material 3.5.2 → 3.5.4

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 (464) hide show
  1. package/dist/components/badge/api.js +156 -156
  2. package/dist/components/badge/badge.js +9 -9
  3. package/dist/components/badge/config.js +43 -43
  4. package/dist/components/badge/constants.js +13 -13
  5. package/dist/components/badge/features.js +75 -75
  6. package/dist/components/bottom-app-bar/bottom-app-bar.js +98 -98
  7. package/dist/components/bottom-app-bar/config.js +5 -5
  8. package/dist/components/bottom-app-bar/constants.js +8 -8
  9. package/dist/components/bottom-sheet/api.js +52 -52
  10. package/dist/components/bottom-sheet/bottom-sheet.js +9 -9
  11. package/dist/components/bottom-sheet/config.js +17 -17
  12. package/dist/components/bottom-sheet/constants.js +24 -24
  13. package/dist/components/bottom-sheet/features/drag.js +91 -91
  14. package/dist/components/bottom-sheet/features/state.js +148 -148
  15. package/dist/components/bottom-sheet/features/structure.js +85 -85
  16. package/dist/components/button/api.js +265 -265
  17. package/dist/components/button/button.js +15 -15
  18. package/dist/components/button/config.js +39 -39
  19. package/dist/components/button/constants.js +21 -21
  20. package/dist/components/button/features/progress.js +167 -167
  21. package/dist/components/button/features/toggle.js +31 -31
  22. package/dist/components/button-group/button-group.js +389 -389
  23. package/dist/components/button-group/config.js +106 -106
  24. package/dist/components/button-group/constants.js +62 -62
  25. package/dist/components/card/api.js +88 -88
  26. package/dist/components/card/card.js +11 -11
  27. package/dist/components/card/config.js +131 -131
  28. package/dist/components/card/constants.js +39 -39
  29. package/dist/components/card/content.js +175 -175
  30. package/dist/components/carousel/api.js +49 -49
  31. package/dist/components/carousel/arrangement.js +51 -51
  32. package/dist/components/carousel/carousel.js +2 -2
  33. package/dist/components/carousel/config.js +31 -31
  34. package/dist/components/carousel/constants.js +17 -17
  35. package/dist/components/carousel/features/scroll.js +469 -469
  36. package/dist/components/carousel/features/slides.js +125 -125
  37. package/dist/components/carousel/keylines.js +244 -244
  38. package/dist/components/carousel/strategy.js +185 -185
  39. package/dist/components/checkbox/api.js +87 -87
  40. package/dist/components/checkbox/checkbox.js +55 -55
  41. package/dist/components/checkbox/config.js +44 -44
  42. package/dist/components/checkbox/constants.js +10 -10
  43. package/dist/components/chips/api.js +157 -157
  44. package/dist/components/chips/chip/chip.js +275 -275
  45. package/dist/components/chips/chips.js +25 -25
  46. package/dist/components/chips/config.js +73 -73
  47. package/dist/components/chips/constants.js +2 -2
  48. package/dist/components/chips/features/chip-items.js +15 -15
  49. package/dist/components/chips/features/container.js +39 -39
  50. package/dist/components/chips/features/controller.js +317 -317
  51. package/dist/components/chips/features/dom.js +52 -52
  52. package/dist/components/datepicker/api.js +6 -6
  53. package/dist/components/datepicker/config.js +3 -3
  54. package/dist/components/datepicker/constants.js +39 -39
  55. package/dist/components/datepicker/datepicker.js +675 -675
  56. package/dist/components/datepicker/render.js +153 -153
  57. package/dist/components/datepicker/types.js +6 -6
  58. package/dist/components/datepicker/utils.js +157 -157
  59. package/dist/components/dialog/api.js +109 -109
  60. package/dist/components/dialog/config.js +29 -29
  61. package/dist/components/dialog/constants.js +35 -35
  62. package/dist/components/dialog/dialog.js +16 -16
  63. package/dist/components/dialog/features.js +739 -739
  64. package/dist/components/divider/config.js +4 -4
  65. package/dist/components/divider/constants.js +10 -10
  66. package/dist/components/divider/divider.js +6 -6
  67. package/dist/components/divider/features.js +72 -72
  68. package/dist/components/drawer/api.js +73 -73
  69. package/dist/components/drawer/config.js +61 -61
  70. package/dist/components/drawer/constants.js +32 -32
  71. package/dist/components/drawer/drawer.js +38 -38
  72. package/dist/components/drawer/features/headline.js +34 -34
  73. package/dist/components/drawer/features/items.js +203 -203
  74. package/dist/components/drawer/features/state.js +206 -206
  75. package/dist/components/extended-fab/api.js +92 -92
  76. package/dist/components/extended-fab/config.js +65 -65
  77. package/dist/components/extended-fab/constants.js +30 -30
  78. package/dist/components/extended-fab/extended-fab.js +51 -51
  79. package/dist/components/fab/api.js +65 -65
  80. package/dist/components/fab/config.js +46 -46
  81. package/dist/components/fab/constants.js +25 -25
  82. package/dist/components/fab/fab.js +9 -9
  83. package/dist/components/fab-menu/config.js +9 -9
  84. package/dist/components/fab-menu/constants.js +15 -15
  85. package/dist/components/fab-menu/fab-menu.js +310 -310
  86. package/dist/components/fab-menu/stagger.js +18 -18
  87. package/dist/components/icon-button/api.js +195 -195
  88. package/dist/components/icon-button/config.js +79 -79
  89. package/dist/components/icon-button/constants.js +43 -43
  90. package/dist/components/icon-button/features/toggle.js +116 -116
  91. package/dist/components/icon-button/icon-button.js +15 -15
  92. package/dist/components/list/api.js +55 -55
  93. package/dist/components/list/config.js +56 -56
  94. package/dist/components/list/constants.js +25 -25
  95. package/dist/components/list/features/anatomy.js +41 -41
  96. package/dist/components/list/features/renderer.js +136 -136
  97. package/dist/components/list/features/selection.js +118 -118
  98. package/dist/components/list/list.js +9 -9
  99. package/dist/components/loading-indicator/api.js +117 -117
  100. package/dist/components/loading-indicator/config.js +13 -13
  101. package/dist/components/loading-indicator/constants.js +23 -23
  102. package/dist/components/loading-indicator/features/motion.js +33 -33
  103. package/dist/components/loading-indicator/features/renderer.js +121 -121
  104. package/dist/components/loading-indicator/loading-indicator.js +8 -8
  105. package/dist/components/menu/api.js +76 -76
  106. package/dist/components/menu/config.js +73 -73
  107. package/dist/components/menu/constants.js +45 -45
  108. package/dist/components/menu/features/controller.js +507 -507
  109. package/dist/components/menu/features/keyboard.js +292 -292
  110. package/dist/components/menu/features/layer.js +13 -13
  111. package/dist/components/menu/features/loader.js +61 -61
  112. package/dist/components/menu/features/opener.js +288 -288
  113. package/dist/components/menu/features/position.js +279 -279
  114. package/dist/components/menu/features/registry.js +7 -7
  115. package/dist/components/menu/features/submenu.js +386 -386
  116. package/dist/components/menu/features/tasks.js +45 -45
  117. package/dist/components/menu/menu.js +16 -16
  118. package/dist/components/menu/on-demand.js +138 -138
  119. package/dist/components/navigation-bar/navigation-bar.js +144 -144
  120. package/dist/components/navigation-rail/config.js +11 -11
  121. package/dist/components/navigation-rail/constants.js +8 -8
  122. package/dist/components/navigation-rail/navigation-rail.js +237 -237
  123. package/dist/components/progress/api.js +207 -207
  124. package/dist/components/progress/config.js +137 -137
  125. package/dist/components/progress/constants.js +88 -88
  126. package/dist/components/progress/features/canvas.js +291 -291
  127. package/dist/components/progress/features/circular.js +69 -69
  128. package/dist/components/progress/features/colors.js +41 -41
  129. package/dist/components/progress/features/linear.js +96 -96
  130. package/dist/components/progress/features/motion.js +87 -87
  131. package/dist/components/progress/features/state.js +35 -35
  132. package/dist/components/progress/progress.js +11 -11
  133. package/dist/components/radios/api.js +54 -54
  134. package/dist/components/radios/config.js +19 -19
  135. package/dist/components/radios/constants.js +10 -10
  136. package/dist/components/radios/radio.js +161 -161
  137. package/dist/components/radios/radios.js +12 -12
  138. package/dist/components/search/api.js +116 -116
  139. package/dist/components/search/config.js +66 -66
  140. package/dist/components/search/constants.js +75 -75
  141. package/dist/components/search/features/input.js +238 -238
  142. package/dist/components/search/features/states.js +279 -279
  143. package/dist/components/search/features/structure.js +212 -212
  144. package/dist/components/search/features/suggestions.js +234 -234
  145. package/dist/components/search/search.js +30 -30
  146. package/dist/components/select/api.js +92 -92
  147. package/dist/components/select/config.js +46 -46
  148. package/dist/components/select/constants.js +39 -39
  149. package/dist/components/select/features.js +485 -485
  150. package/dist/components/select/select.js +17 -17
  151. package/dist/components/side-sheet/api.js +46 -46
  152. package/dist/components/side-sheet/config.js +19 -19
  153. package/dist/components/side-sheet/constants.js +22 -22
  154. package/dist/components/side-sheet/features/state.js +132 -132
  155. package/dist/components/side-sheet/features/structure.js +89 -89
  156. package/dist/components/side-sheet/side-sheet.js +8 -8
  157. package/dist/components/slider/config.js +54 -54
  158. package/dist/components/slider/constants.js +54 -54
  159. package/dist/components/slider/features/axis.js +14 -14
  160. package/dist/components/slider/features/controller.js +944 -944
  161. package/dist/components/slider/features/dom.js +104 -104
  162. package/dist/components/slider/features/states.js +83 -83
  163. package/dist/components/slider/slider.js +16 -16
  164. package/dist/components/snackbar/api.js +199 -199
  165. package/dist/components/snackbar/config.js +24 -24
  166. package/dist/components/snackbar/constants.js +41 -41
  167. package/dist/components/snackbar/features.js +115 -115
  168. package/dist/components/snackbar/layer.js +72 -72
  169. package/dist/components/snackbar/position.js +20 -20
  170. package/dist/components/snackbar/queue.js +89 -89
  171. package/dist/components/snackbar/snackbar.js +12 -12
  172. package/dist/components/split-button/api.js +137 -137
  173. package/dist/components/split-button/config.js +11 -11
  174. package/dist/components/split-button/constants.js +24 -24
  175. package/dist/components/split-button/features/buttons.js +35 -35
  176. package/dist/components/split-button/features/menu.js +12 -12
  177. package/dist/components/split-button/split-button.js +11 -11
  178. package/dist/components/switch/api.js +101 -101
  179. package/dist/components/switch/config.js +20 -20
  180. package/dist/components/switch/constants.js +29 -29
  181. package/dist/components/switch/features.js +123 -123
  182. package/dist/components/switch/switch.js +13 -13
  183. package/dist/components/tabs/api.js +104 -104
  184. package/dist/components/tabs/config.js +20 -20
  185. package/dist/components/tabs/constants.js +40 -40
  186. package/dist/components/tabs/features.js +159 -159
  187. package/dist/components/tabs/indicator.js +151 -151
  188. package/dist/components/tabs/responsive.js +59 -59
  189. package/dist/components/tabs/tab.js +218 -218
  190. package/dist/components/tabs/tabs.js +27 -27
  191. package/dist/components/tabs/utils.js +121 -121
  192. package/dist/components/text-field/api.js +212 -212
  193. package/dist/components/text-field/config.js +30 -30
  194. package/dist/components/text-field/constants.js +54 -54
  195. package/dist/components/text-field/features/counter.js +51 -51
  196. package/dist/components/text-field/features/density.js +36 -36
  197. package/dist/components/text-field/features/error.js +55 -55
  198. package/dist/components/text-field/features/field.js +30 -30
  199. package/dist/components/text-field/features/leading-icon.js +52 -52
  200. package/dist/components/text-field/features/placement.js +146 -146
  201. package/dist/components/text-field/features/prefix-text.js +48 -48
  202. package/dist/components/text-field/features/required.js +48 -48
  203. package/dist/components/text-field/features/suffix-text.js +48 -48
  204. package/dist/components/text-field/features/supporting-text.js +85 -85
  205. package/dist/components/text-field/features/trailing-icon.js +88 -88
  206. package/dist/components/text-field/text-field.js +11 -11
  207. package/dist/components/timepicker/api.js +275 -275
  208. package/dist/components/timepicker/config.js +31 -31
  209. package/dist/components/timepicker/constants.js +52 -52
  210. package/dist/components/timepicker/dial.js +164 -164
  211. package/dist/components/timepicker/render.js +400 -400
  212. package/dist/components/timepicker/timepicker.js +40 -40
  213. package/dist/components/timepicker/types.js +8 -8
  214. package/dist/components/timepicker/utils.js +67 -67
  215. package/dist/components/toolbar/config.js +35 -35
  216. package/dist/components/toolbar/constants.js +17 -17
  217. package/dist/components/toolbar/toolbar.js +188 -188
  218. package/dist/components/tooltip/api.js +309 -309
  219. package/dist/components/tooltip/config.js +32 -32
  220. package/dist/components/tooltip/constants.js +38 -38
  221. package/dist/components/tooltip/tooltip.js +20 -20
  222. package/dist/components/tooltip/types.js +15 -15
  223. package/dist/components/top-app-bar/config.js +5 -5
  224. package/dist/components/top-app-bar/constants.js +25 -25
  225. package/dist/components/top-app-bar/top-app-bar.js +158 -158
  226. package/dist/core/canvas/animation.js +30 -30
  227. package/dist/core/canvas/drawing.js +52 -52
  228. package/dist/core/canvas/resize.js +47 -47
  229. package/dist/core/canvas/utils.js +101 -101
  230. package/dist/core/compose/base.js +5 -5
  231. package/dist/core/compose/cleanup.js +47 -47
  232. package/dist/core/compose/component.js +132 -132
  233. package/dist/core/compose/features/badge.js +56 -56
  234. package/dist/core/compose/features/checkable.js +37 -37
  235. package/dist/core/compose/features/constants.js +1 -1
  236. package/dist/core/compose/features/debounce.js +39 -39
  237. package/dist/core/compose/features/disabled.js +61 -61
  238. package/dist/core/compose/features/events.js +19 -19
  239. package/dist/core/compose/features/icon.js +66 -66
  240. package/dist/core/compose/features/input.js +63 -63
  241. package/dist/core/compose/features/lifecycle.js +71 -71
  242. package/dist/core/compose/features/position.js +31 -31
  243. package/dist/core/compose/features/ripple.js +76 -76
  244. package/dist/core/compose/features/size.js +5 -5
  245. package/dist/core/compose/features/style.js +7 -7
  246. package/dist/core/compose/features/text.js +49 -49
  247. package/dist/core/compose/features/textinput.js +164 -164
  248. package/dist/core/compose/features/textlabel.js +47 -47
  249. package/dist/core/compose/features/throttle.js +39 -39
  250. package/dist/core/compose/features/track.js +24 -24
  251. package/dist/core/compose/features/variant.js +5 -5
  252. package/dist/core/compose/features/withEvents.js +48 -48
  253. package/dist/core/compose/pipe.js +4 -4
  254. package/dist/core/compose/utils/type-guards.js +6 -6
  255. package/dist/core/config/component.js +54 -54
  256. package/dist/core/config/global.js +6 -6
  257. package/dist/core/config.js +9 -9
  258. package/dist/core/dom/attributes.js +38 -38
  259. package/dist/core/dom/classes.js +74 -74
  260. package/dist/core/dom/create.js +133 -133
  261. package/dist/core/dom/direction.js +28 -28
  262. package/dist/core/dom/events.js +80 -80
  263. package/dist/core/dom/focus.js +38 -38
  264. package/dist/core/dom/form-value.js +10 -10
  265. package/dist/core/dom/html.js +7 -7
  266. package/dist/core/dom/layer.js +134 -134
  267. package/dist/core/dom/roving.js +69 -69
  268. package/dist/core/dom/utils.js +38 -38
  269. package/dist/core/navigation/destinations.js +103 -103
  270. package/dist/core/navigation/ripple.js +39 -39
  271. package/dist/core/shapes/cubic.js +55 -55
  272. package/dist/core/shapes/material.js +164 -164
  273. package/dist/core/shapes/polygon.js +198 -198
  274. package/dist/core/state/emitter.js +29 -29
  275. package/dist/core/state/events.js +30 -30
  276. package/dist/core/state/store.js +55 -55
  277. package/dist/core/theme/tokens.js +28 -28
  278. package/dist/core/utils/attributes.js +8 -8
  279. package/dist/core/utils/background.js +29 -29
  280. package/dist/core/utils/color.js +21 -21
  281. package/dist/core/utils/mobile.js +28 -28
  282. package/dist/core/utils/object.js +17 -17
  283. package/dist/core/utils/performance.js +111 -111
  284. package/dist/core/utils/theme.js +49 -49
  285. package/dist/core/utils/url.js +0 -0
  286. package/dist/core/utils/warn.js +14 -14
  287. package/dist/elements/adapter.js +51 -51
  288. package/dist/elements/badge.js +23 -23
  289. package/dist/elements/bottom-app-bar.js +32 -32
  290. package/dist/elements/bottom-sheet.js +81 -81
  291. package/dist/elements/button-group.js +151 -151
  292. package/dist/elements/button.js +40 -40
  293. package/dist/elements/card.js +89 -89
  294. package/dist/elements/carousel.js +101 -101
  295. package/dist/elements/checkbox.js +44 -44
  296. package/dist/elements/chips.js +185 -185
  297. package/dist/elements/datepicker.js +101 -101
  298. package/dist/elements/define.js +571 -571
  299. package/dist/elements/dialog.js +134 -134
  300. package/dist/elements/divider.js +16 -16
  301. package/dist/elements/drawer.js +118 -118
  302. package/dist/elements/extended-fab.js +29 -29
  303. package/dist/elements/fab-menu.js +58 -58
  304. package/dist/elements/fab.js +18 -18
  305. package/dist/elements/form-button.js +14 -14
  306. package/dist/elements/icon-button.js +42 -42
  307. package/dist/elements/index.js +87 -87
  308. package/dist/elements/lifecycle.js +8 -8
  309. package/dist/elements/list.js +162 -162
  310. package/dist/elements/loading-indicator.js +19 -19
  311. package/dist/elements/menu.js +169 -169
  312. package/dist/elements/navigation-bar.js +58 -58
  313. package/dist/elements/navigation-rail.js +110 -110
  314. package/dist/elements/preupgrade/badge.css +1 -1
  315. package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
  316. package/dist/elements/preupgrade/bottom-sheet.css +1 -1
  317. package/dist/elements/preupgrade/button-group.css +1 -1
  318. package/dist/elements/preupgrade/button.css +1 -1
  319. package/dist/elements/preupgrade/card.css +1 -1
  320. package/dist/elements/preupgrade/carousel.css +1 -1
  321. package/dist/elements/preupgrade/checkbox.css +1 -1
  322. package/dist/elements/preupgrade/chips.css +1 -1
  323. package/dist/elements/preupgrade/datepicker.css +1 -1
  324. package/dist/elements/preupgrade/dialog.css +1 -1
  325. package/dist/elements/preupgrade/divider.css +1 -1
  326. package/dist/elements/preupgrade/drawer.css +1 -1
  327. package/dist/elements/preupgrade/extended-fab.css +1 -1
  328. package/dist/elements/preupgrade/fab-menu.css +1 -1
  329. package/dist/elements/preupgrade/fab.css +1 -1
  330. package/dist/elements/preupgrade/icon-button.css +1 -1
  331. package/dist/elements/preupgrade/list.css +1 -1
  332. package/dist/elements/preupgrade/loading-indicator.css +1 -1
  333. package/dist/elements/preupgrade/menu.css +1 -1
  334. package/dist/elements/preupgrade/navigation-bar.css +1 -1
  335. package/dist/elements/preupgrade/navigation-rail.css +1 -1
  336. package/dist/elements/preupgrade/progress.css +1 -1
  337. package/dist/elements/preupgrade/radios.css +1 -1
  338. package/dist/elements/preupgrade/search.css +1 -1
  339. package/dist/elements/preupgrade/select.css +1 -1
  340. package/dist/elements/preupgrade/side-sheet.css +1 -1
  341. package/dist/elements/preupgrade/slider.css +1 -1
  342. package/dist/elements/preupgrade/snackbar.css +1 -1
  343. package/dist/elements/preupgrade/split-button.css +1 -1
  344. package/dist/elements/preupgrade/switch.css +1 -1
  345. package/dist/elements/preupgrade/tabs.css +1 -1
  346. package/dist/elements/preupgrade/text-field.css +1 -1
  347. package/dist/elements/preupgrade/timepicker.css +1 -1
  348. package/dist/elements/preupgrade/toolbar.css +1 -1
  349. package/dist/elements/preupgrade/tooltip.css +1 -1
  350. package/dist/elements/preupgrade/top-app-bar.css +1 -1
  351. package/dist/elements/preupgrade.css +1 -1
  352. package/dist/elements/preupgrade.js +0 -1
  353. package/dist/elements/progress.js +32 -32
  354. package/dist/elements/radios.js +105 -105
  355. package/dist/elements/search.js +189 -189
  356. package/dist/elements/select.js +124 -124
  357. package/dist/elements/sheet.js +49 -49
  358. package/dist/elements/side-sheet.js +53 -53
  359. package/dist/elements/slider.js +117 -117
  360. package/dist/elements/snackbar.js +45 -45
  361. package/dist/elements/split-button.js +82 -82
  362. package/dist/elements/styles.js +27 -27
  363. package/dist/elements/switch.js +43 -43
  364. package/dist/elements/tabs.js +96 -96
  365. package/dist/elements/text-field.js +117 -117
  366. package/dist/elements/timepicker.js +142 -142
  367. package/dist/elements/toolbar.js +63 -63
  368. package/dist/elements/tooltip.js +111 -111
  369. package/dist/elements/top-app-bar.js +75 -75
  370. package/dist/package.json +1 -1
  371. package/dist/react/create.js +113 -113
  372. package/dist/react/shadow.js +8 -8
  373. package/dist/solid/create.js +122 -122
  374. package/dist/solid/shadow.js +6 -6
  375. package/dist/ssr/index.js +17 -17
  376. package/dist/ssr/react.js +2 -310
  377. package/dist/ssr/solid.js +1 -16
  378. package/dist/ssr/svelte.js +1 -73
  379. package/dist/ssr/vue.js +1 -71
  380. package/dist/styles/badge.css +1 -1
  381. package/dist/styles/base.css +1 -1
  382. package/dist/styles/bottom-app-bar.css +1 -1
  383. package/dist/styles/bottom-sheet.css +1 -1
  384. package/dist/styles/button-group.css +1 -1
  385. package/dist/styles/button.css +1 -1
  386. package/dist/styles/card.css +1 -1
  387. package/dist/styles/carousel.css +1 -1
  388. package/dist/styles/checkbox.css +1 -1
  389. package/dist/styles/chips.css +1 -1
  390. package/dist/styles/contrast.css +1 -1
  391. package/dist/styles/datepicker.css +1 -1
  392. package/dist/styles/dialog.css +1 -1
  393. package/dist/styles/divider.css +1 -1
  394. package/dist/styles/drawer.css +1 -1
  395. package/dist/styles/extended-fab.css +1 -1
  396. package/dist/styles/fab-menu.css +1 -1
  397. package/dist/styles/fab.css +1 -1
  398. package/dist/styles/icon-button.css +1 -1
  399. package/dist/styles/list.css +1 -1
  400. package/dist/styles/loading-indicator.css +1 -1
  401. package/dist/styles/menu.css +1 -1
  402. package/dist/styles/navigation-bar.css +1 -1
  403. package/dist/styles/navigation-rail.css +1 -1
  404. package/dist/styles/progress.css +1 -1
  405. package/dist/styles/radios.css +1 -1
  406. package/dist/styles/search.css +1 -1
  407. package/dist/styles/select.css +1 -1
  408. package/dist/styles/side-sheet.css +1 -1
  409. package/dist/styles/slider.css +1 -1
  410. package/dist/styles/snackbar.css +1 -1
  411. package/dist/styles/split-button.css +1 -1
  412. package/dist/styles/switch.css +1 -1
  413. package/dist/styles/tabs.css +1 -1
  414. package/dist/styles/text-field.css +1 -1
  415. package/dist/styles/timepicker.css +1 -1
  416. package/dist/styles/toolbar.css +1 -1
  417. package/dist/styles/tooltip.css +1 -1
  418. package/dist/styles/top-app-bar.css +1 -1
  419. package/dist/styles/typography.css +1 -1
  420. package/dist/styles/utilities.css +1 -1
  421. package/dist/styles.css +1 -1
  422. package/dist/themes/autumn-contrast.css +1 -1
  423. package/dist/themes/autumn.css +1 -1
  424. package/dist/themes/baseline-contrast.css +1 -1
  425. package/dist/themes/baseline.css +1 -1
  426. package/dist/themes/brownbeige-contrast.css +1 -1
  427. package/dist/themes/brownbeige.css +1 -1
  428. package/dist/themes/content-contrast.css +1 -1
  429. package/dist/themes/content.css +1 -1
  430. package/dist/themes/desert-contrast.css +1 -1
  431. package/dist/themes/desert.css +1 -1
  432. package/dist/themes/expressive-contrast.css +1 -1
  433. package/dist/themes/expressive.css +1 -1
  434. package/dist/themes/fidelity-contrast.css +1 -1
  435. package/dist/themes/fidelity.css +1 -1
  436. package/dist/themes/forest-contrast.css +1 -1
  437. package/dist/themes/forest.css +1 -1
  438. package/dist/themes/fruit-salad-contrast.css +1 -1
  439. package/dist/themes/fruit-salad.css +1 -1
  440. package/dist/themes/highcontrast-contrast.css +1 -1
  441. package/dist/themes/highcontrast.css +1 -1
  442. package/dist/themes/monochrome-contrast.css +1 -1
  443. package/dist/themes/monochrome.css +1 -1
  444. package/dist/themes/neutral-contrast.css +1 -1
  445. package/dist/themes/neutral.css +1 -1
  446. package/dist/themes/ocean-contrast.css +1 -1
  447. package/dist/themes/ocean.css +1 -1
  448. package/dist/themes/rainbow-contrast.css +1 -1
  449. package/dist/themes/rainbow.css +1 -1
  450. package/dist/themes/sageivory-contrast.css +1 -1
  451. package/dist/themes/sageivory.css +1 -1
  452. package/dist/themes/spring-contrast.css +1 -1
  453. package/dist/themes/spring.css +1 -1
  454. package/dist/themes/summer-contrast.css +1 -1
  455. package/dist/themes/summer.css +1 -1
  456. package/dist/themes/sunset-contrast.css +1 -1
  457. package/dist/themes/sunset.css +1 -1
  458. package/dist/themes/tealcaramel-contrast.css +1 -1
  459. package/dist/themes/tealcaramel.css +1 -1
  460. package/dist/themes/vibrant-contrast.css +1 -1
  461. package/dist/themes/vibrant.css +1 -1
  462. package/dist/vue/create.js +123 -123
  463. package/dist/vue/shadow.js +6 -6
  464. package/package.json +1 -1
