@nanoporetech-digital/components 6.1.0 → 6.3.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.
Files changed (286) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/cjs/index-14451c95.js +6 -2
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/nano-alert.cjs.entry.js +1 -1
  5. package/dist/cjs/nano-animation.cjs.entry.js +1209 -0
  6. package/dist/cjs/nano-animation.cjs.entry.js.map +1 -0
  7. package/dist/cjs/nano-components.cjs.js +1 -1
  8. package/dist/cjs/nano-dialog.cjs.entry.js +22 -5
  9. package/dist/cjs/nano-dialog.cjs.entry.js.map +1 -1
  10. package/dist/cjs/nano-drawer.cjs.entry.js +1 -1
  11. package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js.map +1 -1
  12. package/dist/cjs/nano-hero.cjs.entry.js +1 -1
  13. package/dist/cjs/nano-hero.cjs.entry.js.map +1 -1
  14. package/dist/cjs/nano-intersection-observe.cjs.entry.js +131 -0
  15. package/dist/cjs/nano-intersection-observe.cjs.entry.js.map +1 -0
  16. package/dist/cjs/nano-resize-observe_2.cjs.entry.js +1 -1
  17. package/dist/cjs/nano-resize-observe_2.cjs.entry.js.map +1 -1
  18. package/dist/cjs/nano-sticker.cjs.entry.js +2 -27
  19. package/dist/cjs/nano-sticker.cjs.entry.js.map +1 -1
  20. package/dist/cjs/nano-tab-group.cjs.entry.js +3 -4
  21. package/dist/cjs/nano-tab-group.cjs.entry.js.map +1 -1
  22. package/dist/cjs/{nano-table-6f48a747.js → nano-table-9f615d5c.js} +5 -25
  23. package/dist/cjs/nano-table-9f615d5c.js.map +1 -0
  24. package/dist/cjs/nano-table.cjs.entry.js +2 -1
  25. package/dist/cjs/nano-table.cjs.entry.js.map +1 -1
  26. package/dist/cjs/{scroll-e8c21f80.js → scroll-4e95debb.js} +40 -3
  27. package/dist/cjs/scroll-4e95debb.js.map +1 -0
  28. package/dist/cjs/scroll-parent-87393de2.js +31 -0
  29. package/dist/cjs/scroll-parent-87393de2.js.map +1 -0
  30. package/dist/cjs/{table.worker-f3e54773.js → table.worker-6b65a9ea.js} +3 -2
  31. package/dist/cjs/table.worker-6b65a9ea.js.map +1 -0
  32. package/dist/cjs/transitions-20fce787.js.map +1 -1
  33. package/dist/collection/collection-manifest.json +2 -1
  34. package/dist/collection/components/animation/animation.js +547 -0
  35. package/dist/collection/components/animation/animation.js.map +1 -0
  36. package/dist/collection/components/animation/animations/attention_seekers/bounce.js +43 -0
  37. package/dist/collection/components/animation/animations/attention_seekers/flash.js +7 -0
  38. package/dist/collection/components/animation/animations/attention_seekers/headShake.js +8 -0
  39. package/dist/collection/components/animation/animations/attention_seekers/heartBeat.js +7 -0
  40. package/dist/collection/components/animation/animations/attention_seekers/jello.js +15 -0
  41. package/dist/collection/components/animation/animations/attention_seekers/pulse.js +5 -0
  42. package/dist/collection/components/animation/animations/attention_seekers/rubberBand.js +9 -0
  43. package/dist/collection/components/animation/animations/attention_seekers/shake.js +13 -0
  44. package/dist/collection/components/animation/animations/attention_seekers/shakeX.js +13 -0
  45. package/dist/collection/components/animation/animations/attention_seekers/shakeY.js +13 -0
  46. package/dist/collection/components/animation/animations/attention_seekers/swing.js +7 -0
  47. package/dist/collection/components/animation/animations/attention_seekers/tada.js +13 -0
  48. package/dist/collection/components/animation/animations/attention_seekers/wobble.js +18 -0
  49. package/dist/collection/components/animation/animations/back_entrances/backInDown.js +5 -0
  50. package/dist/collection/components/animation/animations/back_entrances/backInLeft.js +5 -0
  51. package/dist/collection/components/animation/animations/back_entrances/backInRight.js +5 -0
  52. package/dist/collection/components/animation/animations/back_entrances/backInUp.js +5 -0
  53. package/dist/collection/components/animation/animations/back_exits/backOutDown.js +5 -0
  54. package/dist/collection/components/animation/animations/back_exits/backOutLeft.js +5 -0
  55. package/dist/collection/components/animation/animations/back_exits/backOutRight.js +5 -0
  56. package/dist/collection/components/animation/animations/back_exits/backOutUp.js +5 -0
  57. package/dist/collection/components/animation/animations/bouncing_entrances/bounceIn.js +14 -0
  58. package/dist/collection/components/animation/animations/bouncing_entrances/bounceInDown.js +20 -0
  59. package/dist/collection/components/animation/animations/bouncing_entrances/bounceInLeft.js +16 -0
  60. package/dist/collection/components/animation/animations/bouncing_entrances/bounceInRight.js +16 -0
  61. package/dist/collection/components/animation/animations/bouncing_entrances/bounceInUp.js +16 -0
  62. package/dist/collection/components/animation/animations/bouncing_exits/bounceOut.js +6 -0
  63. package/dist/collection/components/animation/animations/bouncing_exits/bounceOutDown.js +14 -0
  64. package/dist/collection/components/animation/animations/bouncing_exits/bounceOutLeft.js +12 -0
  65. package/dist/collection/components/animation/animations/bouncing_exits/bounceOutRight.js +8 -0
  66. package/dist/collection/components/animation/animations/bouncing_exits/bounceOutUp.js +18 -0
  67. package/dist/collection/components/animation/animations/easings/easings.js +35 -0
  68. package/dist/collection/components/animation/animations/easings/easings.js.map +1 -0
  69. package/dist/collection/components/animation/animations/fading_entrances/fadeIn.js +4 -0
  70. package/dist/collection/components/animation/animations/fading_entrances/fadeInBottomLeft.js +4 -0
  71. package/dist/collection/components/animation/animations/fading_entrances/fadeInBottomRight.js +4 -0
  72. package/dist/collection/components/animation/animations/fading_entrances/fadeInDown.js +4 -0
  73. package/dist/collection/components/animation/animations/fading_entrances/fadeInDownBig.js +4 -0
  74. package/dist/collection/components/animation/animations/fading_entrances/fadeInLeft.js +4 -0
  75. package/dist/collection/components/animation/animations/fading_entrances/fadeInLeftBig.js +4 -0
  76. package/dist/collection/components/animation/animations/fading_entrances/fadeInRight.js +4 -0
  77. package/dist/collection/components/animation/animations/fading_entrances/fadeInRightBig.js +4 -0
  78. package/dist/collection/components/animation/animations/fading_entrances/fadeInTopLeft.js +4 -0
  79. package/dist/collection/components/animation/animations/fading_entrances/fadeInTopRight.js +4 -0
  80. package/dist/collection/components/animation/animations/fading_entrances/fadeInUp.js +4 -0
  81. package/dist/collection/components/animation/animations/fading_entrances/fadeInUpBig.js +4 -0
  82. package/dist/collection/components/animation/animations/fading_exits/fadeOut.js +4 -0
  83. package/dist/collection/components/animation/animations/fading_exits/fadeOutBottomLeft.js +4 -0
  84. package/dist/collection/components/animation/animations/fading_exits/fadeOutBottomRight.js +4 -0
  85. package/dist/collection/components/animation/animations/fading_exits/fadeOutDown.js +4 -0
  86. package/dist/collection/components/animation/animations/fading_exits/fadeOutDownBig.js +4 -0
  87. package/dist/collection/components/animation/animations/fading_exits/fadeOutLeft.js +4 -0
  88. package/dist/collection/components/animation/animations/fading_exits/fadeOutLeftBig.js +4 -0
  89. package/dist/collection/components/animation/animations/fading_exits/fadeOutRight.js +4 -0
  90. package/dist/collection/components/animation/animations/fading_exits/fadeOutRightBig.js +4 -0
  91. package/dist/collection/components/animation/animations/fading_exits/fadeOutTopLeft.js +4 -0
  92. package/dist/collection/components/animation/animations/fading_exits/fadeOutTopRight.js +4 -0
  93. package/dist/collection/components/animation/animations/fading_exits/fadeOutUp.js +4 -0
  94. package/dist/collection/components/animation/animations/fading_exits/fadeOutUpBig.js +4 -0
  95. package/dist/collection/components/animation/animations/flippers/flip.js +32 -0
  96. package/dist/collection/components/animation/animations/flippers/flipInX.js +20 -0
  97. package/dist/collection/components/animation/animations/flippers/flipInY.js +20 -0
  98. package/dist/collection/components/animation/animations/flippers/flipOutX.js +13 -0
  99. package/dist/collection/components/animation/animations/flippers/flipOutY.js +13 -0
  100. package/dist/collection/components/animation/animations/index.js +203 -0
  101. package/dist/collection/components/animation/animations/index.js.map +1 -0
  102. package/dist/collection/components/animation/animations/lightspeed/lightSpeedInLeft.js +10 -0
  103. package/dist/collection/components/animation/animations/lightspeed/lightSpeedInRight.js +10 -0
  104. package/dist/collection/components/animation/animations/lightspeed/lightSpeedOutLeft.js +8 -0
  105. package/dist/collection/components/animation/animations/lightspeed/lightSpeedOutRight.js +8 -0
  106. package/dist/collection/components/animation/animations/rotating_entrances/rotateIn.js +4 -0
  107. package/dist/collection/components/animation/animations/rotating_entrances/rotateInDownLeft.js +4 -0
  108. package/dist/collection/components/animation/animations/rotating_entrances/rotateInDownRight.js +4 -0
  109. package/dist/collection/components/animation/animations/rotating_entrances/rotateInUpLeft.js +4 -0
  110. package/dist/collection/components/animation/animations/rotating_entrances/rotateInUpRight.js +4 -0
  111. package/dist/collection/components/animation/animations/rotating_exits/rotateOut.js +4 -0
  112. package/dist/collection/components/animation/animations/rotating_exits/rotateOutDownLeft.js +4 -0
  113. package/dist/collection/components/animation/animations/rotating_exits/rotateOutDownRight.js +4 -0
  114. package/dist/collection/components/animation/animations/rotating_exits/rotateOutUpLeft.js +4 -0
  115. package/dist/collection/components/animation/animations/rotating_exits/rotateOutUpRight.js +4 -0
  116. package/dist/collection/components/animation/animations/sliding_entrances/slideInDown.js +4 -0
  117. package/dist/collection/components/animation/animations/sliding_entrances/slideInLeft.js +4 -0
  118. package/dist/collection/components/animation/animations/sliding_entrances/slideInRight.js +4 -0
  119. package/dist/collection/components/animation/animations/sliding_entrances/slideInUp.js +4 -0
  120. package/dist/collection/components/animation/animations/sliding_exits/slideOutDown.js +4 -0
  121. package/dist/collection/components/animation/animations/sliding_exits/slideOutLeft.js +4 -0
  122. package/dist/collection/components/animation/animations/sliding_exits/slideOutRight.js +4 -0
  123. package/dist/collection/components/animation/animations/sliding_exits/slideOutUp.js +4 -0
  124. package/dist/collection/components/animation/animations/specials/hinge.js +18 -0
  125. package/dist/collection/components/animation/animations/specials/jackInTheBox.js +11 -0
  126. package/dist/collection/components/animation/animations/specials/rollIn.js +8 -0
  127. package/dist/collection/components/animation/animations/specials/rollOut.js +8 -0
  128. package/dist/collection/components/animation/animations/zooming_entrances/zoomIn.js +4 -0
  129. package/dist/collection/components/animation/animations/zooming_entrances/zoomInDown.js +14 -0
  130. package/dist/collection/components/animation/animations/zooming_entrances/zoomInLeft.js +14 -0
  131. package/dist/collection/components/animation/animations/zooming_entrances/zoomInRight.js +14 -0
  132. package/dist/collection/components/animation/animations/zooming_entrances/zoomInUp.js +14 -0
  133. package/dist/collection/components/animation/animations/zooming_exits/zoomOut.js +5 -0
  134. package/dist/collection/components/animation/animations/zooming_exits/zoomOutDown.js +14 -0
  135. package/dist/collection/components/animation/animations/zooming_exits/zoomOutLeft.js +12 -0
  136. package/dist/collection/components/animation/animations/zooming_exits/zoomOutRight.js +12 -0
  137. package/dist/collection/components/animation/animations/zooming_exits/zoomOutUp.js +14 -0
  138. package/dist/collection/components/dialog/dialog.css +13 -5
  139. package/dist/collection/components/dialog/dialog.js +20 -3
  140. package/dist/collection/components/dialog/dialog.js.map +1 -1
  141. package/dist/collection/components/hero/hero.css +0 -1
  142. package/dist/collection/components/intersection-observe/intersection-observe.js +256 -0
  143. package/dist/collection/components/intersection-observe/intersection-observe.js.map +1 -0
  144. package/dist/collection/components/resize-observe/resize-observe.js +1 -1
  145. package/dist/collection/components/resize-observe/resize-observe.js.map +1 -1
  146. package/dist/collection/components/select/select.js +5 -5
  147. package/dist/collection/components/select/select.js.map +1 -1
  148. package/dist/collection/components/sticker/sticker.js +2 -27
  149. package/dist/collection/components/sticker/sticker.js.map +1 -1
  150. package/dist/collection/components/table/table.js +2 -1
  151. package/dist/collection/components/table/table.js.map +1 -1
  152. package/dist/collection/components/table/table.utils.js +0 -21
  153. package/dist/collection/components/table/table.utils.js.map +1 -1
  154. package/dist/collection/components/tabs/tab-group.js +2 -3
  155. package/dist/collection/components/tabs/tab-group.js.map +1 -1
  156. package/dist/collection/utils/scroll-parent.js +26 -0
  157. package/dist/collection/utils/scroll-parent.js.map +1 -0
  158. package/dist/collection/utils/scroll.js +39 -2
  159. package/dist/collection/utils/scroll.js.map +1 -1
  160. package/dist/collection/utils/transitions.js +1 -0
  161. package/dist/collection/utils/transitions.js.map +1 -1
  162. package/dist/components/index.d.ts +2 -1
  163. package/dist/components/index.js +2 -1
  164. package/dist/components/index.js.map +1 -1
  165. package/dist/components/{nano-aspect-ratio.d.ts → nano-animation.d.ts} +4 -4
  166. package/dist/components/nano-animation.js +1239 -0
  167. package/dist/components/nano-animation.js.map +1 -0
  168. package/dist/components/nano-dialog.js +21 -4
  169. package/dist/components/nano-dialog.js.map +1 -1
  170. package/dist/components/nano-hero.js +1 -1
  171. package/dist/components/nano-hero.js.map +1 -1
  172. package/dist/components/nano-intersection-observe.d.ts +11 -0
  173. package/dist/components/nano-intersection-observe.js +149 -0
  174. package/dist/components/nano-intersection-observe.js.map +1 -0
  175. package/dist/components/nano-tab-group.js +2 -3
  176. package/dist/components/nano-tab-group.js.map +1 -1
  177. package/dist/components/resize-observe.js +1 -1
  178. package/dist/components/resize-observe.js.map +1 -1
  179. package/dist/components/scroll-parent.js +29 -0
  180. package/dist/components/scroll-parent.js.map +1 -0
  181. package/dist/components/scroll.js +39 -2
  182. package/dist/components/scroll.js.map +1 -1
  183. package/dist/components/select.js.map +1 -1
  184. package/dist/components/sticker.js +2 -27
  185. package/dist/components/sticker.js.map +1 -1
  186. package/dist/components/table.js +1 -21
  187. package/dist/components/table.js.map +1 -1
  188. package/dist/components/transitions.js.map +1 -1
  189. package/dist/esm/index-9695db0a.js +6 -2
  190. package/dist/esm/loader.js +1 -1
  191. package/dist/esm/nano-alert.entry.js +1 -1
  192. package/dist/esm/nano-animation.entry.js +1205 -0
  193. package/dist/esm/nano-animation.entry.js.map +1 -0
  194. package/dist/esm/nano-components.js +1 -1
  195. package/dist/esm/nano-dialog.entry.js +22 -5
  196. package/dist/esm/nano-dialog.entry.js.map +1 -1
  197. package/dist/esm/nano-drawer.entry.js +1 -1
  198. package/dist/esm/nano-global-nav-user-profile_3.entry.js.map +1 -1
  199. package/dist/esm/nano-hero.entry.js +1 -1
  200. package/dist/esm/nano-hero.entry.js.map +1 -1
  201. package/dist/esm/nano-intersection-observe.entry.js +127 -0
  202. package/dist/esm/nano-intersection-observe.entry.js.map +1 -0
  203. package/dist/esm/nano-resize-observe_2.entry.js +1 -1
  204. package/dist/esm/nano-resize-observe_2.entry.js.map +1 -1
  205. package/dist/esm/nano-sticker.entry.js +2 -27
  206. package/dist/esm/nano-sticker.entry.js.map +1 -1
  207. package/dist/esm/nano-tab-group.entry.js +3 -4
  208. package/dist/esm/nano-tab-group.entry.js.map +1 -1
  209. package/dist/esm/{nano-table-fc01a927.js → nano-table-66bee831.js} +3 -23
  210. package/dist/esm/nano-table-66bee831.js.map +1 -0
  211. package/dist/esm/nano-table.entry.js +2 -1
  212. package/dist/esm/nano-table.entry.js.map +1 -1
  213. package/dist/esm/{scroll-ac332213.js → scroll-762b3e1a.js} +40 -3
  214. package/dist/esm/scroll-762b3e1a.js.map +1 -0
  215. package/dist/esm/scroll-parent-bab1cbf7.js +29 -0
  216. package/dist/esm/scroll-parent-bab1cbf7.js.map +1 -0
  217. package/dist/esm/{table.worker-c70f6379.js → table.worker-936e6d51.js} +3 -2
  218. package/dist/esm/table.worker-936e6d51.js.map +1 -0
  219. package/dist/esm/transitions-bd15e312.js.map +1 -1
  220. package/dist/nano-components/nano-alert.entry.js +1 -1
  221. package/dist/nano-components/nano-animation.entry.js +5 -0
  222. package/dist/nano-components/nano-animation.entry.js.map +1 -0
  223. package/dist/nano-components/nano-components.css +1 -1
  224. package/dist/nano-components/nano-components.esm.js +1 -1
  225. package/dist/nano-components/nano-components.esm.js.map +1 -1
  226. package/dist/nano-components/nano-dialog.entry.js +1 -1
  227. package/dist/nano-components/nano-dialog.entry.js.map +1 -1
  228. package/dist/nano-components/nano-drawer.entry.js +1 -1
  229. package/dist/nano-components/nano-global-nav-user-profile_3.entry.js.map +1 -1
  230. package/dist/nano-components/nano-hero.entry.js +1 -1
  231. package/dist/nano-components/nano-hero.entry.js.map +1 -1
  232. package/dist/nano-components/nano-intersection-observe.entry.js +5 -0
  233. package/dist/nano-components/nano-intersection-observe.entry.js.map +1 -0
  234. package/dist/nano-components/nano-resize-observe_2.entry.js +1 -1
  235. package/dist/nano-components/nano-resize-observe_2.entry.js.map +1 -1
  236. package/dist/nano-components/nano-sticker.entry.js +1 -1
  237. package/dist/nano-components/nano-sticker.entry.js.map +1 -1
  238. package/dist/nano-components/nano-tab-group.entry.js +1 -1
  239. package/dist/nano-components/nano-tab-group.entry.js.map +1 -1
  240. package/dist/nano-components/nano-table-66bee831.js +5 -0
  241. package/dist/nano-components/nano-table-66bee831.js.map +1 -0
  242. package/dist/nano-components/nano-table.entry.js +1 -1
  243. package/dist/nano-components/scroll-762b3e1a.js +5 -0
  244. package/dist/nano-components/scroll-762b3e1a.js.map +1 -0
  245. package/dist/nano-components/scroll-parent-bab1cbf7.js +5 -0
  246. package/dist/nano-components/scroll-parent-bab1cbf7.js.map +1 -0
  247. package/dist/nano-components/table.worker-936e6d51.js +5 -0
  248. package/dist/nano-components/transitions-bd15e312.js.map +1 -1
  249. package/dist/types/components/animation/animation.d.ts +74 -0
  250. package/dist/types/components/animation/animations/easings/easings.d.ts +31 -0
  251. package/dist/types/components/animation/animations/index.d.ts +101 -0
  252. package/dist/types/components/intersection-observe/intersection-observe.d.ts +45 -0
  253. package/dist/types/components/select/select.d.ts +2 -4
  254. package/dist/types/components/sticker/sticker.d.ts +0 -5
  255. package/dist/types/components/table/table.utils.d.ts +0 -6
  256. package/dist/types/components.d.ts +209 -42
  257. package/dist/types/interface.d.ts +6 -2
  258. package/dist/types/utils/scroll-parent.d.ts +6 -0
  259. package/docs-json.json +945 -31
  260. package/docs-vscode.json +488 -8
  261. package/hydrate/index.js +1568 -235
  262. package/package.json +2 -2
  263. package/dist/cjs/nano-aspect-ratio.cjs.entry.js +0 -53
  264. package/dist/cjs/nano-aspect-ratio.cjs.entry.js.map +0 -1
  265. package/dist/cjs/nano-table-6f48a747.js.map +0 -1
  266. package/dist/cjs/scroll-e8c21f80.js.map +0 -1
  267. package/dist/cjs/table.worker-f3e54773.js.map +0 -1
  268. package/dist/collection/components/aspect-ratio/aspect-ratio.css +0 -38
  269. package/dist/collection/components/aspect-ratio/aspect-ratio.js +0 -106
  270. package/dist/collection/components/aspect-ratio/aspect-ratio.js.map +0 -1
  271. package/dist/components/nano-aspect-ratio.js +0 -70
  272. package/dist/components/nano-aspect-ratio.js.map +0 -1
  273. package/dist/esm/nano-aspect-ratio.entry.js +0 -49
  274. package/dist/esm/nano-aspect-ratio.entry.js.map +0 -1
  275. package/dist/esm/nano-table-fc01a927.js.map +0 -1
  276. package/dist/esm/scroll-ac332213.js.map +0 -1
  277. package/dist/esm/table.worker-c70f6379.js.map +0 -1
  278. package/dist/nano-components/nano-aspect-ratio.entry.js +0 -5
  279. package/dist/nano-components/nano-aspect-ratio.entry.js.map +0 -1
  280. package/dist/nano-components/nano-table-fc01a927.js +0 -5
  281. package/dist/nano-components/nano-table-fc01a927.js.map +0 -1
  282. package/dist/nano-components/scroll-ac332213.js +0 -5
  283. package/dist/nano-components/scroll-ac332213.js.map +0 -1
  284. package/dist/nano-components/table.worker-c70f6379.js +0 -5
  285. package/dist/types/components/aspect-ratio/aspect-ratio.d.ts +0 -19
  286. /package/dist/nano-components/{table.worker-c70f6379.js.map → table.worker-936e6d51.js.map} +0 -0
