@alfalab/core-components-select 14.3.4 → 15.0.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 (452) hide show
  1. package/Component.desktop.d.ts +19 -0
  2. package/{Component.js → Component.desktop.js} +6 -6
  3. package/Component.mobile-ebda875c.d.ts +6 -0
  4. package/Component.mobile-f1f15074.d.ts +387 -0
  5. package/Component.mobile.d.ts +41 -0
  6. package/Component.mobile.js +62 -0
  7. package/Component.modal.mobile.d.ts +60 -0
  8. package/Component.modal.mobile.js +62 -0
  9. package/Component.responsive.d.ts +1 -1
  10. package/Component.responsive.js +26 -25
  11. package/components/arrow/Component.d.ts +2 -1
  12. package/components/arrow/Component.js +1 -1
  13. package/components/arrow/index.css +3 -3
  14. package/components/base-checkmark/Component.d.ts +2 -1
  15. package/components/base-checkmark/Component.js +1 -1
  16. package/components/base-checkmark/index.css +4 -4
  17. package/components/base-option/Component.js +1 -1
  18. package/components/base-option/index.css +13 -13
  19. package/components/base-select/Component.js +6 -6
  20. package/components/base-select/index.css +8 -8
  21. package/components/base-select/index.js +1 -1
  22. package/components/base-select-mobile/Component.d.ts +3 -3
  23. package/components/base-select-mobile/Component.js +13 -9
  24. package/components/base-select-mobile/footer/Component.d.ts +2 -1
  25. package/components/base-select-mobile/footer/Component.js +4 -4
  26. package/components/base-select-mobile/footer/index.css +5 -5
  27. package/components/base-select-mobile/footer/index.js +1 -1
  28. package/components/base-select-mobile/index.css +13 -11
  29. package/components/base-select-mobile/index.js +1 -2
  30. package/components/checkmark/Component.d.ts +2 -1
  31. package/components/checkmark/Component.js +1 -1
  32. package/components/checkmark/index.css +10 -10
  33. package/components/checkmark-mobile/Component.d.ts +2 -1
  34. package/components/checkmark-mobile/Component.js +1 -1
  35. package/components/checkmark-mobile/index.css +6 -6
  36. package/components/field/Component.d.ts +9 -1
  37. package/components/field/Component.js +19 -16
  38. package/components/field/index.css +38 -11
  39. package/components/field/index.js +0 -1
  40. package/components/index.d.ts +0 -2
  41. package/components/index.js +4 -19
  42. package/components/optgroup/Component.d.ts +2 -1
  43. package/components/optgroup/Component.js +1 -1
  44. package/components/optgroup/index.css +6 -6
  45. package/components/option/Component.js +1 -1
  46. package/components/option/index.css +20 -20
  47. package/components/options-list/Component.js +1 -1
  48. package/components/options-list/index.css +9 -9
  49. package/components/virtual-options-list/Component.js +1 -1
  50. package/components/virtual-options-list/index.css +15 -15
  51. package/cssm/Component.desktop.d.ts +19 -0
  52. package/cssm/{Component.js → Component.desktop.js} +6 -6
  53. package/cssm/Component.mobile-ebda875c.d.ts +6 -0
  54. package/cssm/Component.mobile-f1f15074.d.ts +387 -0
  55. package/cssm/Component.mobile.d.ts +41 -0
  56. package/cssm/Component.mobile.js +74 -0
  57. package/cssm/Component.modal.mobile.d.ts +60 -0
  58. package/cssm/Component.modal.mobile.js +74 -0
  59. package/cssm/Component.responsive.d.ts +1 -1
  60. package/cssm/Component.responsive.js +30 -33
  61. package/cssm/components/arrow/Component.d.ts +2 -1
  62. package/cssm/components/base-checkmark/Component.d.ts +2 -1
  63. package/cssm/components/base-select/Component.js +5 -5
  64. package/cssm/components/base-select/index.js +1 -1
  65. package/cssm/components/base-select-mobile/Component.d.ts +3 -3
  66. package/cssm/components/base-select-mobile/Component.js +12 -8
  67. package/cssm/components/base-select-mobile/footer/Component.d.ts +2 -1
  68. package/cssm/components/base-select-mobile/footer/Component.js +3 -3
  69. package/cssm/components/base-select-mobile/footer/index.js +1 -1
  70. package/cssm/components/base-select-mobile/index.js +1 -2
  71. package/cssm/components/base-select-mobile/index.module.css +4 -2
  72. package/cssm/components/checkmark/Component.d.ts +2 -1
  73. package/cssm/components/checkmark-mobile/Component.d.ts +2 -1
  74. package/cssm/components/field/Component.d.ts +9 -1
  75. package/cssm/components/field/Component.js +18 -15
  76. package/cssm/components/field/index.js +0 -1
  77. package/cssm/components/field/index.module.css +31 -4
  78. package/cssm/components/index.d.ts +0 -2
  79. package/cssm/components/index.js +7 -28
  80. package/cssm/components/optgroup/Component.d.ts +2 -1
  81. package/cssm/desktop-63dec22f.d.ts +6 -0
  82. package/cssm/desktop.d.ts +2 -0
  83. package/cssm/desktop.js +44 -0
  84. package/cssm/hook-97e6e688.d.ts +16 -0
  85. package/cssm/hook-97e6e688.js +110 -0
  86. package/{esm/hook-b4e70cb0.d.ts → cssm/hook-9ea9e32c.d.ts} +9 -7
  87. package/cssm/index-ebda875c.d.ts +20 -60
  88. package/cssm/index.d.ts +2 -5
  89. package/cssm/index.js +34 -61
  90. package/cssm/mobile-96988a65.d.ts +2 -0
  91. package/cssm/mobile.d.ts +5 -4
  92. package/cssm/mobile.js +15 -24
  93. package/cssm/presets/index.d.ts +1 -1
  94. package/cssm/presets/index.js +8 -36
  95. package/cssm/presets/useLazyLoading/hook.d.ts +1 -1
  96. package/cssm/presets/useLazyLoading/hook.js +900 -4
  97. package/cssm/presets/useSelectWithApply/hook.js +9 -48
  98. package/cssm/presets/useSelectWithApply/options-list-with-apply/Component.js +3 -42
  99. package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +2 -1
  100. package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +3 -3
  101. package/cssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  102. package/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +10 -49
  103. package/cssm/presets/useSelectWithLoading/hook.d.ts +1 -1
  104. package/cssm/shared.d.ts +5 -0
  105. package/cssm/shared.js +77 -0
  106. package/cssm/typings-9211a437.d.ts +95 -0
  107. package/cssm/typings-baf4875b.d.ts +52 -0
  108. package/desktop-63dec22f.d.ts +6 -0
  109. package/desktop.d.ts +2 -0
  110. package/{responsive.js → desktop.js} +5 -19
  111. package/esm/Component.desktop.d.ts +19 -0
  112. package/esm/{Component.js → Component.desktop.js} +6 -6
  113. package/esm/Component.mobile-ebda875c.d.ts +6 -0
  114. package/esm/Component.mobile-f1f15074.d.ts +387 -0
  115. package/esm/Component.mobile.d.ts +41 -0
  116. package/esm/Component.mobile.js +54 -0
  117. package/esm/Component.modal.mobile.d.ts +60 -0
  118. package/esm/Component.modal.mobile.js +54 -0
  119. package/esm/Component.responsive.d.ts +1 -1
  120. package/esm/Component.responsive.js +26 -25
  121. package/esm/components/arrow/Component.d.ts +2 -1
  122. package/esm/components/arrow/Component.js +1 -1
  123. package/esm/components/arrow/index.css +3 -3
  124. package/esm/components/base-checkmark/Component.d.ts +2 -1
  125. package/esm/components/base-checkmark/Component.js +1 -1
  126. package/esm/components/base-checkmark/index.css +4 -4
  127. package/esm/components/base-option/Component.js +1 -1
  128. package/esm/components/base-option/index.css +13 -13
  129. package/esm/components/base-select/Component.js +2 -2
  130. package/esm/components/base-select/index.css +8 -8
  131. package/esm/components/base-select/index.js +1 -1
  132. package/esm/components/base-select-mobile/Component.d.ts +3 -3
  133. package/esm/components/base-select-mobile/Component.js +9 -5
  134. package/esm/components/base-select-mobile/footer/Component.d.ts +2 -1
  135. package/esm/components/base-select-mobile/footer/Component.js +4 -4
  136. package/esm/components/base-select-mobile/footer/index.css +5 -5
  137. package/esm/components/base-select-mobile/footer/index.js +1 -1
  138. package/esm/components/base-select-mobile/index.css +13 -11
  139. package/esm/components/base-select-mobile/index.js +1 -2
  140. package/esm/components/checkmark/Component.d.ts +2 -1
  141. package/esm/components/checkmark/Component.js +1 -1
  142. package/esm/components/checkmark/index.css +10 -10
  143. package/esm/components/checkmark-mobile/Component.d.ts +2 -1
  144. package/esm/components/checkmark-mobile/Component.js +1 -1
  145. package/esm/components/checkmark-mobile/index.css +6 -6
  146. package/esm/components/field/Component.d.ts +9 -1
  147. package/esm/components/field/Component.js +19 -16
  148. package/esm/components/field/index.css +38 -11
  149. package/esm/components/field/index.js +0 -1
  150. package/esm/components/index.d.ts +0 -2
  151. package/esm/components/index.js +4 -17
  152. package/esm/components/optgroup/Component.d.ts +2 -1
  153. package/esm/components/optgroup/Component.js +1 -1
  154. package/esm/components/optgroup/index.css +6 -6
  155. package/esm/components/option/Component.js +1 -1
  156. package/esm/components/option/index.css +20 -20
  157. package/esm/components/options-list/Component.js +1 -1
  158. package/esm/components/options-list/index.css +9 -9
  159. package/esm/components/virtual-options-list/Component.js +1 -1
  160. package/esm/components/virtual-options-list/index.css +15 -15
  161. package/esm/desktop-63dec22f.d.ts +6 -0
  162. package/esm/desktop.d.ts +2 -0
  163. package/esm/{responsive.js → desktop.js} +4 -18
  164. package/esm/hook-326a5cea.d.ts +16 -0
  165. package/esm/hook-326a5cea.js +102 -0
  166. package/{cssm/hook-b4e70cb0.d.ts → esm/hook-9ea9e32c.d.ts} +9 -7
  167. package/esm/index-ebda875c.d.ts +20 -60
  168. package/esm/index.d.ts +2 -5
  169. package/esm/index.js +27 -29
  170. package/esm/mobile-96988a65.d.ts +2 -0
  171. package/esm/mobile.d.ts +5 -4
  172. package/esm/mobile.js +12 -16
  173. package/esm/presets/index.d.ts +1 -1
  174. package/esm/presets/index.js +6 -25
  175. package/esm/presets/useLazyLoading/hook.d.ts +1 -1
  176. package/esm/presets/useLazyLoading/hook.js +899 -4
  177. package/esm/presets/useSelectWithApply/hook.js +7 -33
  178. package/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +2 -28
  179. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +2 -1
  180. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +4 -4
  181. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/index.css +3 -3
  182. package/esm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
  183. package/esm/presets/useSelectWithApply/options-list-with-apply/header/index.css +3 -3
  184. package/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  185. package/esm/presets/useSelectWithApply/options-list-with-apply/index.js +8 -34
  186. package/esm/presets/useSelectWithLoading/hook.d.ts +1 -1
  187. package/esm/presets/useSelectWithLoading/hook.js +1 -1
  188. package/esm/presets/useSelectWithLoading/index.css +2 -2
  189. package/esm/shared.d.ts +5 -0
  190. package/esm/shared.js +37 -0
  191. package/esm/typings-9211a437.d.ts +95 -0
  192. package/esm/typings-baf4875b.d.ts +52 -0
  193. package/hook-6e94be9c.d.ts +16 -0
  194. package/hook-6e94be9c.js +110 -0
  195. package/{hook-b4e70cb0.d.ts → hook-9ea9e32c.d.ts} +9 -7
  196. package/index-ebda875c.d.ts +20 -60
  197. package/index.d.ts +2 -5
  198. package/index.js +28 -51
  199. package/mobile-96988a65.d.ts +2 -0
  200. package/mobile.d.ts +5 -4
  201. package/mobile.js +14 -18
  202. package/modern/Component.desktop.d.ts +19 -0
  203. package/modern/{Component.js → Component.desktop.js} +7 -4
  204. package/modern/Component.mobile-ebda875c.d.ts +6 -0
  205. package/modern/Component.mobile-f1f15074.d.ts +387 -0
  206. package/modern/Component.mobile.d.ts +41 -0
  207. package/modern/Component.mobile.js +61 -0
  208. package/modern/Component.modal.mobile.d.ts +60 -0
  209. package/modern/Component.modal.mobile.js +61 -0
  210. package/modern/Component.responsive.d.ts +1 -1
  211. package/modern/Component.responsive.js +26 -25
  212. package/modern/components/arrow/Component.d.ts +2 -1
  213. package/modern/components/arrow/Component.js +1 -1
  214. package/modern/components/arrow/index.css +3 -3
  215. package/modern/components/base-checkmark/Component.d.ts +2 -1
  216. package/modern/components/base-checkmark/Component.js +1 -1
  217. package/modern/components/base-checkmark/index.css +4 -4
  218. package/modern/components/base-option/Component.js +1 -1
  219. package/modern/components/base-option/index.css +13 -13
  220. package/modern/components/base-select/Component.js +2 -2
  221. package/modern/components/base-select/index.css +8 -8
  222. package/modern/components/base-select/index.js +1 -1
  223. package/modern/components/base-select-mobile/Component.d.ts +3 -3
  224. package/modern/components/base-select-mobile/Component.js +9 -5
  225. package/modern/components/base-select-mobile/footer/Component.d.ts +2 -1
  226. package/modern/components/base-select-mobile/footer/Component.js +4 -4
  227. package/modern/components/base-select-mobile/footer/index.css +5 -5
  228. package/modern/components/base-select-mobile/footer/index.js +1 -1
  229. package/modern/components/base-select-mobile/index.css +13 -11
  230. package/modern/components/base-select-mobile/index.js +1 -2
  231. package/modern/components/checkmark/Component.d.ts +2 -1
  232. package/modern/components/checkmark/Component.js +1 -1
  233. package/modern/components/checkmark/index.css +10 -10
  234. package/modern/components/checkmark-mobile/Component.d.ts +2 -1
  235. package/modern/components/checkmark-mobile/Component.js +1 -1
  236. package/modern/components/checkmark-mobile/index.css +6 -6
  237. package/modern/components/field/Component.d.ts +9 -1
  238. package/modern/components/field/Component.js +17 -14
  239. package/modern/components/field/index.css +38 -11
  240. package/modern/components/field/index.js +0 -1
  241. package/modern/components/index.d.ts +0 -2
  242. package/modern/components/index.js +4 -17
  243. package/modern/components/optgroup/Component.d.ts +2 -1
  244. package/modern/components/optgroup/Component.js +1 -1
  245. package/modern/components/optgroup/index.css +6 -6
  246. package/modern/components/option/Component.js +1 -1
  247. package/modern/components/option/index.css +20 -20
  248. package/modern/components/options-list/Component.js +1 -1
  249. package/modern/components/options-list/index.css +9 -9
  250. package/modern/components/virtual-options-list/Component.js +1 -1
  251. package/modern/components/virtual-options-list/index.css +15 -15
  252. package/modern/desktop-63dec22f.d.ts +6 -0
  253. package/modern/desktop.d.ts +2 -0
  254. package/modern/{responsive.js → desktop.js} +4 -18
  255. package/modern/{hook-b4e70cb0.d.ts → hook-9ea9e32c.d.ts} +9 -7
  256. package/modern/hook-e0fd0350.d.ts +16 -0
  257. package/modern/{Component-ecb2a41a.js → hook-e0fd0350.js} +3 -66
  258. package/modern/index-ebda875c.d.ts +20 -60
  259. package/modern/index.d.ts +2 -5
  260. package/modern/index.js +27 -29
  261. package/modern/mobile-96988a65.d.ts +2 -0
  262. package/modern/mobile.d.ts +5 -4
  263. package/modern/mobile.js +12 -16
  264. package/modern/presets/index.d.ts +1 -1
  265. package/modern/presets/index.js +6 -25
  266. package/modern/presets/useLazyLoading/hook.d.ts +1 -1
  267. package/modern/presets/useLazyLoading/hook.js +899 -4
  268. package/modern/presets/useSelectWithApply/hook.js +7 -33
  269. package/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +2 -28
  270. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +2 -1
  271. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +4 -4
  272. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/index.css +3 -3
  273. package/modern/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
  274. package/modern/presets/useSelectWithApply/options-list-with-apply/header/index.css +3 -3
  275. package/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  276. package/modern/presets/useSelectWithApply/options-list-with-apply/index.js +8 -34
  277. package/modern/presets/useSelectWithLoading/hook.d.ts +1 -1
  278. package/modern/presets/useSelectWithLoading/hook.js +1 -1
  279. package/modern/presets/useSelectWithLoading/index.css +2 -2
  280. package/modern/shared.d.ts +5 -0
  281. package/modern/shared.js +36 -0
  282. package/modern/typings-9211a437.d.ts +95 -0
  283. package/modern/typings-baf4875b.d.ts +52 -0
  284. package/package.json +37 -12
  285. package/presets/index.d.ts +1 -1
  286. package/presets/index.js +6 -25
  287. package/presets/useLazyLoading/hook.d.ts +1 -1
  288. package/presets/useLazyLoading/hook.js +899 -4
  289. package/presets/useSelectWithApply/hook.js +7 -33
  290. package/presets/useSelectWithApply/options-list-with-apply/Component.js +2 -28
  291. package/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +2 -1
  292. package/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +4 -4
  293. package/presets/useSelectWithApply/options-list-with-apply/footer/index.css +3 -3
  294. package/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
  295. package/presets/useSelectWithApply/options-list-with-apply/header/index.css +3 -3
  296. package/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  297. package/presets/useSelectWithApply/options-list-with-apply/index.js +8 -34
  298. package/presets/useSelectWithLoading/hook.d.ts +1 -1
  299. package/presets/useSelectWithLoading/hook.js +1 -1
  300. package/presets/useSelectWithLoading/index.css +2 -2
  301. package/shared.d.ts +5 -0
  302. package/shared.js +63 -0
  303. package/src/Component.desktop.tsx +52 -0
  304. package/src/Component.mobile.tsx +149 -0
  305. package/src/Component.modal.mobile.tsx +144 -0
  306. package/src/Component.responsive.tsx +59 -0
  307. package/src/components/arrow/Component.tsx +12 -0
  308. package/src/components/arrow/index.module.css +15 -0
  309. package/src/components/arrow/index.ts +1 -0
  310. package/src/components/base-checkmark/Component.tsx +33 -0
  311. package/src/components/base-checkmark/index.module.css +18 -0
  312. package/src/components/base-checkmark/index.ts +1 -0
  313. package/src/components/base-option/Component.tsx +57 -0
  314. package/src/components/base-option/index.module.css +67 -0
  315. package/src/components/base-option/index.ts +1 -0
  316. package/src/components/base-select/Component.tsx +478 -0
  317. package/src/components/base-select/index.module.css +68 -0
  318. package/src/components/base-select/index.ts +1 -0
  319. package/src/components/base-select-mobile/Component.tsx +486 -0
  320. package/src/components/base-select-mobile/footer/Component.tsx +46 -0
  321. package/src/components/base-select-mobile/footer/index.module.css +23 -0
  322. package/src/components/base-select-mobile/footer/index.ts +1 -0
  323. package/src/components/base-select-mobile/index.module.css +48 -0
  324. package/src/components/base-select-mobile/index.ts +1 -0
  325. package/src/components/checkmark/Component.tsx +56 -0
  326. package/src/components/checkmark/index.module.css +48 -0
  327. package/src/components/checkmark/index.ts +1 -0
  328. package/src/components/checkmark-mobile/Component.tsx +18 -0
  329. package/src/components/checkmark-mobile/index.module.css +28 -0
  330. package/src/components/checkmark-mobile/index.ts +1 -0
  331. package/src/components/field/Component.tsx +110 -0
  332. package/src/components/field/index.module.css +60 -0
  333. package/src/components/field/index.ts +1 -0
  334. package/src/components/index.ts +8 -0
  335. package/src/components/native-select/Component.tsx +60 -0
  336. package/src/components/native-select/index.ts +1 -0
  337. package/src/components/optgroup/Component.tsx +15 -0
  338. package/src/components/optgroup/index.module.css +30 -0
  339. package/src/components/optgroup/index.ts +1 -0
  340. package/src/components/option/Component.tsx +65 -0
  341. package/src/components/option/index.module.css +108 -0
  342. package/src/components/option/index.ts +1 -0
  343. package/src/components/options-list/Component.tsx +140 -0
  344. package/src/components/options-list/index.module.css +40 -0
  345. package/src/components/options-list/index.ts +1 -0
  346. package/src/components/virtual-options-list/Component.tsx +217 -0
  347. package/src/components/virtual-options-list/index.module.css +76 -0
  348. package/src/components/virtual-options-list/index.ts +1 -0
  349. package/src/consts.ts +1 -0
  350. package/src/desktop.ts +1 -0
  351. package/src/index.ts +4 -0
  352. package/src/mobile.ts +5 -0
  353. package/src/presets/index.ts +3 -0
  354. package/src/presets/useLazyLoading/hook.tsx +309 -0
  355. package/src/presets/useSelectWithApply/hook.tsx +154 -0
  356. package/src/presets/useSelectWithApply/options-list-with-apply/Component.tsx +106 -0
  357. package/src/presets/useSelectWithApply/options-list-with-apply/footer/Component.tsx +37 -0
  358. package/src/presets/useSelectWithApply/options-list-with-apply/footer/index.module.css +11 -0
  359. package/src/presets/useSelectWithApply/options-list-with-apply/header/Component.tsx +26 -0
  360. package/src/presets/useSelectWithApply/options-list-with-apply/header/index.module.css +9 -0
  361. package/src/presets/useSelectWithApply/options-list-with-apply/index.ts +1 -0
  362. package/src/presets/useSelectWithLoading/hook.tsx +40 -0
  363. package/src/shared.ts +5 -0
  364. package/src/typings.ts +691 -0
  365. package/src/utils.ts +154 -0
  366. package/src/vars.css +57 -0
  367. package/typings-9211a437.d.ts +95 -0
  368. package/typings-baf4875b.d.ts +52 -0
  369. package/Component-01f08370.d.ts +0 -108
  370. package/Component-01f08370.js +0 -165
  371. package/Component-3885b0d7.d.ts +0 -169
  372. package/Component.d.ts +0 -104
  373. package/Component.mobile-b2c0420d.d.ts +0 -93
  374. package/components/select-mobile/Component.d.ts +0 -0
  375. package/components/select-mobile/Component.js +0 -49
  376. package/components/select-mobile/index.d.ts +0 -1
  377. package/components/select-mobile/index.js +0 -49
  378. package/components/select-modal-mobile/Component.d.ts +0 -0
  379. package/components/select-modal-mobile/Component.js +0 -49
  380. package/components/select-modal-mobile/index.d.ts +0 -1
  381. package/components/select-modal-mobile/index.js +0 -49
  382. package/cssm/Component-3885b0d7.d.ts +0 -169
  383. package/cssm/Component-4727d474.d.ts +0 -108
  384. package/cssm/Component-4727d474.js +0 -175
  385. package/cssm/Component.d.ts +0 -104
  386. package/cssm/Component.mobile-b2c0420d.d.ts +0 -93
  387. package/cssm/components/select-mobile/Component.d.ts +0 -0
  388. package/cssm/components/select-mobile/Component.js +0 -66
  389. package/cssm/components/select-mobile/index.d.ts +0 -1
  390. package/cssm/components/select-mobile/index.js +0 -66
  391. package/cssm/components/select-modal-mobile/Component.d.ts +0 -0
  392. package/cssm/components/select-modal-mobile/Component.js +0 -66
  393. package/cssm/components/select-modal-mobile/index.d.ts +0 -1
  394. package/cssm/components/select-modal-mobile/index.js +0 -66
  395. package/cssm/getDataTestId-5c876d98.d.ts +0 -2
  396. package/cssm/getDataTestId-5c876d98.js +0 -8
  397. package/cssm/index-3885b0d7.d.ts +0 -3
  398. package/cssm/intersection-observer-9ec5cf59.d.ts +0 -1
  399. package/cssm/intersection-observer-9ec5cf59.js +0 -893
  400. package/cssm/responsive.d.ts +0 -2
  401. package/cssm/responsive.js +0 -67
  402. package/cssm/types-ebda875c.d.ts +0 -113
  403. package/esm/Component-3885b0d7.d.ts +0 -169
  404. package/esm/Component-5e2bc757.d.ts +0 -108
  405. package/esm/Component-5e2bc757.js +0 -155
  406. package/esm/Component.d.ts +0 -104
  407. package/esm/Component.mobile-b2c0420d.d.ts +0 -93
  408. package/esm/components/select-mobile/Component.d.ts +0 -0
  409. package/esm/components/select-mobile/Component.js +0 -41
  410. package/esm/components/select-mobile/index.d.ts +0 -1
  411. package/esm/components/select-mobile/index.js +0 -41
  412. package/esm/components/select-modal-mobile/Component.d.ts +0 -0
  413. package/esm/components/select-modal-mobile/Component.js +0 -41
  414. package/esm/components/select-modal-mobile/index.d.ts +0 -1
  415. package/esm/components/select-modal-mobile/index.js +0 -41
  416. package/esm/getDataTestId-fc7d4653.d.ts +0 -2
  417. package/esm/getDataTestId-fc7d4653.js +0 -6
  418. package/esm/index-3885b0d7.d.ts +0 -3
  419. package/esm/intersection-observer-6768cbd0.d.ts +0 -1
  420. package/esm/intersection-observer-6768cbd0.js +0 -891
  421. package/esm/presets/useLazyLoading/index.css +0 -8
  422. package/esm/responsive.d.ts +0 -2
  423. package/esm/types-ebda875c.d.ts +0 -113
  424. package/getDataTestId-18fbdb35.d.ts +0 -2
  425. package/getDataTestId-18fbdb35.js +0 -8
  426. package/index-3885b0d7.d.ts +0 -3
  427. package/intersection-observer-0413a170.d.ts +0 -1
  428. package/intersection-observer-0413a170.js +0 -893
  429. package/modern/Component-3885b0d7.d.ts +0 -169
  430. package/modern/Component-ecb2a41a.d.ts +0 -108
  431. package/modern/Component.d.ts +0 -104
  432. package/modern/Component.mobile-b2c0420d.d.ts +0 -93
  433. package/modern/components/select-mobile/Component.d.ts +0 -0
  434. package/modern/components/select-mobile/Component.js +0 -40
  435. package/modern/components/select-mobile/index.d.ts +0 -1
  436. package/modern/components/select-mobile/index.js +0 -40
  437. package/modern/components/select-modal-mobile/Component.d.ts +0 -0
  438. package/modern/components/select-modal-mobile/Component.js +0 -40
  439. package/modern/components/select-modal-mobile/index.d.ts +0 -1
  440. package/modern/components/select-modal-mobile/index.js +0 -40
  441. package/modern/getDataTestId-6120c308.d.ts +0 -2
  442. package/modern/getDataTestId-6120c308.js +0 -6
  443. package/modern/index-3885b0d7.d.ts +0 -3
  444. package/modern/intersection-observer-6768cbd0.d.ts +0 -1
  445. package/modern/intersection-observer-6768cbd0.js +0 -891
  446. package/modern/presets/useLazyLoading/index.css +0 -8
  447. package/modern/responsive.d.ts +0 -2
  448. package/modern/types-ebda875c.d.ts +0 -113
  449. package/presets/useLazyLoading/index.css +0 -8
  450. package/responsive.d.ts +0 -2
  451. package/types-ebda875c.d.ts +0 -113
  452. /package/{cssm/presets/useLazyLoading → src/presets/useSelectWithLoading}/index.module.css +0 -0