@@ -1,62 +1,62 @@
1
1
  import { createEmitter } from "./emitter.js";
2
2
  export const createStore = (initialState = {}, options = {}) => {
3
- let state = { ...initialState };
4
- const emitter = createEmitter();
5
- const derivedStates = new Map();
6
- const middleware = options.middleware || [];
7
- const notifyListeners = (newState, oldState) => {
8
- emitter.emit('change', newState, oldState);
9
- };
10
- const applyMiddleware = (newState, oldState) => {
11
- return middleware.reduce((state, fn) => fn(state, oldState), newState);
12
- };
13
- return {
14
- getState: () => {
15
- const derivedValues = {};
16
- derivedStates.forEach((compute, key) => {
17
- derivedValues[key] = compute(state);
18
- });
19
- return { ...state, ...derivedValues };
20
- },
21
- setState: (update) => {
22
- const oldState = { ...state };
23
- const newState = typeof update === 'function'
24
- ? update(state)
25
- : { ...state, ...update };
26
- state = applyMiddleware(newState, oldState);
27
- notifyListeners(state, oldState);
28
- },
29
- subscribe: (listener) => emitter.on('change', listener),
30
- derive: (key, computation) => {
31
- derivedStates.set(key, computation);
32
- const remove = () => {
33
- derivedStates.delete(key);
34
- };
35
- return Object.assign(remove, { get: () => computation(state) });
36
- },
37
- select: (selector) => selector(state),
38
- reset: () => {
39
- state = { ...initialState };
40
- notifyListeners(state, {});
41
- }
42
- };
3
+ let state = { ...initialState };
4
+ const emitter = createEmitter();
5
+ const derivedStates = new Map();
6
+ const middleware = options.middleware || [];
7
+ const notifyListeners = (newState, oldState) => {
8
+ emitter.emit('change', newState, oldState);
9
+ };
10
+ const applyMiddleware = (newState, oldState) => {
11
+ return middleware.reduce((state, fn) => fn(state, oldState), newState);
12
+ };
13
+ return {
14
+ getState: () => {
15
+ const derivedValues = {};
16
+ derivedStates.forEach((compute, key) => {
17
+ derivedValues[key] = compute(state);
18
+ });
19
+ return { ...state, ...derivedValues };
20
+ },
21
+ setState: (update) => {
22
+ const oldState = { ...state };
23
+ const newState = typeof update === 'function'
24
+ ? update(state)
25
+ : { ...state, ...update };
26
+ state = applyMiddleware(newState, oldState);
27
+ notifyListeners(state, oldState);
28
+ },
29
+ subscribe: (listener) => emitter.on('change', listener),
30
+ derive: (key, computation) => {
31
+ derivedStates.set(key, computation);
32
+ const remove = () => {
33
+ derivedStates.delete(key);
34
+ };
35
+ return Object.assign(remove, { get: () => computation(state) });
36
+ },
37
+ select: (selector) => selector(state),
38
+ reset: () => {
39
+ state = { ...initialState };
40
+ notifyListeners(state, {});
41
+ }
42
+ };
43
43
  };