@@ -86,7 +86,10 @@ export class Dialog {
86
86
  this.open ? this.show() : this.hide();
87
87
  }
88
88
  handleHoistChange() {
89
- if (!this.hoist || Array.from(document.body.children).includes(this.host))
89
+ // if native popover is supported then bail as this is not required
90
+ if (globalThis.HTMLElement.prototype.hasOwnProperty('popover') ||
91
+ !this.hoist ||
92
+ Array.from(document.body.children).includes(this.host))
90
93
  return;
91
94
  document.body.prepend(this.host);
92
95
  }
@@ -106,6 +109,11 @@ export class Dialog {
106
109
  this.willShow = true;
107
110
  this.open = true;
108
111
  this.modal.activate();
112
+ // @ts-ignore
113
+ if (typeof this.dialog?.showPopover === 'function') {
114
+ // @ts-ignore
115
+ this.dialog.showPopover();
116
+ }
109
117
  lockBodyScrolling(this.host);
110
118
  if (this.open) {
111
119
  // Wait for the next frame before setting initial focus so the dialog is technically visible
@@ -130,13 +138,20 @@ export class Dialog {
130
138
  this.willHide = true;
131
139
  this.open = false;
132
140
  this.modal.deactivate();
133
- unlockBodyScrolling(this.host);
134
141
  this.stopVideos();
135
142
  // Restore focus to the original trigger
136
143
  const trigger = this.originalTrigger;
137
144
  if (trigger && typeof trigger.focus === 'function') {
138
145
  setTimeout(() => trigger.focus());
139
146
  }
147
+ setTimeout(() => {
148
+ // @ts-ignore
149
+ if (!this.open && typeof this.dialog?.hidePopover === 'function') {
150
+ // @ts-ignore
151
+ this.dialog.hidePopover();
152
+ }
153
+ unlockBodyScrolling(this.host);
154
+ }, 300);
140
155
  }
141
156
  stopVideos() {
142
157
  const videos = Array.from(this.host.querySelectorAll('iframe,video'));
@@ -178,7 +193,9 @@ export class Dialog {
178
193
  'dialog--has-header': !this.noHeader,
179
194
  'dialog--nodismiss': this.noDismiss,
180
195
  'dialog--with-ribbon': this.showRibbon,
181
- }, onKeyDown: this.handleKeyDown, ref: (ele) => (this.dialog = ele) }, h("div", { part: "overlay", class: "dialog__overlay", ref: (el) => (this.overlay = el), onClick: this.requestClose }), h("div", { ref: (el) => (this.panel = el), part: "panel", class: "dialog__panel", role: "dialog", "aria-modal": "true", "aria-hidden": this.open ? 'false' : 'true', "aria-label": this.noHeader ? this.label : null, "aria-labelledby": !this.noHeader ? `${this.componentId}-title` : null, tabIndex: 0 }, h("div", { class: "dialog__body-wrap" }, !this.noHeader && (h("nano-sticker", null, h("div", { part: "header", class: "dialog__header" }, h("span", { part: "title", class: "dialog__title", id: `${this.componentId}-title` }, h("slot", { name: "label" }, this.label || String.fromCharCode(65279))), !this.noUserDismiss && (h("nano-icon-button", { part: "close-button", exportparts: "base:close-button__base", class: "dialog__close-icon", label: "close dialog", onClick: this.requestClose, iconName: "light/times" }))))), h("div", { part: "body", class: "dialog__body" }, h("slot", null)), !this.noFooter && (this.hasFooter || !this.noUserDismiss) && (h("nano-sticker", { position: "bottom" }, h("footer", { part: "footer", class: "dialog__footer" }, h("slot", { name: "footer", onSlotchange: this.handleSlotChange }), !this.noUserDismiss && (h("button", { class: "dialog__close-txt", onClick: this.requestClose }, "Close"))))))))));
196
+ }, onKeyDown: this.handleKeyDown, ref: (ele) => (this.dialog = ele),
197
+ // @ts-ignore
198
+ popover: "manual" }, h("div", { part: "overlay", class: "dialog__overlay", ref: (el) => (this.overlay = el), onClick: this.requestClose }), h("div", { ref: (el) => (this.panel = el), part: "panel", class: "dialog__panel", role: "dialog", "aria-modal": "true", "aria-hidden": this.open ? 'false' : 'true', "aria-label": this.noHeader ? this.label : null, "aria-labelledby": !this.noHeader ? `${this.componentId}-title` : null, tabIndex: -1 }, h("div", { class: "dialog__body-wrap" }, !this.noHeader && (h("nano-sticker", null, h("header", { part: "header", class: "dialog__header" }, h("span", { part: "title", class: "dialog__title", id: `${this.componentId}-title` }, h("slot", { name: "label" }, this.label || String.fromCharCode(65279))), !this.noUserDismiss && (h("nano-icon-button", { part: "close-button", exportparts: "base:close-button__base", class: "dialog__close-icon", label: "close dialog", onClick: this.requestClose, iconName: "light/times" }))))), h("div", { part: "body", class: "dialog__body" }, h("slot", null)), !this.noFooter && (this.hasFooter || !this.noUserDismiss) && (h("footer", { part: "footer", class: "dialog__footer" }, h("slot", { name: "footer", onSlotchange: this.handleSlotChange }), !this.noUserDismiss && (h("button", { class: "dialog__close-txt", onClick: this.requestClose }, "Close")))))))));
182
199
  }