@@ -1,893 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Copyright 2016 Google Inc. All Rights Reserved.
5
- *
6
- * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.
7
- *
8
- * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
9
- *
10
- */
11
- (function () {
12
- // Exit early if we're not running in a browser.
13
- if (typeof window !== 'object') {
14
- return;
15
- }
16
- // Exit early if all IntersectionObserver and IntersectionObserverEntry
17
- // features are natively supported.
18
- if ('IntersectionObserver' in window &&
19
- 'IntersectionObserverEntry' in window &&
20
- 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
21
- // Minimal polyfill for Edge 15's lack of `isIntersecting`
22
- // See: https://github.com/w3c/IntersectionObserver/issues/211
23
- if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {
24
- Object.defineProperty(window.IntersectionObserverEntry.prototype, 'isIntersecting', {
25
- get: function () {
26
- return this.intersectionRatio > 0;
27
- }
28
- });
29
- }
30
- return;
31
- }
32
- /**
33
- * Returns the embedding frame element, if any.
34
- * @param {!Document} doc
35
- * @return {!Element}
36
- */
37
- function getFrameElement(doc) {
38
- try {
39
- return doc.defaultView && doc.defaultView.frameElement || null;
40
- }
41
- catch (e) {
42
- // Ignore the error.
43
- return null;
44
- }
45
- }
46
- /**
47
- * A local reference to the root document.
48
- */
49
- var document = (function (startDoc) {
50
- var doc = startDoc;
51
- var frame = getFrameElement(doc);
52
- while (frame) {
53
- doc = frame.ownerDocument;
54
- frame = getFrameElement(doc);
55
- }
56
- return doc;
57
- })(window.document);
58
- /**
59
- * An IntersectionObserver registry. This registry exists to hold a strong
60
- * reference to IntersectionObserver instances currently observing a target
61
- * element. Without this registry, instances without another reference may be
62
- * garbage collected.
63
- */
64
- var registry = [];
65
- /**
66
- * The signal updater for cross-origin intersection. When not null, it means
67
- * that the polyfill is configured to work in a cross-origin mode.
68
- * @type {function(DOMRect|ClientRect, DOMRect|ClientRect)}
69
- */
70
- var crossOriginUpdater = null;
71
- /**
72
- * The current cross-origin intersection. Only used in the cross-origin mode.
73
- * @type {DOMRect|ClientRect}
74
- */
75
- var crossOriginRect = null;
76
- /**
77
- * Creates the global IntersectionObserverEntry constructor.
78
- * https://w3c.github.io/IntersectionObserver/#intersection-observer-entry
79
- * @param {Object} entry A dictionary of instance properties.
80
- * @constructor
81
- */
82
- function IntersectionObserverEntry(entry) {
83
- this.time = entry.time;
84
- this.target = entry.target;
85
- this.rootBounds = ensureDOMRect(entry.rootBounds);
86
- this.boundingClientRect = ensureDOMRect(entry.boundingClientRect);
87
- this.intersectionRect = ensureDOMRect(entry.intersectionRect || getEmptyRect());
88
- this.isIntersecting = !!entry.intersectionRect;
89
- // Calculates the intersection ratio.
90
- var targetRect = this.boundingClientRect;
91
- var targetArea = targetRect.width * targetRect.height;
92
- var intersectionRect = this.intersectionRect;
93
- var intersectionArea = intersectionRect.width * intersectionRect.height;
94
- // Sets intersection ratio.
95
- if (targetArea) {
96
- // Round the intersection ratio to avoid floating point math issues:
97
- // https://github.com/w3c/IntersectionObserver/issues/324
98
- this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4));
99
- }
100
- else {
101
- // If area is zero and is intersecting, sets to 1, otherwise to 0
102
- this.intersectionRatio = this.isIntersecting ? 1 : 0;
103
- }
104
- }
105
- /**
106
- * Creates the global IntersectionObserver constructor.
107
- * https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
108
- * @param {Function} callback The function to be invoked after intersection
109
- * changes have queued. The function is not invoked if the queue has
110
- * been emptied by calling the `takeRecords` method.
111
- * @param {Object=} opt_options Optional configuration options.
112
- * @constructor
113
- */
114
- function IntersectionObserver(callback, opt_options) {
115
- var options = opt_options || {};
116
- if (typeof callback != 'function') {
117
- throw new Error('callback must be a function');
118
- }
119
- if (options.root &&
120
- options.root.nodeType != 1 &&
121
- options.root.nodeType != 9) {
122
- throw new Error('root must be a Document or Element');
123
- }
124
- // Binds and throttles `this._checkForIntersections`.
125
- this._checkForIntersections = throttle(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);
126
- // Private properties.
127
- this._callback = callback;
128
- this._observationTargets = [];
129
- this._queuedEntries = [];
130
- this._rootMarginValues = this._parseRootMargin(options.rootMargin);
131
- // Public properties.
132
- this.thresholds = this._initThresholds(options.threshold);
133
- this.root = options.root || null;
134
- this.rootMargin = this._rootMarginValues.map(function (margin) {
135
- return margin.value + margin.unit;
136
- }).join(' ');
137
- /** @private @const {!Array<!Document>} */
138
- this._monitoringDocuments = [];
139
- /** @private @const {!Array<function()>} */
140
- this._monitoringUnsubscribes = [];
141
- }
142
- /**
143
- * The minimum interval within which the document will be checked for
144
- * intersection changes.
145
- */
146
- IntersectionObserver.prototype.THROTTLE_TIMEOUT = 100;
147
- /**
148
- * The frequency in which the polyfill polls for intersection changes.
149
- * this can be updated on a per instance basis and must be set prior to
150
- * calling `observe` on the first target.
151
- */
152
- IntersectionObserver.prototype.POLL_INTERVAL = null;
153
- /**
154
- * Use a mutation observer on the root element
155
- * to detect intersection changes.
156
- */
157
- IntersectionObserver.prototype.USE_MUTATION_OBSERVER = true;
158
- /**
159
- * Sets up the polyfill in the cross-origin mode. The result is the
160
- * updater function that accepts two arguments: `boundingClientRect` and
161
- * `intersectionRect` - just as these fields would be available to the
162
- * parent via `IntersectionObserverEntry`. This function should be called
163
- * each time the iframe receives intersection information from the parent
164
- * window, e.g. via messaging.
165
- * @return {function(DOMRect|ClientRect, DOMRect|ClientRect)}
166
- */
167
- IntersectionObserver._setupCrossOriginUpdater = function () {
168
- if (!crossOriginUpdater) {
169
- /**
170
- * @param {DOMRect|ClientRect} boundingClientRect
171
- * @param {DOMRect|ClientRect} intersectionRect
172
- */
173
- crossOriginUpdater = function (boundingClientRect, intersectionRect) {
174
- if (!boundingClientRect || !intersectionRect) {
175
- crossOriginRect = getEmptyRect();
176
- }
177
- else {
178
- crossOriginRect = convertFromParentRect(boundingClientRect, intersectionRect);
179
- }
180
- registry.forEach(function (observer) {
181
- observer._checkForIntersections();
182
- });
183
- };
184
- }
185
- return crossOriginUpdater;
186
- };
187
- /**
188
- * Resets the cross-origin mode.
189
- */
190
- IntersectionObserver._resetCrossOriginUpdater = function () {
191
- crossOriginUpdater = null;
192
- crossOriginRect = null;
193
- };
194
- /**
195
- * Starts observing a target element for intersection changes based on
196
- * the thresholds values.
197
- * @param {Element} target The DOM element to observe.
198
- */
199
- IntersectionObserver.prototype.observe = function (target) {
200
- var isTargetAlreadyObserved = this._observationTargets.some(function (item) {
201
- return item.element == target;
202
- });
203
- if (isTargetAlreadyObserved) {
204
- return;
205
- }
206
- if (!(target && target.nodeType == 1)) {
207
- throw new Error('target must be an Element');
208
- }
209
- this._registerInstance();
210
- this._observationTargets.push({ element: target, entry: null });
211
- this._monitorIntersections(target.ownerDocument);
212
- this._checkForIntersections();
213
- };
214
- /**
215
- * Stops observing a target element for intersection changes.
216
- * @param {Element} target The DOM element to observe.
217
- */
218
- IntersectionObserver.prototype.unobserve = function (target) {
219
- this._observationTargets =
220
- this._observationTargets.filter(function (item) {
221
- return item.element != target;
222
- });
223
- this._unmonitorIntersections(target.ownerDocument);
224
- if (this._observationTargets.length == 0) {
225
- this._unregisterInstance();
226
- }
227
- };
228
- /**
229
- * Stops observing all target elements for intersection changes.
230
- */
231
- IntersectionObserver.prototype.disconnect = function () {
232
- this._observationTargets = [];
233
- this._unmonitorAllIntersections();
234
- this._unregisterInstance();
235
- };
236
- /**
237
- * Returns any queue entries that have not yet been reported to the
238
- * callback and clears the queue. This can be used in conjunction with the
239
- * callback to obtain the absolute most up-to-date intersection information.
240
- * @return {Array} The currently queued entries.
241
- */
242
- IntersectionObserver.prototype.takeRecords = function () {
243
- var records = this._queuedEntries.slice();
244
- this._queuedEntries = [];
245
- return records;
246
- };
247
- /**
248
- * Accepts the threshold value from the user configuration object and
249
- * returns a sorted array of unique threshold values. If a value is not
250
- * between 0 and 1 and error is thrown.
251
- * @private
252
- * @param {Array|number=} opt_threshold An optional threshold value or
253
- * a list of threshold values, defaulting to [0].
254
- * @return {Array} A sorted list of unique and valid threshold values.
255
- */
256
- IntersectionObserver.prototype._initThresholds = function (opt_threshold) {
257
- var threshold = opt_threshold || [0];
258
- if (!Array.isArray(threshold))
259
- threshold = [threshold];
260
- return threshold.sort().filter(function (t, i, a) {
261
- if (typeof t != 'number' || isNaN(t) || t < 0 || t > 1) {
262
- throw new Error('threshold must be a number between 0 and 1 inclusively');
263
- }
264
- return t !== a[i - 1];
265
- });
266
- };
267
- /**
268
- * Accepts the rootMargin value from the user configuration object
269
- * and returns an array of the four margin values as an object containing
270
- * the value and unit properties. If any of the values are not properly
271
- * formatted or use a unit other than px or %, and error is thrown.
272
- * @private
273
- * @param {string=} opt_rootMargin An optional rootMargin value,
274
- * defaulting to '0px'.
275
- * @return {Array<Object>} An array of margin objects with the keys
276
- * value and unit.
277
- */
278
- IntersectionObserver.prototype._parseRootMargin = function (opt_rootMargin) {
279
- var marginString = opt_rootMargin || '0px';
280
- var margins = marginString.split(/\s+/).map(function (margin) {
281
- var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
282
- if (!parts) {
283
- throw new Error('rootMargin must be specified in pixels or percent');
284
- }
285
- return { value: parseFloat(parts[1]), unit: parts[2] };
286
- });
287
- // Handles shorthand.
288
- margins[1] = margins[1] || margins[0];
289
- margins[2] = margins[2] || margins[0];
290
- margins[3] = margins[3] || margins[1];
291
- return margins;
292
- };
293
- /**
294
- * Starts polling for intersection changes if the polling is not already
295
- * happening, and if the page's visibility state is visible.
296
- * @param {!Document} doc
297
- * @private
298
- */
299
- IntersectionObserver.prototype._monitorIntersections = function (doc) {
300
- var win = doc.defaultView;
301
- if (!win) {
302
- // Already destroyed.
303
- return;
304
- }
305
- if (this._monitoringDocuments.indexOf(doc) != -1) {
306
- // Already monitoring.
307
- return;
308
- }
309
- // Private state for monitoring.
310
- var callback = this._checkForIntersections;
311
- var monitoringInterval = null;
312
- var domObserver = null;
313
- // If a poll interval is set, use polling instead of listening to
314
- // resize and scroll events or DOM mutations.
315
- if (this.POLL_INTERVAL) {
316
- monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL);
317
- }
318
- else {
319
- addEvent(win, 'resize', callback, true);
320
- addEvent(doc, 'scroll', callback, true);
321
- if (this.USE_MUTATION_OBSERVER && 'MutationObserver' in win) {
322
- domObserver = new win.MutationObserver(callback);
323
- domObserver.observe(doc, {
324
- attributes: true,
325
- childList: true,
326
- characterData: true,
327
- subtree: true
328
- });
329
- }
330
- }
331
- this._monitoringDocuments.push(doc);
332
- this._monitoringUnsubscribes.push(function () {
333
- // Get the window object again. When a friendly iframe is destroyed, it
334
- // will be null.
335
- var win = doc.defaultView;
336
- if (win) {
337
- if (monitoringInterval) {
338
- win.clearInterval(monitoringInterval);
339
- }
340
- removeEvent(win, 'resize', callback, true);
341
- }
342
- removeEvent(doc, 'scroll', callback, true);
343
- if (domObserver) {
344
- domObserver.disconnect();
345
- }
346
- });
347
- // Also monitor the parent.
348
- var rootDoc = (this.root && (this.root.ownerDocument || this.root)) || document;
349
- if (doc != rootDoc) {
350
- var frame = getFrameElement(doc);
351
- if (frame) {
352
- this._monitorIntersections(frame.ownerDocument);
353
- }
354
- }
355
- };
356
- /**
357
- * Stops polling for intersection changes.
358
- * @param {!Document} doc
359
- * @private
360
- */
361
- IntersectionObserver.prototype._unmonitorIntersections = function (doc) {
362
- var index = this._monitoringDocuments.indexOf(doc);
363
- if (index == -1) {
364
- return;
365
- }
366
- var rootDoc = (this.root && (this.root.ownerDocument || this.root)) || document;
367
- // Check if any dependent targets are still remaining.
368
- var hasDependentTargets = this._observationTargets.some(function (item) {
369
- var itemDoc = item.element.ownerDocument;
370
- // Target is in this context.
371
- if (itemDoc == doc) {
372
- return true;
373
- }
374
- // Target is nested in this context.
375
- while (itemDoc && itemDoc != rootDoc) {
376
- var frame = getFrameElement(itemDoc);
377
- itemDoc = frame && frame.ownerDocument;
378
- if (itemDoc == doc) {
379
- return true;
380
- }
381
- }
382
- return false;
383
- });
384
- if (hasDependentTargets) {
385
- return;
386
- }
387
- // Unsubscribe.
388
- var unsubscribe = this._monitoringUnsubscribes[index];
389
- this._monitoringDocuments.splice(index, 1);
390
- this._monitoringUnsubscribes.splice(index, 1);
391
- unsubscribe();
392
- // Also unmonitor the parent.
393
- if (doc != rootDoc) {
394
- var frame = getFrameElement(doc);
395
- if (frame) {
396
- this._unmonitorIntersections(frame.ownerDocument);
397
- }
398
- }
399
- };
400
- /**
401
- * Stops polling for intersection changes.
402
- * @param {!Document} doc
403
- * @private
404
- */
405
- IntersectionObserver.prototype._unmonitorAllIntersections = function () {
406
- var unsubscribes = this._monitoringUnsubscribes.slice(0);
407
- this._monitoringDocuments.length = 0;
408
- this._monitoringUnsubscribes.length = 0;
409
- for (var i = 0; i < unsubscribes.length; i++) {
410
- unsubscribes[i]();
411
- }
412
- };
413
- /**
414
- * Scans each observation target for intersection changes and adds them
415
- * to the internal entries queue. If new entries are found, it
416
- * schedules the callback to be invoked.
417
- * @private
418
- */
419
- IntersectionObserver.prototype._checkForIntersections = function () {
420
- if (!this.root && crossOriginUpdater && !crossOriginRect) {
421
- // Cross origin monitoring, but no initial data available yet.
422
- return;
423
- }
424
- var rootIsInDom = this._rootIsInDom();
425
- var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
426
- this._observationTargets.forEach(function (item) {
427
- var target = item.element;
428
- var targetRect = getBoundingClientRect(target);
429
- var rootContainsTarget = this._rootContainsTarget(target);
430
- var oldEntry = item.entry;
431
- var intersectionRect = rootIsInDom && rootContainsTarget &&
432
- this._computeTargetAndRootIntersection(target, targetRect, rootRect);
433
- var rootBounds = null;
434
- if (!this._rootContainsTarget(target)) {
435
- rootBounds = getEmptyRect();
436
- }
437
- else if (!crossOriginUpdater || this.root) {
438
- rootBounds = rootRect;
439
- }
440
- var newEntry = item.entry = new IntersectionObserverEntry({
441
- time: now(),
442
- target: target,
443
- boundingClientRect: targetRect,
444
- rootBounds: rootBounds,
445
- intersectionRect: intersectionRect
446
- });
447
- if (!oldEntry) {
448
- this._queuedEntries.push(newEntry);
449
- }
450
- else if (rootIsInDom && rootContainsTarget) {
451
- // If the new entry intersection ratio has crossed any of the
452
- // thresholds, add a new entry.
453
- if (this._hasCrossedThreshold(oldEntry, newEntry)) {
454
- this._queuedEntries.push(newEntry);
455
- }
456
- }
457
- else {
458
- // If the root is not in the DOM or target is not contained within
459
- // root but the previous entry for this target had an intersection,
460
- // add a new record indicating removal.
461
- if (oldEntry && oldEntry.isIntersecting) {
462
- this._queuedEntries.push(newEntry);
463
- }
464
- }
465
- }, this);
466
- if (this._queuedEntries.length) {
467
- this._callback(this.takeRecords(), this);
468
- }
469
- };
470
- /**
471
- * Accepts a target and root rect computes the intersection between then
472
- * following the algorithm in the spec.
473
- * TODO(philipwalton): at this time clip-path is not considered.
474
- * https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo
475
- * @param {Element} target The target DOM element
476
- * @param {Object} targetRect The bounding rect of the target.
477
- * @param {Object} rootRect The bounding rect of the root after being
478
- * expanded by the rootMargin value.
479
- * @return {?Object} The final intersection rect object or undefined if no
480
- * intersection is found.
481
- * @private
482
- */
483
- IntersectionObserver.prototype._computeTargetAndRootIntersection =
484
- function (target, targetRect, rootRect) {
485
- // If the element isn't displayed, an intersection can't happen.
486
- if (window.getComputedStyle(target).display == 'none')
487
- return;
488
- var intersectionRect = targetRect;
489
- var parent = getParentNode(target);
490
- var atRoot = false;
491
- while (!atRoot && parent) {
492
- var parentRect = null;
493
- var parentComputedStyle = parent.nodeType == 1 ?
494
- window.getComputedStyle(parent) : {};
495
- // If the parent isn't displayed, an intersection can't happen.
496
- if (parentComputedStyle.display == 'none')
497
- return null;
498
- if (parent == this.root || parent.nodeType == /* DOCUMENT */ 9) {
499
- atRoot = true;
500
- if (parent == this.root || parent == document) {
501
- if (crossOriginUpdater && !this.root) {
502
- if (!crossOriginRect ||
503
- crossOriginRect.width == 0 && crossOriginRect.height == 0) {
504
- // A 0-size cross-origin intersection means no-intersection.
505
- parent = null;
506
- parentRect = null;
507
- intersectionRect = null;
508
- }
509
- else {
510
- parentRect = crossOriginRect;
511
- }
512
- }
513
- else {
514
- parentRect = rootRect;
515
- }
516
- }
517
- else {
518
- // Check if there's a frame that can be navigated to.
519
- var frame = getParentNode(parent);
520
- var frameRect = frame && getBoundingClientRect(frame);
521
- var frameIntersect = frame &&
522
- this._computeTargetAndRootIntersection(frame, frameRect, rootRect);
523
- if (frameRect && frameIntersect) {
524
- parent = frame;
525
- parentRect = convertFromParentRect(frameRect, frameIntersect);
526
- }
527
- else {
528
- parent = null;
529
- intersectionRect = null;
530
- }
531
- }
532
- }
533
- else {
534
- // If the element has a non-visible overflow, and it's not the <body>
535
- // or <html> element, update the intersection rect.
536
- // Note: <body> and <html> cannot be clipped to a rect that's not also
537
- // the document rect, so no need to compute a new intersection.
538
- var doc = parent.ownerDocument;
539
- if (parent != doc.body &&
540
- parent != doc.documentElement &&
541
- parentComputedStyle.overflow != 'visible') {
542
- parentRect = getBoundingClientRect(parent);
543
- }
544
- }
545
- // If either of the above conditionals set a new parentRect,
546
- // calculate new intersection data.
547
- if (parentRect) {
548
- intersectionRect = computeRectIntersection(parentRect, intersectionRect);
549
- }
550
- if (!intersectionRect)
551
- break;
552
- parent = parent && getParentNode(parent);
553
- }
554
- return intersectionRect;
555
- };
556
- /**
557
- * Returns the root rect after being expanded by the rootMargin value.
558
- * @return {ClientRect} The expanded root rect.
559
- * @private
560
- */
561
- IntersectionObserver.prototype._getRootRect = function () {
562
- var rootRect;
563
- if (this.root && !isDoc(this.root)) {
564
- rootRect = getBoundingClientRect(this.root);
565
- }
566
- else {
567
- // Use <html>/<body> instead of window since scroll bars affect size.
568
- var doc = isDoc(this.root) ? this.root : document;
569
- var html = doc.documentElement;
570
- var body = doc.body;
571
- rootRect = {
572
- top: 0,
573
- left: 0,
574
- right: html.clientWidth || body.clientWidth,
575
- width: html.clientWidth || body.clientWidth,
576
- bottom: html.clientHeight || body.clientHeight,
577
- height: html.clientHeight || body.clientHeight
578
- };
579
- }
580
- return this._expandRectByRootMargin(rootRect);
581
- };
582
- /**
583
- * Accepts a rect and expands it by the rootMargin value.
584
- * @param {DOMRect|ClientRect} rect The rect object to expand.
585
- * @return {ClientRect} The expanded rect.
586
- * @private
587
- */
588
- IntersectionObserver.prototype._expandRectByRootMargin = function (rect) {
589
- var margins = this._rootMarginValues.map(function (margin, i) {
590
- return margin.unit == 'px' ? margin.value :
591
- margin.value * (i % 2 ? rect.width : rect.height) / 100;
592
- });
593
- var newRect = {
594
- top: rect.top - margins[0],
595
- right: rect.right + margins[1],
596
- bottom: rect.bottom + margins[2],
597
- left: rect.left - margins[3]
598
- };
599
- newRect.width = newRect.right - newRect.left;
600
- newRect.height = newRect.bottom - newRect.top;
601
- return newRect;
602
- };
603
- /**
604
- * Accepts an old and new entry and returns true if at least one of the
605
- * threshold values has been crossed.
606
- * @param {?IntersectionObserverEntry} oldEntry The previous entry for a
607
- * particular target element or null if no previous entry exists.
608
- * @param {IntersectionObserverEntry} newEntry The current entry for a
609
- * particular target element.
610
- * @return {boolean} Returns true if a any threshold has been crossed.
611
- * @private
612
- */
613
- IntersectionObserver.prototype._hasCrossedThreshold =
614
- function (oldEntry, newEntry) {
615
- // To make comparing easier, an entry that has a ratio of 0
616
- // but does not actually intersect is given a value of -1
617
- var oldRatio = oldEntry && oldEntry.isIntersecting ?
618
- oldEntry.intersectionRatio || 0 : -1;
619
- var newRatio = newEntry.isIntersecting ?
620
- newEntry.intersectionRatio || 0 : -1;
621
- // Ignore unchanged ratios
622
- if (oldRatio === newRatio)
623
- return;
624
- for (var i = 0; i < this.thresholds.length; i++) {
625
- var threshold = this.thresholds[i];
626
- // Return true if an entry matches a threshold or if the new ratio
627
- // and the old ratio are on the opposite sides of a threshold.
628
- if (threshold == oldRatio || threshold == newRatio ||
629
- threshold < oldRatio !== threshold < newRatio) {
630
- return true;
631
- }
632
- }
633
- };
634
- /**
635
- * Returns whether or not the root element is an element and is in the DOM.
636
- * @return {boolean} True if the root element is an element and is in the DOM.
637
- * @private
638
- */
639
- IntersectionObserver.prototype._rootIsInDom = function () {
640
- return !this.root || containsDeep(document, this.root);
641
- };
642
- /**
643
- * Returns whether or not the target element is a child of root.
644
- * @param {Element} target The target element to check.
645
- * @return {boolean} True if the target element is a child of root.
646
- * @private
647
- */
648
- IntersectionObserver.prototype._rootContainsTarget = function (target) {
649
- var rootDoc = (this.root && (this.root.ownerDocument || this.root)) || document;
650
- return (containsDeep(rootDoc, target) &&
651
- (!this.root || rootDoc == target.ownerDocument));
652
- };
653
- /**
654
- * Adds the instance to the global IntersectionObserver registry if it isn't
655
- * already present.
656
- * @private
657
- */
658
- IntersectionObserver.prototype._registerInstance = function () {
659
- if (registry.indexOf(this) < 0) {
660
- registry.push(this);
661
- }
662
- };
663
- /**
664
- * Removes the instance from the global IntersectionObserver registry.
665
- * @private
666
- */
667
- IntersectionObserver.prototype._unregisterInstance = function () {
668
- var index = registry.indexOf(this);
669
- if (index != -1)
670
- registry.splice(index, 1);
671
- };
672
- /**
673
- * Returns the result of the performance.now() method or null in browsers
674
- * that don't support the API.
675
- * @return {number} The elapsed time since the page was requested.
676
- */
677
- function now() {
678
- return window.performance && performance.now && performance.now();
679
- }
680
- /**
681
- * Throttles a function and delays its execution, so it's only called at most
682
- * once within a given time period.
683
- * @param {Function} fn The function to throttle.
684
- * @param {number} timeout The amount of time that must pass before the
685
- * function can be called again.
686
- * @return {Function} The throttled function.
687
- */
688
- function throttle(fn, timeout) {
689
- var timer = null;
690
- return function () {
691
- if (!timer) {
692
- timer = setTimeout(function () {
693
- fn();
694
- timer = null;
695
- }, timeout);
696
- }
697
- };
698
- }
699
- /**
700
- * Adds an event handler to a DOM node ensuring cross-browser compatibility.
701
- * @param {Node} node The DOM node to add the event handler to.
702
- * @param {string} event The event name.
703
- * @param {Function} fn The event handler to add.
704
- * @param {boolean} opt_useCapture Optionally adds the even to the capture
705
- * phase. Note: this only works in modern browsers.
706
- */
707
- function addEvent(node, event, fn, opt_useCapture) {
708
- if (typeof node.addEventListener == 'function') {
709
- node.addEventListener(event, fn, opt_useCapture || false);
710
- }
711
- else if (typeof node.attachEvent == 'function') {
712
- node.attachEvent('on' + event, fn);
713
- }
714
- }
715
- /**
716
- * Removes a previously added event handler from a DOM node.
717
- * @param {Node} node The DOM node to remove the event handler from.
718
- * @param {string} event The event name.
719
- * @param {Function} fn The event handler to remove.
720
- * @param {boolean} opt_useCapture If the event handler was added with this
721
- * flag set to true, it should be set to true here in order to remove it.
722
- */
723
- function removeEvent(node, event, fn, opt_useCapture) {
724
- if (typeof node.removeEventListener == 'function') {
725
- node.removeEventListener(event, fn, opt_useCapture || false);
726
- }
727
- else if (typeof node.detatchEvent == 'function') {
728
- node.detatchEvent('on' + event, fn);
729
- }
730
- }
731
- /**
732
- * Returns the intersection between two rect objects.
733
- * @param {Object} rect1 The first rect.
734
- * @param {Object} rect2 The second rect.
735
- * @return {?Object|?ClientRect} The intersection rect or undefined if no
736
- * intersection is found.
737
- */
738
- function computeRectIntersection(rect1, rect2) {
739
- var top = Math.max(rect1.top, rect2.top);
740
- var bottom = Math.min(rect1.bottom, rect2.bottom);
741
- var left = Math.max(rect1.left, rect2.left);
742
- var right = Math.min(rect1.right, rect2.right);
743
- var width = right - left;
744
- var height = bottom - top;
745
- return (width >= 0 && height >= 0) && {
746
- top: top,
747
- bottom: bottom,
748
- left: left,
749
- right: right,
750
- width: width,
751
- height: height
752
- } || null;
753
- }
754
- /**
755
- * Shims the native getBoundingClientRect for compatibility with older IE.
756
- * @param {Element} el The element whose bounding rect to get.
757
- * @return {DOMRect|ClientRect} The (possibly shimmed) rect of the element.
758
- */
759
- function getBoundingClientRect(el) {
760
- var rect;
761
- try {
762
- rect = el.getBoundingClientRect();
763
- }
764
- catch (err) {
765
- // Ignore Windows 7 IE11 "Unspecified error"
766
- // https://github.com/w3c/IntersectionObserver/pull/205
767
- }
768
- if (!rect)
769
- return getEmptyRect();
770
- // Older IE
771
- if (!(rect.width && rect.height)) {
772
- rect = {
773
- top: rect.top,
774
- right: rect.right,
775
- bottom: rect.bottom,
776
- left: rect.left,
777
- width: rect.right - rect.left,
778
- height: rect.bottom - rect.top
779
- };
780
- }
781
- return rect;
782
- }
783
- /**
784
- * Returns an empty rect object. An empty rect is returned when an element
785
- * is not in the DOM.
786
- * @return {ClientRect} The empty rect.
787
- */
788
- function getEmptyRect() {
789
- return {
790
- top: 0,
791
- bottom: 0,
792
- left: 0,
793
- right: 0,
794
- width: 0,
795
- height: 0
796
- };
797
- }
798
- /**
799
- * Ensure that the result has all of the necessary fields of the DOMRect.
800
- * Specifically this ensures that `x` and `y` fields are set.
801
- *
802
- * @param {?DOMRect|?ClientRect} rect
803
- * @return {?DOMRect}
804
- */
805
- function ensureDOMRect(rect) {
806
- // A `DOMRect` object has `x` and `y` fields.
807
- if (!rect || 'x' in rect) {
808
- return rect;
809
- }
810
- // A IE's `ClientRect` type does not have `x` and `y`. The same is the case
811
- // for internally calculated Rect objects. For the purposes of
812
- // `IntersectionObserver`, it's sufficient to simply mirror `left` and `top`
813
- // for these fields.
814
- return {
815
- top: rect.top,
816
- y: rect.top,
817
- bottom: rect.bottom,
818
- left: rect.left,
819
- x: rect.left,
820
- right: rect.right,
821
- width: rect.width,
822
- height: rect.height
823
- };
824
- }
825
- /**
826
- * Inverts the intersection and bounding rect from the parent (frame) BCR to
827
- * the local BCR space.
828
- * @param {DOMRect|ClientRect} parentBoundingRect The parent's bound client rect.
829
- * @param {DOMRect|ClientRect} parentIntersectionRect The parent's own intersection rect.
830
- * @return {ClientRect} The local root bounding rect for the parent's children.
831
- */
832
- function convertFromParentRect(parentBoundingRect, parentIntersectionRect) {
833
- var top = parentIntersectionRect.top - parentBoundingRect.top;
834
- var left = parentIntersectionRect.left - parentBoundingRect.left;
835
- return {
836
- top: top,
837
- left: left,
838
- height: parentIntersectionRect.height,
839
- width: parentIntersectionRect.width,
840
- bottom: top + parentIntersectionRect.height,
841
- right: left + parentIntersectionRect.width
842
- };
843
- }
844
- /**
845
- * Checks to see if a parent element contains a child element (including inside
846
- * shadow DOM).
847
- * @param {Node} parent The parent element.
848
- * @param {Node} child The child element.
849
- * @return {boolean} True if the parent node contains the child node.
850
- */
851
- function containsDeep(parent, child) {
852
- var node = child;
853
- while (node) {
854
- if (node == parent)
855
- return true;
856
- node = getParentNode(node);
857
- }
858
- return false;
859
- }
860
- /**
861
- * Gets the parent node of an element or its host element if the parent node
862
- * is a shadow root.
863
- * @param {Node} node The node whose parent to get.
864
- * @return {Node|null} The parent node or null if no parent exists.
865
- */
866
- function getParentNode(node) {
867
- var parent = node.parentNode;
868
- if (node.nodeType == /* DOCUMENT */ 9 && node != document) {
869
- // If this node is a document node, look for the embedding frame.
870
- return getFrameElement(node);
871
- }
872
- // If the parent has element that is assigned through shadow root slot
873
- if (parent && parent.assignedSlot) {
874
- parent = parent.assignedSlot.parentNode;
875
- }
876
- if (parent && parent.nodeType == 11 && parent.host) {
877
- // If the parent is a shadow root, return the host element.
878
- return parent.host;
879
- }
880
- return parent;
881
- }
882
- /**
883
- * Returns true if `node` is a Document.
884
- * @param {!Node} node
885
- * @returns {boolean}
886
- */
887
- function isDoc(node) {
888
- return node && node.nodeType === 9;
889
- }
890
- // Exposes the constructors globally.
891
- window.IntersectionObserver = IntersectionObserver;
892
- window.IntersectionObserverEntry = IntersectionObserverEntry;
893
- }());