44
44
  export const loggingMiddleware = (newState, oldState) => {
45
- console.log('State change:', {
46
- old: oldState,
47
- new: newState,
48
- diff: Object.keys(newState).reduce((acc, key) => {
49
- if (newState[key] !== oldState[key]) {
50
- acc[key] = { from: oldState[key], to: newState[key] };
51
- }
52
- return acc;
53
- }, {})
54
- });
55
- return newState;
45
+ console.log('State change:', {
46
+ old: oldState,
47
+ new: newState,
48
+ diff: Object.keys(newState).reduce((acc, key) => {
49
+ if (newState[key] !== oldState[key]) {
50
+ acc[key] = { from: oldState[key], to: newState[key] };
51
+ }
52
+ return acc;
53
+ }, {})
54
+ });
55
+ return newState;
56
56
  };
57
57
  export const deriveFiltered = (predicate) => (state) => Object.keys(state).reduce((acc, key) => {
58
- if (predicate(state[key], key)) {
59
- acc[key] = state[key];
60
- }
61
- return acc;
58
+ if (predicate(state[key], key)) {
59
+ acc[key] = state[key];
60
+ }
61
+ return acc;
62
62
  }, {});
@@ -1,36 +1,36 @@
1
1
  export const THEME_ROLES = [
2
- "error", "on-error", "error-container", "on-error-container",
3
- "primary", "on-primary", "primary-container", "on-primary-container",
4
- "secondary", "on-secondary", "secondary-container", "on-secondary-container",
5
- "tertiary", "on-tertiary", "tertiary-container", "on-tertiary-container",
6
- "primary-fixed", "primary-fixed-dim", "on-primary-fixed", "on-primary-fixed-variant",
7
- "secondary-fixed", "secondary-fixed-dim", "on-secondary-fixed", "on-secondary-fixed-variant",
8
- "tertiary-fixed", "tertiary-fixed-dim", "on-tertiary-fixed", "on-tertiary-fixed-variant",
9
- "surface", "surface-dim", "surface-bright", "surface-variant",
10
- "surface-container-lowest", "surface-container-low", "surface-container",
11
- "surface-container-high", "surface-container-highest",
12
- "on-surface", "on-surface-variant",
13
- "outline", "outline-variant", "shadow", "scrim",
14
- "inverse-surface", "inverse-on-surface", "inverse-primary",
2
+ "error", "on-error", "error-container", "on-error-container",
3
+ "primary", "on-primary", "primary-container", "on-primary-container",
4
+ "secondary", "on-secondary", "secondary-container", "on-secondary-container",
5
+ "tertiary", "on-tertiary", "tertiary-container", "on-tertiary-container",
6
+ "primary-fixed", "primary-fixed-dim", "on-primary-fixed", "on-primary-fixed-variant",
7
+ "secondary-fixed", "secondary-fixed-dim", "on-secondary-fixed", "on-secondary-fixed-variant",
8
+ "tertiary-fixed", "tertiary-fixed-dim", "on-tertiary-fixed", "on-tertiary-fixed-variant",
9
+ "surface", "surface-dim", "surface-bright", "surface-variant",
10
+ "surface-container-lowest", "surface-container-low", "surface-container",
11
+ "surface-container-high", "surface-container-highest",
12
+ "on-surface", "on-surface-variant",
13
+ "outline", "outline-variant", "shadow", "scrim",
14
+ "inverse-surface", "inverse-on-surface", "inverse-primary",
15
15
  ];