183
200
  static get is() { return "nano-dialog"; }
184
201
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../../src/components/dialog/dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,KAAK,EAEL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,EACL,CAAC,EACD,IAAI,GAEL,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EACL,cAAc,GAEf,MAAM,mCAAmC,CAAC;AAE3C,I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CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n Method,\n Prop,\n State,\n Watch,\n h,\n Host,\n ComponentInterface,\n} from '@stencil/core';\nimport Modal from '../../utils/modal';\nimport { lockBodyScrolling, unlockBodyScrolling } from '../../utils/scroll';\nimport { hasSlot } from '../../utils/slot';\nimport {\n ComponentStore,\n StorageMethods,\n} from '../../utils/store/component-store';\n\nlet id = 0;\n\n/**\n * Dialogs, sometimes called \"modals\", appear above the page and require the user's immediate attention.\n *\n * @part base - The component’s base wrapper\n * @part overlay - The overlay that covers the screen behind the dialog\n * @part panel - The dialog’s panel (where the dialog and its content are rendered)\n * @part header - The dialog’s header. This element wraps the title and header actions\n * @part title - The dialog’s title\n * @part close-button - The `<nano-icon-button>` close button\n * @part close-button__base - The close button's exported `base` part\n * @part body - dilog body / content\n * @part footer - dialog footer bar\n *\n * @slot label - The dialog's label. Alternatively, you can use the label prop.\n * @slot footer - The dialog's footer, usually one or more buttons representing various options.\n * @slot - The dialog's content.\n */\n@Component({\n tag: 'nano-dialog',\n styleUrl: 'dialog.scss',\n shadow: true,\n})\nexport class Dialog implements ComponentInterface {\n private componentId = `dialog-${++id}`;\n private modal: Modal;\n private willShow = false;\n private willHide = false;\n private originalTrigger: HTMLElement | null;\n private overlay: HTMLElement;\n private dialog: HTMLElement;\n\n get panel() {\n return this._panel;\n }\n set panel(p: HTMLElement) {\n if (this._panel) {\n this.panel.removeEventListener('transitionend', this.handleTransitionEnd);\n }\n p.addEventListener('transitionend', this.handleTransitionEnd);\n this._panel = p;\n }\n private _panel: HTMLElement;\n\n @Element() host: HTMLNanoDialogElement;\n @State() noDismiss = false;\n @State() hasFooter = false;\n\n /** Show a colour ribbon at the top of the modal */\n @Prop() showRibbon = true;\n\n /** Indicates whether or not the dialog is open. You can use this in lieu of the show/hide methods. */\n @Prop({ mutable: true, reflect: true }) open = false;\n\n @Watch('open')\n handleOpenChange() {\n this.open ? this.show() : this.hide();\n }\n\n /** The dialog's label as displayed in the header. You should always include a relevant\n * label even when using `no-header`, as it is required for proper accessibility. */\n @Prop() label!: string;\n\n /** Set to true to disable the header. This will also remove the default close button,\n * so please ensure you provide an easy, accessible way for users to dismiss the dialog. */\n @Prop() noHeader = false;\n\n /** Set to true to disable the footer. This will also remove the footer close button,\n * so please ensure you provide an easy, accessible way for users to dismiss the dialog. */\n @Prop() noFooter = false;\n\n /** An alternative to `preventDefault()` on the `nanoRequestClose` event. This will hide the close button and disable clicks on the overlay or presses the `Escape` key */\n @Prop() noUserDismiss = false;\n\n /** Store search queries (against this ID) to the component store. Use in conjunction with storeMethod */\n @Prop() storeId?: string;\n\n /** The method of storage. Either session storage, url hash (after the '#') or url query (after the '?'). */\n @Prop() storeMethod: StorageMethods = 'url-hash';\n\n /** Relocate the dialog to the root of the DOM. Useful for elements bound via css `transform: ...` */\n @Prop() hoist = false;\n\n @Watch('hoist')\n handleHoistChange() {\n if (!this.hoist || Array.from(document.body.children).includes(this.host))\n return;\n document.body.prepend(this.host);\n }\n\n /** Emitted when the dialog opens. Calling `event.preventDefault()` will prevent it from being opened. */\n @Event() nanoShow: EventEmitter;\n\n /** Emitted after the dialog opens and all transitions are complete. */\n @Event() nanoAfterShow: EventEmitter;\n\n /** Emitted when the dialog closes. Calling `event.preventDefault()` will prevent it from being closed. */\n @Event() nanoHide: EventEmitter;\n\n /** Emitted after the dialog closes and all transitions are complete. */\n @Event() nanoAfterHide: EventEmitter;\n\n /** Emitted when the dialog opens and the panel gains focus. Calling `event.preventDefault()` will prevent\n * focus and allow you to set it on a different element in the dialog, such as an input or button. */\n @Event() nanoInitialFocus: EventEmitter;\n\n /** Emitted when the user clicks the close button, clicks the overlay, or presses the `Escape` key. Calling `event.preventDefault()` will prevent the dialog from closing. */\n @Event() nanoRequestClose: EventEmitter;\n\n /** Shows the dialog */\n @Method()\n async show() {\n if (this.willShow) {\n return;\n }\n\n const nanoShow = this.nanoShow.emit();\n if (nanoShow.defaultPrevented) {\n this.open = false;\n return;\n }\n\n if (this.dialog) this.dialog.hidden = false;\n this.originalTrigger = document.activeElement as HTMLElement;\n this.willShow = true;\n this.open = true;\n this.modal.activate();\n\n lockBodyScrolling(this.host);\n\n if (this.open) {\n // Wait for the next frame before setting initial focus so the dialog is technically visible\n this.host.addEventListener(\n 'nanoAfterShow',\n () => {\n const nanoInitialFocus = this.nanoInitialFocus.emit();\n if (!nanoInitialFocus.defaultPrevented) {\n this.panel.focus({ preventScroll: true });\n }\n },\n { once: true }\n );\n }\n }\n\n /** Hides the dialog */\n @Method()\n async hide() {\n if (this.willHide) {\n return;\n }\n\n const nanoHide = this.nanoHide.emit();\n if (nanoHide.defaultPrevented) {\n this.open = true;\n return;\n }\n\n this.willHide = true;\n this.open = false;\n this.modal.deactivate();\n unlockBodyScrolling(this.host);\n this.stopVideos();\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (trigger && typeof trigger.focus === 'function') {\n setTimeout(() => trigger.focus());\n }\n }\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n this.requestClose();\n }\n };\n\n private requestClose = () => {\n const nanoOverlayDismiss = this.nanoRequestClose.emit();\n\n if (!nanoOverlayDismiss.defaultPrevented && !this.noUserDismiss) {\n this.hide();\n } else {\n this.noDismiss = true;\n setTimeout(() => (this.noDismiss = false), 250);\n }\n };\n\n private handleTransitionEnd = (event: TransitionEvent) => {\n if (\n event.propertyName === 'opacity' &&\n event\n .composedPath()\n .find((node) => node === this.panel || node === this.overlay)\n ) {\n // Ensure we only emit one event when the target element is no longer visible\n this.willShow = false;\n this.willHide = false;\n this.open ? this.nanoAfterShow.emit() : this.nanoAfterHide.emit();\n if (!this.open) this.dialog.hidden = true;\n }\n };\n\n private handleSlotChange = () => {\n this.hasFooter = hasSlot(this.host, 'footer');\n };\n\n private stopVideos() {\n const videos: (HTMLVideoElement | HTMLIFrameElement)[] = Array.from(\n this.host.querySelectorAll('iframe,video')\n );\n videos.forEach((video) => {\n if (video.tagName.toLowerCase() === 'video')\n (video as HTMLVideoElement).pause();\n else {\n const src = video.src;\n video.src = src;\n }\n });\n }\n\n connectedCallback() {\n this.handleHoistChange();\n this.modal = new Modal(this.host);\n }\n\n componentWillLoad() {\n this.handleSlotChange();\n // Show on init if open\n if (this.open) this.show();\n if (this.storeId)\n ComponentStore.init(this, ['open'], this.storeMethod, this.storeId);\n }\n\n componentDidLoad() {\n this.dialog.hidden = !this.open;\n }\n\n disconnectedCallback() {\n unlockBodyScrolling(this.host);\n if (!this.panel) return;\n this.panel.removeEventListener('transitionend', this.handleTransitionEnd);\n }\n\n render() {\n return (\n <Host>\n <div\n part=\"base\"\n class={{\n dialog: true,\n 'dialog--open': this.open,\n 'dialog--has-footer': !this.noFooter,\n 'dialog--has-header': !this.noHeader,\n 'dialog--nodismiss': this.noDismiss,\n 'dialog--with-ribbon': this.showRibbon,\n }}\n onKeyDown={this.handleKeyDown}\n ref={(ele) => (this.dialog = ele)}\n >\n <div\n part=\"overlay\"\n class=\"dialog__overlay\"\n ref={(el) => (this.overlay = el)}\n onClick={this.requestClose}\n />\n\n <div\n ref={(el) => (this.panel = el)}\n part=\"panel\"\n class=\"dialog__panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-hidden={this.open ? 'false' : 'true'}\n aria-label={this.noHeader ? this.label : null}\n aria-labelledby={\n !this.noHeader ? `${this.componentId}-title` : null\n }\n tabIndex={0}\n >\n <div class=\"dialog__body-wrap\">\n {!this.noHeader && (\n <nano-sticker>\n <div part=\"header\" class=\"dialog__header\">\n <span\n part=\"title\"\n class=\"dialog__title\"\n id={`${this.componentId}-title`}\n >\n <slot name=\"label\">\n {/* If there's no label, use an invisible character to prevent the heading from collapsing */}\n {this.label || String.fromCharCode(65279)}\n </slot>\n </span>\n {!this.noUserDismiss && (\n <nano-icon-button\n part=\"close-button\"\n exportparts=\"base:close-button__base\"\n class=\"dialog__close-icon\"\n label=\"close dialog\"\n onClick={this.requestClose}\n iconName=\"light/times\"\n />\n )}\n </div>\n </nano-sticker>\n )}\n <div part=\"body\" class=\"dialog__body\">\n <slot />\n </div>\n {!this.noFooter && (this.hasFooter || !this.noUserDismiss) && (\n <nano-sticker position=\"bottom\">\n <footer part=\"footer\" class=\"dialog__footer\">\n <slot name=\"footer\" onSlotchange={this.handleSlotChange} />\n {!this.noUserDismiss && (\n <button\n class=\"dialog__close-txt\"\n onClick={this.requestClose}\n >\n Close\n </button>\n )}\n </footer>\n </nano-sticker>\n )}\n </div>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../../src/components/dialog/dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,KAAK,EAEL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,EACL,CAAC,EACD,IAAI,GAEL,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EACL,cAAc,GAEf,MAAM,mCAAmC,CAAC;AAE3C,IAAI,EAAE,GAAG,CAAC,CAAC;AAEX;;;;;;;;;;;;;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AC,cAAc;cACnC,eAAQ,CACJ;YACL,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAC5D,cAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,gBAAgB;cAC1C,YAAM,IAAI,EAAC,QAAQ,EAAC,YAAY,EAAE,IAAI,CAAC,gBAAgB,GAAI;cAC1D,CAAC,IAAI,CAAC,aAAa,IAAI,CACtB,cACE,KAAK,EAAC,mBAAmB,EACzB,OAAO,EAAE,IAAI,CAAC,YAAY,YAGnB,CACV,CACM,CACV,CACG,CACF,CACF,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n Method,\n Prop,\n State,\n Watch,\n h,\n Host,\n ComponentInterface,\n} from '@stencil/core';\nimport Modal from '../../utils/modal';\nimport { lockBodyScrolling, unlockBodyScrolling } from '../../utils/scroll';\nimport { hasSlot } from '../../utils/slot';\nimport {\n ComponentStore,\n StorageMethods,\n} from '../../utils/store/component-store';\n\nlet id = 0;\n\n/**\n * Dialogs, sometimes called \"modals\", appear above the page and require the user's immediate attention.\n *\n * @part base - The component’s base wrapper\n * @part overlay - The overlay that covers the screen behind the dialog\n * @part panel - The dialog’s panel (where the dialog and its content are rendered)\n * @part header - The dialog’s header. This element wraps the title and header actions\n * @part title - The dialog’s title\n * @part close-button - The `<nano-icon-button>` close button\n * @part close-button__base - The close button's exported `base` part\n * @part body - dilog body / content\n * @part footer - dialog footer bar\n *\n * @slot label - The dialog's label. Alternatively, you can use the label prop.\n * @slot footer - The dialog's footer, usually one or more buttons representing various options.\n * @slot - The dialog's content.\n */\n@Component({\n tag: 'nano-dialog',\n styleUrl: 'dialog.scss',\n shadow: true,\n})\nexport class Dialog implements ComponentInterface {\n private componentId = `dialog-${++id}`;\n private modal: Modal;\n private willShow = false;\n private willHide = false;\n private originalTrigger: HTMLElement | null;\n private overlay: HTMLElement;\n private dialog: HTMLElement;\n\n get panel() {\n return this._panel;\n }\n set panel(p: HTMLElement) {\n if (this._panel) {\n this.panel.removeEventListener('transitionend', this.handleTransitionEnd);\n }\n p.addEventListener('transitionend', this.handleTransitionEnd);\n this._panel = p;\n }\n private _panel: HTMLElement;\n\n @Element() host: HTMLNanoDialogElement;\n @State() noDismiss = false;\n @State() hasFooter = false;\n\n /** Show a colour ribbon at the top of the modal */\n @Prop() showRibbon = true;\n\n /** Indicates whether or not the dialog is open. You can use this in lieu of the show/hide methods. */\n @Prop({ mutable: true, reflect: true }) open = false;\n\n @Watch('open')\n handleOpenChange() {\n this.open ? this.show() : this.hide();\n }\n\n /** The dialog's label as displayed in the header. You should always include a relevant\n * label even when using `no-header`, as it is required for proper accessibility. */\n @Prop() label!: string;\n\n /** Set to true to disable the header. This will also remove the default close button,\n * so please ensure you provide an easy, accessible way for users to dismiss the dialog. */\n @Prop() noHeader = false;\n\n /** Set to true to disable the footer. This will also remove the footer close button,\n * so please ensure you provide an easy, accessible way for users to dismiss the dialog. */\n @Prop() noFooter = false;\n\n /** An alternative to `preventDefault()` on the `nanoRequestClose` event. This will hide the close button and disable clicks on the overlay or presses the `Escape` key */\n @Prop() noUserDismiss = false;\n\n /** Store search queries (against this ID) to the component store. Use in conjunction with storeMethod */\n @Prop() storeId?: string;\n\n /** The method of storage. Either session storage, url hash (after the '#') or url query (after the '?'). */\n @Prop() storeMethod: StorageMethods = 'url-hash';\n\n /** Relocate the dialog to the root of the DOM. Useful for elements bound via css `transform: ...` */\n @Prop() hoist = false;\n\n @Watch('hoist')\n handleHoistChange() {\n // if native popover is supported then bail as this is not required\n if (\n globalThis.HTMLElement.prototype.hasOwnProperty('popover') ||\n !this.hoist ||\n Array.from(document.body.children).includes(this.host)\n )\n return;\n document.body.prepend(this.host);\n }\n\n /** Emitted when the dialog opens. Calling `event.preventDefault()` will prevent it from being opened. */\n @Event() nanoShow: EventEmitter;\n\n /** Emitted after the dialog opens and all transitions are complete. */\n @Event() nanoAfterShow: EventEmitter;\n\n /** Emitted when the dialog closes. Calling `event.preventDefault()` will prevent it from being closed. */\n @Event() nanoHide: EventEmitter;\n\n /** Emitted after the dialog closes and all transitions are complete. */\n @Event() nanoAfterHide: EventEmitter;\n\n /** Emitted when the dialog opens and the panel gains focus. Calling `event.preventDefault()` will prevent\n * focus and allow you to set it on a different element in the dialog, such as an input or button. */\n @Event() nanoInitialFocus: EventEmitter;\n\n /** Emitted when the user clicks the close button, clicks the overlay, or presses the `Escape` key. Calling `event.preventDefault()` will prevent the dialog from closing. */\n @Event() nanoRequestClose: EventEmitter;\n\n /** Shows the dialog */\n @Method()\n async show() {\n if (this.willShow) {\n return;\n }\n\n const nanoShow = this.nanoShow.emit();\n if (nanoShow.defaultPrevented) {\n this.open = false;\n return;\n }\n\n if (this.dialog) this.dialog.hidden = false;\n this.originalTrigger = document.activeElement as HTMLElement;\n this.willShow = true;\n\n this.open = true;\n this.modal.activate();\n\n // @ts-ignore\n if (typeof this.dialog?.showPopover === 'function') {\n // @ts-ignore\n this.dialog.showPopover();\n }\n\n lockBodyScrolling(this.host);\n\n if (this.open) {\n // Wait for the next frame before setting initial focus so the dialog is technically visible\n this.host.addEventListener(\n 'nanoAfterShow',\n () => {\n const nanoInitialFocus = this.nanoInitialFocus.emit();\n if (!nanoInitialFocus.defaultPrevented) {\n this.panel.focus({ preventScroll: true });\n }\n },\n { once: true }\n );\n }\n }\n\n /** Hides the dialog */\n @Method()\n async hide() {\n if (this.willHide) {\n return;\n }\n\n const nanoHide = this.nanoHide.emit();\n if (nanoHide.defaultPrevented) {\n this.open = true;\n return;\n }\n\n this.willHide = true;\n this.open = false;\n this.modal.deactivate();\n this.stopVideos();\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (trigger && typeof trigger.focus === 'function') {\n setTimeout(() => trigger.focus());\n }\n\n setTimeout(() => {\n // @ts-ignore\n if (!this.open && typeof this.dialog?.hidePopover === 'function') {\n // @ts-ignore\n this.dialog.hidePopover();\n }\n unlockBodyScrolling(this.host);\n }, 300);\n }\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n this.requestClose();\n }\n };\n\n private requestClose = () => {\n const nanoOverlayDismiss = this.nanoRequestClose.emit();\n\n if (!nanoOverlayDismiss.defaultPrevented && !this.noUserDismiss) {\n this.hide();\n } else {\n this.noDismiss = true;\n setTimeout(() => (this.noDismiss = false), 250);\n }\n };\n\n private handleTransitionEnd = (event: TransitionEvent) => {\n if (\n event.propertyName === 'opacity' &&\n event\n .composedPath()\n .find((node) => node === this.panel || node === this.overlay)\n ) {\n // Ensure we only emit one event when the target element is no longer visible\n this.willShow = false;\n this.willHide = false;\n this.open ? this.nanoAfterShow.emit() : this.nanoAfterHide.emit();\n if (!this.open) this.dialog.hidden = true;\n }\n };\n\n private handleSlotChange = () => {\n this.hasFooter = hasSlot(this.host, 'footer');\n };\n\n private stopVideos() {\n const videos: (HTMLVideoElement | HTMLIFrameElement)[] = Array.from(\n this.host.querySelectorAll('iframe,video')\n );\n videos.forEach((video) => {\n if (video.tagName.toLowerCase() === 'video')\n (video as HTMLVideoElement).pause();\n else {\n const src = video.src;\n video.src = src;\n }\n });\n }\n\n connectedCallback() {\n this.handleHoistChange();\n this.modal = new Modal(this.host);\n }\n\n componentWillLoad() {\n this.handleSlotChange();\n // Show on init if open\n if (this.open) this.show();\n if (this.storeId)\n ComponentStore.init(this, ['open'], this.storeMethod, this.storeId);\n }\n\n componentDidLoad() {\n this.dialog.hidden = !this.open;\n }\n\n disconnectedCallback() {\n unlockBodyScrolling(this.host);\n if (!this.panel) return;\n this.panel.removeEventListener('transitionend', this.handleTransitionEnd);\n }\n\n render() {\n return (\n <Host>\n <div\n part=\"base\"\n class={{\n dialog: true,\n 'dialog--open': this.open,\n 'dialog--has-footer': !this.noFooter,\n 'dialog--has-header': !this.noHeader,\n 'dialog--nodismiss': this.noDismiss,\n 'dialog--with-ribbon': this.showRibbon,\n }}\n onKeyDown={this.handleKeyDown}\n ref={(ele) => (this.dialog = ele)}\n // @ts-ignore\n popover=\"manual\"\n >\n <div\n part=\"overlay\"\n class=\"dialog__overlay\"\n ref={(el) => (this.overlay = el)}\n onClick={this.requestClose}\n />\n\n <div\n ref={(el) => (this.panel = el)}\n part=\"panel\"\n class=\"dialog__panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-hidden={this.open ? 'false' : 'true'}\n aria-label={this.noHeader ? this.label : null}\n aria-labelledby={\n !this.noHeader ? `${this.componentId}-title` : null\n }\n tabIndex={-1}\n >\n <div class=\"dialog__body-wrap\">\n {!this.noHeader && (\n <nano-sticker>\n <header part=\"header\" class=\"dialog__header\">\n <span\n part=\"title\"\n class=\"dialog__title\"\n id={`${this.componentId}-title`}\n >\n <slot name=\"label\">\n {/* If there's no label, use an invisible character to prevent the heading from collapsing */}\n {this.label || String.fromCharCode(65279)}\n </slot>\n </span>\n {!this.noUserDismiss && (\n <nano-icon-button\n part=\"close-button\"\n exportparts=\"base:close-button__base\"\n class=\"dialog__close-icon\"\n label=\"close dialog\"\n onClick={this.requestClose}\n iconName=\"light/times\"\n />\n )}\n </header>\n </nano-sticker>\n )}\n <div part=\"body\" class=\"dialog__body\">\n <slot />\n </div>\n {!this.noFooter && (this.hasFooter || !this.noUserDismiss) && (\n <footer part=\"footer\" class=\"dialog__footer\">\n <slot name=\"footer\" onSlotchange={this.handleSlotChange} />\n {!this.noUserDismiss && (\n <button\n class=\"dialog__close-txt\"\n onClick={this.requestClose}\n >\n Close\n </button>\n )}\n </footer>\n )}\n </div>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -95,7 +95,6 @@ TODO - as soon as container queries hits everywhere, strip out reliance on nano-
95
95
  }
96
96
  }
97
97
  .hero__ctas ::slotted(a.button[slot=secondary-ctas]) {
98
- padding-block: 0.25rem !important;
99
98
  padding-inline: 0.5rem !important;
100
99
  font-size: 0.875rem !important;
101
100
  margin-block: 0 !important;
@@ -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;AAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","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"]}
@@ -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: contents }"; }
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,CA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,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,IAAI;QAC1D,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,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AC,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: 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": "../option/option-interface"
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<Dropdown>",
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
- "Dropdown": {
1193
+ "DropdownInterface": {
1194
1194
  "location": "import",
1195
- "path": "../dropdown/dropdown"
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": "../option/option-interface"
1218
+ "path": "../../interface"
1219
1219
  }
1220
1220
  }
1221
1221
  },