16
16
  const kebab = (name) => name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
17
17
  const HEX = /^#([0-9a-f]{6})$/i;
18
18
  const mode = (roles, name, prefix) => {
19
- const byRole = new Map();
20
- for (const [key, value] of Object.entries(roles))
21
- byRole.set(kebab(key), value);
22
- const tokens = {};
23
- for (const role of THEME_ROLES) {
24
- const hex = byRole.get(role);
25
- if (hex === undefined)
26
- throw new Error(`schemeToTokens: ${name} scheme has no ${role}`);
27
- if (!HEX.test(hex))
28
- throw new Error(`schemeToTokens: ${name} ${role} is not #rrggbb: ${hex}`);
29
- tokens[`--${prefix}-sys-color-${role}`] = hex.toLowerCase();
30
- }
31
- return tokens;
19
+ const byRole = new Map();
20
+ for (const [key, value] of Object.entries(roles))
21
+ byRole.set(kebab(key), value);
22
+ const tokens = {};
23
+ for (const role of THEME_ROLES) {
24
+ const hex = byRole.get(role);
25
+ if (hex === undefined)
26
+ throw new Error(`schemeToTokens: ${name} scheme has no ${role}`);
27
+ if (!HEX.test(hex))
28
+ throw new Error(`schemeToTokens: ${name} ${role} is not #rrggbb: ${hex}`);
29
+ tokens[`--${prefix}-sys-color-${role}`] = hex.toLowerCase();
30
+ }
31
+ return tokens;
32
32
  };
33
33
  export const schemeToTokens = (schemes, options = {}) => {
34
- const prefix = options.prefix ?? "mtrl";
35
- return { light: mode(schemes.light, "light", prefix), dark: mode(schemes.dark, "dark", prefix) };
34
+ const prefix = options.prefix ?? "mtrl";
35
+ return { light: mode(schemes.light, "light", prefix), dark: mode(schemes.dark, "dark", prefix) };
36
36
  };
@@ -1,11 +1,11 @@
1
1
  export const BOOLEAN_ATTRIBUTES = new Set([
2
- "disabled",
3
- "checked",
4
- "readonly",
5
- "required",
6
- "hidden",
7
- "selected",
8
- "open",
9
- "multiple",
2
+ "disabled",
3
+ "checked",
4
+ "readonly",
5
+ "required",
6
+ "hidden",
7
+ "selected",
8
+ "open",
9
+ "multiple",
10
10
  ]);
11
11
  export const omitsAttribute = (key, value) => value === false && BOOLEAN_ATTRIBUTES.has(key.toLowerCase());
@@ -1,32 +1,32 @@
1
1
  export const getInheritedBackground = (element, maxDepth = 17) => {
2
- if (!element || !(element instanceof HTMLElement)) {
3
- return { color: '', element: null };
4
- }
5
- let depth = 0;
6
- let currentElement = element;
7
- while (currentElement && depth < maxDepth) {
8
- const computedStyle = window.getComputedStyle(currentElement);
9
- let bgColor = computedStyle.backgroundColor;
10
- if (bgColor.startsWith('var(')) {
11
- const varMatch = bgColor.match(/var\((--[\w-]+)\)/);
12
- if (varMatch) {
13
- const varName = varMatch[1];
14
- bgColor = window.getComputedStyle(document.documentElement).getPropertyValue(varName).trim() || 'transparent';
15
- }
16
- }
17
- if (bgColor &&
18
- bgColor !== 'transparent' &&
19
- bgColor !== 'rgba(0, 0, 0, 0)' &&
20
- bgColor !== 'rgba(0,0,0,0)') {
21
- return { color: bgColor, element: currentElement };
22
- }
23
- currentElement = currentElement.parentElement;
24
- depth++;
25
- }
26
- const documentBG = window.getComputedStyle(document.body).backgroundColor;
27
- if (documentBG !== 'transparent' && documentBG !== 'rgba(0, 0, 0, 0)') {
28
- return { color: documentBG, element: document.body };
29
- }
30
- return { color: 'rgb(255, 255, 255)', element: null };
2
+ if (!element || !(element instanceof HTMLElement)) {
3
+ return { color: '', element: null };
4
+ }
5
+ let depth = 0;
6
+ let currentElement = element;
7
+ while (currentElement && depth < maxDepth) {
8
+ const computedStyle = window.getComputedStyle(currentElement);
9
+ let bgColor = computedStyle.backgroundColor;
10
+ if (bgColor.startsWith('var(')) {
11
+ const varMatch = bgColor.match(/var\((--[\w-]+)\)/);
12
+ if (varMatch) {
13
+ const varName = varMatch[1];
14
+ bgColor = window.getComputedStyle(document.documentElement).getPropertyValue(varName).trim() || 'transparent';
15
+ }
16
+ }
17
+ if (bgColor &&
18
+ bgColor !== 'transparent' &&
19
+ bgColor !== 'rgba(0, 0, 0, 0)' &&
20
+ bgColor !== 'rgba(0,0,0,0)') {
21
+ return { color: bgColor, element: currentElement };
22
+ }
23
+ currentElement = currentElement.parentElement;
24
+ depth++;
25
+ }
26
+ const documentBG = window.getComputedStyle(document.body).backgroundColor;
27
+ if (documentBG !== 'transparent' && documentBG !== 'rgba(0, 0, 0, 0)') {
28
+ return { color: documentBG, element: document.body };
29
+ }
30
+ return { color: 'rgb(255, 255, 255)', element: null };
31
31
  };
32
32
  export default getInheritedBackground;
@@ -1,23 +1,23 @@
1
1
  export const colorToRGBA = (color, opacity) => {
2
- const canvas = document.createElement('canvas');
3
- const ctx = canvas.getContext('2d');
4
- if (!ctx)
5
- return `rgba(0, 0, 0, ${opacity})`;
6
- ctx.fillStyle = color;
7
- const computedColor = ctx.fillStyle;
8
- if (computedColor.startsWith('#')) {
9
- const hex = computedColor.substring(1);
10
- const r = parseInt(hex.substring(0, 2), 16);
11
- const g = parseInt(hex.substring(2, 4), 16);
12
- const b = parseInt(hex.substring(4, 6), 16);
13
- return `rgba(${r}, ${g}, ${b}, ${opacity})`;
14
- }
15
- if (computedColor.startsWith('rgb')) {
16
- const match = computedColor.match(/\d+/g);
17
- if (match) {
18
- const [r, g, b] = match;
19
- return `rgba(${r}, ${g}, ${b}, ${opacity})`;
20
- }
21
- }
22
- return `rgba(0, 0, 0, ${opacity})`;
2
+ const canvas = document.createElement('canvas');
3
+ const ctx = canvas.getContext('2d');
4
+ if (!ctx)
5
+ return `rgba(0, 0, 0, ${opacity})`;
6
+ ctx.fillStyle = color;
7
+ const computedColor = ctx.fillStyle;
8
+ if (computedColor.startsWith('#')) {
9
+ const hex = computedColor.substring(1);
10
+ const r = parseInt(hex.substring(0, 2), 16);
11
+ const g = parseInt(hex.substring(2, 4), 16);
12
+ const b = parseInt(hex.substring(4, 6), 16);
13
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
14
+ }
15
+ if (computedColor.startsWith('rgb')) {
16
+ const match = computedColor.match(/\d+/g);
17
+ if (match) {
18
+ const [r, g, b] = match;
19
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
20
+ }
21
+ }
22
+ return `rgba(0, 0, 0, ${opacity})`;
23
23
  };
@@ -1,43 +1,43 @@
1
1
  export const isMobileDevice = () => {
2
- const userAgent = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
3
- const screenSize = window.innerWidth <= 768;
4
- return userAgent || screenSize;
2
+ const userAgent = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
3
+ const screenSize = window.innerWidth <= 768;
4
+ return userAgent || screenSize;
5
5
  };
6
6
  export const PASSIVE_EVENTS = { passive: true };
7
7
  export const TOUCH_CONFIG = {
8
- TARGET_SIZE: 44,
9
- FEEDBACK_DURATION: 200,
10
- TAP_THRESHOLD: 250,
11
- SWIPE_THRESHOLD: 50
8
+ TARGET_SIZE: 44,
9
+ FEEDBACK_DURATION: 200,
10
+ TAP_THRESHOLD: 250,
11
+ SWIPE_THRESHOLD: 50
12
12
  };
13
13
  export const TOUCH_TARGETS = {
14
- MINIMUM: 44,
15
- COMFORTABLE: 48,
16
- LARGE: 56
14
+ MINIMUM: 44,
15
+ COMFORTABLE: 48,
16
+ LARGE: 56
17
17
  };
18
18
  export const hasTouchSupport = () => {
19
- return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
19
+ return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
20
20
  };
21
21
  function isTouchEvent(event) {
22
- return 'touches' in event;
22
+ return 'touches' in event;
23
23
  }
24
24
  function isMouseEvent(event) {
25
- return 'clientX' in event && 'clientY' in event;
25
+ return 'clientX' in event && 'clientY' in event;
26
26
  }
27
27
  export const normalizeEvent = (event) => {
28
- const point = isTouchEvent(event) && event.touches.length > 0
29
- ? event.touches[0]
30
- : isMouseEvent(event)
31
- ? event
32
- : undefined;
33
- return {
34
- clientX: point ? point.clientX : 0,
35
- clientY: point ? point.clientY : 0,
36
- pageX: point ? point.pageX : 0,
37
- pageY: point ? point.pageY : 0,
38
- target: event.target,
39
- preventDefault: () => event.preventDefault(),
40
- stopPropagation: () => event.stopPropagation(),
41
- type: event.type
42
- };
28
+ const point = isTouchEvent(event) && event.touches.length > 0
29
+ ? event.touches[0]
30
+ : isMouseEvent(event)
31
+ ? event
32
+ : undefined;
33
+ return {
34
+ clientX: point ? point.clientX : 0,
35
+ clientY: point ? point.clientY : 0,
36
+ pageX: point ? point.pageX : 0,
37
+ pageY: point ? point.pageY : 0,
38
+ target: event.target,
39
+ preventDefault: () => event.preventDefault(),
40
+ stopPropagation: () => event.stopPropagation(),
41
+ type: event.type
42
+ };
43
43
  };
@@ -1,21 +1,21 @@
1
1
  export const isObject = (value) => {
2
- return Boolean(value &&
3
- typeof value === 'object' &&
4
- Object.getPrototypeOf(value) === Object.getPrototypeOf({}));
2
+ return Boolean(value &&
3
+ typeof value === 'object' &&
4
+ Object.getPrototypeOf(value) === Object.getPrototypeOf({}));
5
5
  };
6
6
  export const byString = (obj, path) => {
7
- const normalizedPath = path.replace(/\[(\w+)\]/g, '.$1');
8
- const cleanPath = normalizedPath.replace(/^\./, '');
9
- const keys = cleanPath.split('.');
10
- let result = obj;
11
- for (let i = 0, n = keys.length; i < n; ++i) {
12
- const key = keys[i];
13
- if (key in result) {
14
- result = result[key];
15
- }
16
- else {
17
- return undefined;
18
- }
19
- }
20
- return result;
7
+ const normalizedPath = path.replace(/\[(\w+)\]/g, '.$1');
8
+ const cleanPath = normalizedPath.replace(/^\./, '');
9
+ const keys = cleanPath.split('.');
10
+ let result = obj;
11
+ for (let i = 0, n = keys.length; i < n; ++i) {
12
+ const key = keys[i];
13
+ if (key in result) {
14
+ result = result[key];
15
+ }
16
+ else {
17
+ return undefined;
18
+ }
19
+ }
20
+ return result;
21
21
  };
@@ -1,117 +1,117 @@
1
1
  export const throttle = (fn, wait, options = {}) => {
2
- let timeout = null;
3
- let previous = 0;
4
- const { leading = true, trailing = true } = options;
5
- const throttled = function (...args) {
6
- const now = Date.now();
7
- if (!previous && !leading) {
8
- previous = now;
9
- }
10
- const remaining = wait - (now - previous);
11
- if (remaining <= 0 || remaining > wait) {
12
- if (timeout) {
13
- clearTimeout(timeout);
14
- timeout = null;
15
- }
16
- previous = now;
17
- fn.apply(this, args);
18
- }
19
- else if (!timeout && trailing) {
20
- timeout = window.setTimeout(() => {
21
- previous = leading ? Date.now() : 0;
22
- timeout = null;
23
- fn.apply(this, args);
24
- }, remaining);
25
- }
26
- };
27
- return Object.assign(throttled, { cancel() {
28
- if (timeout !== null)
29
- clearTimeout(timeout);
30
- timeout = null;
31
- previous = 0;
32
- } });
2
+ let timeout = null;
3
+ let previous = 0;
4
+ const { leading = true, trailing = true } = options;
5
+ const throttled = function (...args) {
6
+ const now = Date.now();
7
+ if (!previous && !leading) {
8
+ previous = now;
9
+ }
10
+ const remaining = wait - (now - previous);
11
+ if (remaining <= 0 || remaining > wait) {
12
+ if (timeout) {
13
+ clearTimeout(timeout);
14
+ timeout = null;
15
+ }
16
+ previous = now;
17
+ fn.apply(this, args);
18
+ }
19
+ else if (!timeout && trailing) {
20
+ timeout = window.setTimeout(() => {
21
+ previous = leading ? Date.now() : 0;
22
+ timeout = null;
23
+ fn.apply(this, args);
24
+ }, remaining);
25
+ }
26
+ };
27
+ return Object.assign(throttled, { cancel() {
28
+ if (timeout !== null)
29
+ clearTimeout(timeout);
30
+ timeout = null;
31
+ previous = 0;
32
+ } });
33
33
  };
34
34
  export const debounce = (fn, wait, options = {}) => {
35
- let timeout = null;
36
- let lastArgs = null;
37
- let lastThis = null;
38
- let result;
39
- let lastCallTime = null;
40
- let lastInvokeTime = 0;
41
- const { leading = false, maxWait } = options;
42
- const shouldInvoke = (time) => {
43
- const timeSinceLastCall = time - (lastCallTime || 0);
44
- const timeSinceLastInvoke = time - lastInvokeTime;
45
- return (!lastCallTime ||
46
- timeSinceLastCall >= wait ||
47
- timeSinceLastCall < 0 ||
48
- (maxWait !== undefined && timeSinceLastInvoke >= maxWait));
49
- };
50
- const invokeFunc = (time) => {
51
- const args = lastArgs;
52
- const thisArg = lastThis;
53
- lastArgs = lastThis = null;
54
- lastInvokeTime = time;
55
- result = fn.apply(thisArg, args);
56
- return result;
57
- };
58
- const trailingEdge = (time) => {
59
- timeout = null;
60
- if (lastArgs) {
61
- return invokeFunc(time);
62
- }
63
- return result;
64
- };
65
- const leadingEdge = (time) => {
66
- lastInvokeTime = time;
67
- timeout = window.setTimeout(() => {
68
- trailingEdge(Date.now());
69
- }, wait);
70
- return leading ? invokeFunc(time) : result;
71
- };
72
- const debounced = function (...args) {
73
- const time = Date.now();
74
- const isInvoking = shouldInvoke(time);
75
- lastArgs = args;
76
- lastThis = this;
77
- lastCallTime = time;
78
- if (isInvoking) {
79
- if (timeout === null) {
80
- return leadingEdge(time);
81
- }
82
- if (maxWait !== undefined) {
83
- window.clearTimeout(timeout);
84
- timeout = window.setTimeout(() => {
85
- const timeNow = Date.now();
86
- if (shouldInvoke(timeNow)) {
87
- return trailingEdge(timeNow);
88
- }
89
- }, Math.min(wait, maxWait - (time - lastInvokeTime)));
90
- }
91
- }
92
- if (timeout === null) {
93
- timeout = window.setTimeout(() => {
94
- trailingEdge(Date.now());
95
- }, wait);
96
- }
97
- return result;
98
- };
99
- return Object.assign(debounced, { cancel() {
100
- if (timeout !== null)
101
- window.clearTimeout(timeout);
102
- timeout = null;
103
- lastArgs = lastThis = lastCallTime = null;
104
- lastInvokeTime = 0;
105
- } });
35
+ let timeout = null;
36
+ let lastArgs = null;
37
+ let lastThis = null;
38
+ let result;
39
+ let lastCallTime = null;
40
+ let lastInvokeTime = 0;
41
+ const { leading = false, maxWait } = options;
42
+ const shouldInvoke = (time) => {
43
+ const timeSinceLastCall = time - (lastCallTime || 0);
44
+ const timeSinceLastInvoke = time - lastInvokeTime;
45
+ return (!lastCallTime ||
46
+ timeSinceLastCall >= wait ||
47
+ timeSinceLastCall < 0 ||
48
+ (maxWait !== undefined && timeSinceLastInvoke >= maxWait));
49
+ };
50
+ const invokeFunc = (time) => {
51
+ const args = lastArgs;
52
+ const thisArg = lastThis;
53
+ lastArgs = lastThis = null;
54
+ lastInvokeTime = time;
55
+ result = fn.apply(thisArg, args);
56
+ return result;
57
+ };
58
+ const trailingEdge = (time) => {
59
+ timeout = null;
60
+ if (lastArgs) {
61
+ return invokeFunc(time);
62
+ }
63
+ return result;
64
+ };
65
+ const leadingEdge = (time) => {
66
+ lastInvokeTime = time;
67
+ timeout = window.setTimeout(() => {
68
+ trailingEdge(Date.now());
69
+ }, wait);
70
+ return leading ? invokeFunc(time) : result;
71
+ };
72
+ const debounced = function (...args) {
73
+ const time = Date.now();
74
+ const isInvoking = shouldInvoke(time);
75
+ lastArgs = args;
76
+ lastThis = this;
77
+ lastCallTime = time;
78
+ if (isInvoking) {
79
+ if (timeout === null) {
80
+ return leadingEdge(time);
81
+ }
82
+ if (maxWait !== undefined) {
83
+ window.clearTimeout(timeout);
84
+ timeout = window.setTimeout(() => {
85
+ const timeNow = Date.now();
86
+ if (shouldInvoke(timeNow)) {
87
+ return trailingEdge(timeNow);
88
+ }
89
+ }, Math.min(wait, maxWait - (time - lastInvokeTime)));
90
+ }
91
+ }
92
+ if (timeout === null) {
93
+ timeout = window.setTimeout(() => {
94
+ trailingEdge(Date.now());
95
+ }, wait);
96
+ }
97
+ return result;
98
+ };
99
+ return Object.assign(debounced, { cancel() {
100
+ if (timeout !== null)
101
+ window.clearTimeout(timeout);
102
+ timeout = null;
103
+ lastArgs = lastThis = lastCallTime = null;
104
+ lastInvokeTime = 0;
105
+ } });
106
106
  };
107
107
  export const once = (fn) => {
108
- let called = false;
109
- let result;
110
- return function (...args) {
111
- if (!called) {
112
- called = true;
113
- result = fn.apply(this, args);
114
- }
115
- return result;
116
- };
108
+ let called = false;
109
+ let result;
110
+ return function (...args) {
111
+ if (!called) {
112
+ called = true;
113
+ result = fn.apply(this, args);
114
+ }
115
+ return result;
116
+ };
117
117
  };