material 3.5.3 → 3.6.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 (471) hide show
  1. package/README.md +1 -0
  2. package/dist/components/badge/api.js +156 -156
  3. package/dist/components/badge/badge.js +9 -9
  4. package/dist/components/badge/config.js +43 -43
  5. package/dist/components/badge/constants.js +13 -13
  6. package/dist/components/badge/features.js +75 -75
  7. package/dist/components/bottom-app-bar/bottom-app-bar.js +98 -98
  8. package/dist/components/bottom-app-bar/config.js +5 -5
  9. package/dist/components/bottom-app-bar/constants.js +8 -8
  10. package/dist/components/bottom-sheet/api.js +52 -52
  11. package/dist/components/bottom-sheet/bottom-sheet.js +9 -9
  12. package/dist/components/bottom-sheet/config.js +17 -17
  13. package/dist/components/bottom-sheet/constants.js +24 -24
  14. package/dist/components/bottom-sheet/features/drag.js +91 -91
  15. package/dist/components/bottom-sheet/features/state.js +148 -148
  16. package/dist/components/bottom-sheet/features/structure.js +85 -85
  17. package/dist/components/button/api.js +265 -265
  18. package/dist/components/button/button.js +15 -15
  19. package/dist/components/button/config.js +39 -39
  20. package/dist/components/button/constants.js +21 -21
  21. package/dist/components/button/features/progress.js +167 -167
  22. package/dist/components/button/features/toggle.js +31 -31
  23. package/dist/components/button-group/button-group.js +389 -389
  24. package/dist/components/button-group/config.js +106 -106
  25. package/dist/components/button-group/constants.js +62 -62
  26. package/dist/components/card/api.js +88 -88
  27. package/dist/components/card/card.js +11 -11
  28. package/dist/components/card/config.js +131 -131
  29. package/dist/components/card/constants.js +39 -39
  30. package/dist/components/card/content.js +175 -175
  31. package/dist/components/carousel/api.js +49 -49
  32. package/dist/components/carousel/arrangement.js +51 -51
  33. package/dist/components/carousel/carousel.js +2 -2
  34. package/dist/components/carousel/config.js +31 -31
  35. package/dist/components/carousel/constants.js +17 -17
  36. package/dist/components/carousel/features/scroll.js +469 -469
  37. package/dist/components/carousel/features/slides.js +125 -125
  38. package/dist/components/carousel/keylines.js +244 -244
  39. package/dist/components/carousel/strategy.js +185 -185
  40. package/dist/components/checkbox/api.js +87 -87
  41. package/dist/components/checkbox/checkbox.js +55 -55
  42. package/dist/components/checkbox/config.js +44 -44
  43. package/dist/components/checkbox/constants.js +10 -10
  44. package/dist/components/chips/api.js +157 -157
  45. package/dist/components/chips/chip/chip.js +275 -275
  46. package/dist/components/chips/chips.js +25 -25
  47. package/dist/components/chips/config.js +73 -73
  48. package/dist/components/chips/constants.js +2 -2
  49. package/dist/components/chips/features/chip-items.js +15 -15
  50. package/dist/components/chips/features/container.js +39 -39
  51. package/dist/components/chips/features/controller.js +317 -317
  52. package/dist/components/chips/features/dom.js +52 -52
  53. package/dist/components/datepicker/api.js +6 -6
  54. package/dist/components/datepicker/config.js +3 -3
  55. package/dist/components/datepicker/constants.js +39 -39
  56. package/dist/components/datepicker/datepicker.js +675 -675
  57. package/dist/components/datepicker/render.js +153 -153
  58. package/dist/components/datepicker/types.js +6 -6
  59. package/dist/components/datepicker/utils.js +157 -157
  60. package/dist/components/dialog/api.js +109 -109
  61. package/dist/components/dialog/config.js +29 -29
  62. package/dist/components/dialog/constants.js +35 -35
  63. package/dist/components/dialog/dialog.js +16 -16
  64. package/dist/components/dialog/features.js +739 -739
  65. package/dist/components/divider/config.js +4 -4
  66. package/dist/components/divider/constants.js +10 -10
  67. package/dist/components/divider/divider.js +6 -6
  68. package/dist/components/divider/features.js +72 -72
  69. package/dist/components/drawer/api.js +73 -73
  70. package/dist/components/drawer/config.js +61 -61
  71. package/dist/components/drawer/constants.js +32 -32
  72. package/dist/components/drawer/drawer.js +38 -38
  73. package/dist/components/drawer/features/headline.js +34 -34
  74. package/dist/components/drawer/features/items.js +203 -203
  75. package/dist/components/drawer/features/state.js +206 -206
  76. package/dist/components/extended-fab/api.js +92 -92
  77. package/dist/components/extended-fab/config.js +65 -65
  78. package/dist/components/extended-fab/constants.js +30 -30
  79. package/dist/components/extended-fab/extended-fab.js +51 -51
  80. package/dist/components/fab/api.js +65 -65
  81. package/dist/components/fab/config.js +46 -46
  82. package/dist/components/fab/constants.js +25 -25
  83. package/dist/components/fab/fab.js +9 -9
  84. package/dist/components/fab-menu/config.js +9 -9
  85. package/dist/components/fab-menu/constants.js +15 -15
  86. package/dist/components/fab-menu/fab-menu.js +310 -310
  87. package/dist/components/fab-menu/stagger.js +18 -18
  88. package/dist/components/icon-button/api.js +195 -195
  89. package/dist/components/icon-button/config.js +79 -79
  90. package/dist/components/icon-button/constants.js +43 -43
  91. package/dist/components/icon-button/features/toggle.js +116 -116
  92. package/dist/components/icon-button/icon-button.js +15 -15
  93. package/dist/components/list/api.js +55 -55
  94. package/dist/components/list/config.js +56 -56
  95. package/dist/components/list/constants.js +25 -25
  96. package/dist/components/list/features/anatomy.js +41 -41
  97. package/dist/components/list/features/renderer.js +136 -136
  98. package/dist/components/list/features/selection.js +118 -118
  99. package/dist/components/list/list.js +9 -9
  100. package/dist/components/loading-indicator/api.js +117 -117
  101. package/dist/components/loading-indicator/config.js +13 -13
  102. package/dist/components/loading-indicator/constants.js +23 -23
  103. package/dist/components/loading-indicator/features/motion.js +33 -33
  104. package/dist/components/loading-indicator/features/renderer.js +121 -121
  105. package/dist/components/loading-indicator/loading-indicator.js +8 -8
  106. package/dist/components/menu/api.js +76 -76
  107. package/dist/components/menu/config.js +73 -73
  108. package/dist/components/menu/constants.js +45 -45
  109. package/dist/components/menu/features/controller.js +507 -507
  110. package/dist/components/menu/features/keyboard.js +292 -292
  111. package/dist/components/menu/features/layer.js +13 -13
  112. package/dist/components/menu/features/loader.js +61 -61
  113. package/dist/components/menu/features/opener.js +288 -288
  114. package/dist/components/menu/features/position.js +279 -279
  115. package/dist/components/menu/features/registry.js +7 -7
  116. package/dist/components/menu/features/submenu.js +386 -386
  117. package/dist/components/menu/features/tasks.js +45 -45
  118. package/dist/components/menu/menu.js +16 -16
  119. package/dist/components/menu/on-demand.js +138 -138
  120. package/dist/components/navigation-bar/navigation-bar.js +144 -144
  121. package/dist/components/navigation-rail/config.js +11 -11
  122. package/dist/components/navigation-rail/constants.js +8 -8
  123. package/dist/components/navigation-rail/navigation-rail.js +237 -237
  124. package/dist/components/progress/api.js +207 -207
  125. package/dist/components/progress/config.js +137 -137
  126. package/dist/components/progress/constants.js +88 -88
  127. package/dist/components/progress/features/canvas.js +291 -291
  128. package/dist/components/progress/features/circular.js +69 -69
  129. package/dist/components/progress/features/colors.js +41 -41
  130. package/dist/components/progress/features/linear.js +96 -96
  131. package/dist/components/progress/features/motion.js +87 -87
  132. package/dist/components/progress/features/state.js +35 -35
  133. package/dist/components/progress/progress.js +11 -11
  134. package/dist/components/radios/api.js +54 -54
  135. package/dist/components/radios/config.js +19 -19
  136. package/dist/components/radios/constants.js +10 -10
  137. package/dist/components/radios/radio.js +161 -161
  138. package/dist/components/radios/radios.js +12 -12
  139. package/dist/components/search/api.js +116 -116
  140. package/dist/components/search/config.js +66 -66
  141. package/dist/components/search/constants.js +75 -75
  142. package/dist/components/search/features/input.js +238 -238
  143. package/dist/components/search/features/states.js +279 -279
  144. package/dist/components/search/features/structure.js +212 -212
  145. package/dist/components/search/features/suggestions.js +234 -234
  146. package/dist/components/search/search.js +30 -30
  147. package/dist/components/select/api.js +92 -92
  148. package/dist/components/select/config.js +46 -46
  149. package/dist/components/select/constants.js +39 -39
  150. package/dist/components/select/features.js +485 -485
  151. package/dist/components/select/select.js +17 -17
  152. package/dist/components/side-sheet/api.js +46 -46
  153. package/dist/components/side-sheet/config.js +19 -19
  154. package/dist/components/side-sheet/constants.js +22 -22
  155. package/dist/components/side-sheet/features/state.js +132 -132
  156. package/dist/components/side-sheet/features/structure.js +89 -89
  157. package/dist/components/side-sheet/side-sheet.js +8 -8
  158. package/dist/components/slider/config.js +54 -54
  159. package/dist/components/slider/constants.js +54 -54
  160. package/dist/components/slider/features/axis.js +14 -14
  161. package/dist/components/slider/features/controller.js +944 -944
  162. package/dist/components/slider/features/dom.js +104 -104
  163. package/dist/components/slider/features/states.js +83 -83
  164. package/dist/components/slider/slider.js +16 -16
  165. package/dist/components/snackbar/api.js +199 -199
  166. package/dist/components/snackbar/config.js +24 -24
  167. package/dist/components/snackbar/constants.js +41 -41
  168. package/dist/components/snackbar/features.js +115 -115
  169. package/dist/components/snackbar/layer.js +72 -72
  170. package/dist/components/snackbar/position.js +20 -20
  171. package/dist/components/snackbar/queue.js +89 -89
  172. package/dist/components/snackbar/snackbar.js +12 -12
  173. package/dist/components/split-button/api.js +137 -137
  174. package/dist/components/split-button/config.js +11 -11
  175. package/dist/components/split-button/constants.js +24 -24
  176. package/dist/components/split-button/features/buttons.js +35 -35
  177. package/dist/components/split-button/features/menu.js +12 -12
  178. package/dist/components/split-button/split-button.js +11 -11
  179. package/dist/components/switch/api.js +101 -101
  180. package/dist/components/switch/config.js +20 -20
  181. package/dist/components/switch/constants.js +29 -29
  182. package/dist/components/switch/features.js +123 -123
  183. package/dist/components/switch/switch.js +13 -13
  184. package/dist/components/tabs/api.js +104 -104
  185. package/dist/components/tabs/config.js +20 -20
  186. package/dist/components/tabs/constants.js +40 -40
  187. package/dist/components/tabs/features.js +159 -159
  188. package/dist/components/tabs/indicator.js +151 -151
  189. package/dist/components/tabs/responsive.js +59 -59
  190. package/dist/components/tabs/tab.js +218 -218
  191. package/dist/components/tabs/tabs.js +27 -27
  192. package/dist/components/tabs/utils.js +121 -121
  193. package/dist/components/text-field/api.js +212 -212
  194. package/dist/components/text-field/config.js +30 -30
  195. package/dist/components/text-field/constants.js +54 -54
  196. package/dist/components/text-field/features/counter.js +51 -51
  197. package/dist/components/text-field/features/density.js +36 -36
  198. package/dist/components/text-field/features/error.js +55 -55
  199. package/dist/components/text-field/features/field.js +30 -30
  200. package/dist/components/text-field/features/leading-icon.js +52 -52
  201. package/dist/components/text-field/features/placement.js +146 -146
  202. package/dist/components/text-field/features/prefix-text.js +48 -48
  203. package/dist/components/text-field/features/required.js +48 -48
  204. package/dist/components/text-field/features/suffix-text.js +48 -48
  205. package/dist/components/text-field/features/supporting-text.js +85 -85
  206. package/dist/components/text-field/features/trailing-icon.js +88 -88
  207. package/dist/components/text-field/text-field.js +11 -11
  208. package/dist/components/timepicker/api.js +275 -275
  209. package/dist/components/timepicker/config.js +31 -31
  210. package/dist/components/timepicker/constants.js +52 -52
  211. package/dist/components/timepicker/dial.js +164 -164
  212. package/dist/components/timepicker/render.js +400 -400
  213. package/dist/components/timepicker/timepicker.js +40 -40
  214. package/dist/components/timepicker/types.js +8 -8
  215. package/dist/components/timepicker/utils.js +67 -67
  216. package/dist/components/toolbar/config.js +35 -35
  217. package/dist/components/toolbar/constants.js +17 -17
  218. package/dist/components/toolbar/toolbar.js +188 -188
  219. package/dist/components/tooltip/api.js +309 -309
  220. package/dist/components/tooltip/config.js +32 -32
  221. package/dist/components/tooltip/constants.js +38 -38
  222. package/dist/components/tooltip/tooltip.js +20 -20
  223. package/dist/components/tooltip/types.js +15 -15
  224. package/dist/components/top-app-bar/config.js +5 -5
  225. package/dist/components/top-app-bar/constants.js +25 -25
  226. package/dist/components/top-app-bar/top-app-bar.js +158 -158
  227. package/dist/core/canvas/animation.js +30 -30
  228. package/dist/core/canvas/drawing.js +52 -52
  229. package/dist/core/canvas/resize.js +47 -47
  230. package/dist/core/canvas/utils.js +101 -101
  231. package/dist/core/compose/base.js +5 -5
  232. package/dist/core/compose/cleanup.js +47 -47
  233. package/dist/core/compose/component.js +132 -132
  234. package/dist/core/compose/features/badge.js +56 -56
  235. package/dist/core/compose/features/checkable.js +37 -37
  236. package/dist/core/compose/features/constants.js +1 -1
  237. package/dist/core/compose/features/debounce.js +39 -39
  238. package/dist/core/compose/features/disabled.js +61 -61
  239. package/dist/core/compose/features/events.js +19 -19
  240. package/dist/core/compose/features/icon.js +66 -66
  241. package/dist/core/compose/features/input.js +63 -63
  242. package/dist/core/compose/features/lifecycle.js +71 -71
  243. package/dist/core/compose/features/position.js +31 -31
  244. package/dist/core/compose/features/ripple.js +76 -76
  245. package/dist/core/compose/features/size.js +5 -5
  246. package/dist/core/compose/features/style.js +7 -7
  247. package/dist/core/compose/features/text.js +49 -49
  248. package/dist/core/compose/features/textinput.js +164 -164
  249. package/dist/core/compose/features/textlabel.js +47 -47
  250. package/dist/core/compose/features/throttle.js +39 -39
  251. package/dist/core/compose/features/track.js +24 -24
  252. package/dist/core/compose/features/variant.js +5 -5
  253. package/dist/core/compose/features/withEvents.js +48 -48
  254. package/dist/core/compose/pipe.js +4 -4
  255. package/dist/core/compose/utils/type-guards.js +6 -6
  256. package/dist/core/config/component.js +54 -54
  257. package/dist/core/config/global.js +6 -6
  258. package/dist/core/config.js +9 -9
  259. package/dist/core/dom/attributes.js +38 -38
  260. package/dist/core/dom/classes.js +74 -74
  261. package/dist/core/dom/create.js +133 -133
  262. package/dist/core/dom/direction.js +28 -28
  263. package/dist/core/dom/events.js +80 -80
  264. package/dist/core/dom/focus.js +38 -38
  265. package/dist/core/dom/form-value.js +10 -10
  266. package/dist/core/dom/html.js +7 -7
  267. package/dist/core/dom/layer.js +134 -134
  268. package/dist/core/dom/roving.js +69 -69
  269. package/dist/core/dom/utils.js +38 -38
  270. package/dist/core/navigation/destinations.js +103 -103
  271. package/dist/core/navigation/ripple.js +39 -39
  272. package/dist/core/shapes/cubic.js +55 -55
  273. package/dist/core/shapes/material.js +164 -164
  274. package/dist/core/shapes/polygon.js +198 -198
  275. package/dist/core/state/emitter.js +29 -29
  276. package/dist/core/state/events.js +30 -30
  277. package/dist/core/state/store.js +55 -55
  278. package/dist/core/theme/tokens.js +28 -28
  279. package/dist/core/utils/attributes.js +8 -8
  280. package/dist/core/utils/background.js +29 -29
  281. package/dist/core/utils/color.js +21 -21
  282. package/dist/core/utils/mobile.js +28 -28
  283. package/dist/core/utils/object.js +17 -17
  284. package/dist/core/utils/performance.js +111 -111
  285. package/dist/core/utils/theme.js +49 -49
  286. package/dist/core/utils/url.js +0 -0
  287. package/dist/core/utils/warn.js +14 -14
  288. package/dist/elements/adapter.js +51 -51
  289. package/dist/elements/badge.js +23 -23
  290. package/dist/elements/bottom-app-bar.js +32 -32
  291. package/dist/elements/bottom-sheet.js +81 -81
  292. package/dist/elements/button-group.js +151 -151
  293. package/dist/elements/button.js +40 -40
  294. package/dist/elements/card.js +89 -89
  295. package/dist/elements/carousel.js +101 -101
  296. package/dist/elements/checkbox.js +44 -44
  297. package/dist/elements/chips.js +185 -185
  298. package/dist/elements/datepicker.js +101 -101
  299. package/dist/elements/define.js +571 -571
  300. package/dist/elements/dialog.js +134 -134
  301. package/dist/elements/divider.js +16 -16
  302. package/dist/elements/drawer.js +118 -118
  303. package/dist/elements/extended-fab.js +29 -29
  304. package/dist/elements/fab-menu.js +58 -58
  305. package/dist/elements/fab.js +18 -18
  306. package/dist/elements/form-button.js +14 -14
  307. package/dist/elements/icon-button.js +42 -42
  308. package/dist/elements/index.js +87 -87
  309. package/dist/elements/lifecycle.js +8 -8
  310. package/dist/elements/list.js +162 -162
  311. package/dist/elements/loading-indicator.js +19 -19
  312. package/dist/elements/menu.js +169 -169
  313. package/dist/elements/navigation-bar.js +58 -58
  314. package/dist/elements/navigation-rail.js +110 -110
  315. package/dist/elements/preupgrade/badge.css +1 -1
  316. package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
  317. package/dist/elements/preupgrade/bottom-sheet.css +1 -1
  318. package/dist/elements/preupgrade/button-group.css +1 -1
  319. package/dist/elements/preupgrade/button.css +1 -1
  320. package/dist/elements/preupgrade/card.css +1 -1
  321. package/dist/elements/preupgrade/carousel.css +1 -1
  322. package/dist/elements/preupgrade/checkbox.css +1 -1
  323. package/dist/elements/preupgrade/chips.css +1 -1
  324. package/dist/elements/preupgrade/datepicker.css +1 -1
  325. package/dist/elements/preupgrade/dialog.css +1 -1
  326. package/dist/elements/preupgrade/divider.css +1 -1
  327. package/dist/elements/preupgrade/drawer.css +1 -1
  328. package/dist/elements/preupgrade/extended-fab.css +1 -1
  329. package/dist/elements/preupgrade/fab-menu.css +1 -1
  330. package/dist/elements/preupgrade/fab.css +1 -1
  331. package/dist/elements/preupgrade/icon-button.css +1 -1
  332. package/dist/elements/preupgrade/list.css +1 -1
  333. package/dist/elements/preupgrade/loading-indicator.css +1 -1
  334. package/dist/elements/preupgrade/menu.css +1 -1
  335. package/dist/elements/preupgrade/navigation-bar.css +1 -1
  336. package/dist/elements/preupgrade/navigation-rail.css +1 -1
  337. package/dist/elements/preupgrade/progress.css +1 -1
  338. package/dist/elements/preupgrade/radios.css +1 -1
  339. package/dist/elements/preupgrade/search.css +1 -1
  340. package/dist/elements/preupgrade/select.css +1 -1
  341. package/dist/elements/preupgrade/side-sheet.css +1 -1
  342. package/dist/elements/preupgrade/slider.css +1 -1
  343. package/dist/elements/preupgrade/snackbar.css +1 -1
  344. package/dist/elements/preupgrade/split-button.css +1 -1
  345. package/dist/elements/preupgrade/switch.css +1 -1
  346. package/dist/elements/preupgrade/tabs.css +1 -1
  347. package/dist/elements/preupgrade/text-field.css +1 -1
  348. package/dist/elements/preupgrade/timepicker.css +1 -1
  349. package/dist/elements/preupgrade/toolbar.css +1 -1
  350. package/dist/elements/preupgrade/tooltip.css +1 -1
  351. package/dist/elements/preupgrade/top-app-bar.css +1 -1
  352. package/dist/elements/preupgrade.css +1 -1
  353. package/dist/elements/preupgrade.js +0 -1
  354. package/dist/elements/progress.js +32 -32
  355. package/dist/elements/radios.js +105 -105
  356. package/dist/elements/search.js +189 -189
  357. package/dist/elements/select.js +124 -124
  358. package/dist/elements/sheet.js +49 -49
  359. package/dist/elements/side-sheet.js +53 -53
  360. package/dist/elements/slider.js +117 -117
  361. package/dist/elements/snackbar.js +45 -45
  362. package/dist/elements/split-button.js +82 -82
  363. package/dist/elements/styles.js +27 -27
  364. package/dist/elements/switch.js +43 -43
  365. package/dist/elements/tabs.js +96 -96
  366. package/dist/elements/text-field.js +117 -117
  367. package/dist/elements/timepicker.js +142 -142
  368. package/dist/elements/toolbar.js +63 -63
  369. package/dist/elements/tooltip.js +111 -111
  370. package/dist/elements/top-app-bar.js +75 -75
  371. package/dist/package.json +1 -1
  372. package/dist/react/create.js +113 -113
  373. package/dist/react/shadow.js +8 -8
  374. package/dist/solid/create.js +122 -122
  375. package/dist/solid/shadow.js +6 -6
  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-lite.css +2 -0
  382. package/dist/styles/base-lite.d.ts +1 -0
  383. package/dist/styles/base-lite.js +2 -0
  384. package/dist/styles/base.css +1 -1
  385. package/dist/styles/bottom-app-bar.css +1 -1
  386. package/dist/styles/bottom-sheet.css +1 -1
  387. package/dist/styles/button-group.css +1 -1
  388. package/dist/styles/button.css +1 -1
  389. package/dist/styles/card.css +1 -1
  390. package/dist/styles/carousel.css +1 -1
  391. package/dist/styles/checkbox.css +1 -1
  392. package/dist/styles/chips.css +1 -1
  393. package/dist/styles/contrast.css +1 -1
  394. package/dist/styles/datepicker.css +1 -1
  395. package/dist/styles/dialog.css +1 -1
  396. package/dist/styles/divider.css +1 -1
  397. package/dist/styles/drawer.css +1 -1
  398. package/dist/styles/extended-fab.css +1 -1
  399. package/dist/styles/fab-menu.css +1 -1
  400. package/dist/styles/fab.css +1 -1
  401. package/dist/styles/icon-button.css +1 -1
  402. package/dist/styles/list.css +1 -1
  403. package/dist/styles/loading-indicator.css +1 -1
  404. package/dist/styles/menu.css +1 -1
  405. package/dist/styles/navigation-bar.css +1 -1
  406. package/dist/styles/navigation-rail.css +1 -1
  407. package/dist/styles/progress.css +1 -1
  408. package/dist/styles/radios.css +1 -1
  409. package/dist/styles/search.css +1 -1
  410. package/dist/styles/select.css +1 -1
  411. package/dist/styles/side-sheet.css +1 -1
  412. package/dist/styles/slider.css +1 -1
  413. package/dist/styles/snackbar.css +1 -1
  414. package/dist/styles/split-button.css +1 -1
  415. package/dist/styles/switch.css +1 -1
  416. package/dist/styles/tabs.css +1 -1
  417. package/dist/styles/text-field.css +1 -1
  418. package/dist/styles/timepicker.css +1 -1
  419. package/dist/styles/toolbar.css +1 -1
  420. package/dist/styles/tooltip.css +1 -1
  421. package/dist/styles/top-app-bar.css +1 -1
  422. package/dist/styles/typography.css +1 -1
  423. package/dist/styles/utilities.css +1 -1
  424. package/dist/styles.css +1 -1
  425. package/dist/themes/autumn-contrast.css +1 -1
  426. package/dist/themes/autumn.css +1 -1
  427. package/dist/themes/baseline-contrast.css +1 -1
  428. package/dist/themes/baseline.css +1 -1
  429. package/dist/themes/brownbeige-contrast.css +1 -1
  430. package/dist/themes/brownbeige.css +1 -1
  431. package/dist/themes/content-contrast.css +1 -1
  432. package/dist/themes/content.css +1 -1
  433. package/dist/themes/desert-contrast.css +1 -1
  434. package/dist/themes/desert.css +1 -1
  435. package/dist/themes/expressive-contrast.css +1 -1
  436. package/dist/themes/expressive.css +1 -1
  437. package/dist/themes/fidelity-contrast.css +1 -1
  438. package/dist/themes/fidelity.css +1 -1
  439. package/dist/themes/forest-contrast.css +1 -1
  440. package/dist/themes/forest.css +1 -1
  441. package/dist/themes/fruit-salad-contrast.css +1 -1
  442. package/dist/themes/fruit-salad.css +1 -1
  443. package/dist/themes/highcontrast-contrast.css +1 -1
  444. package/dist/themes/highcontrast.css +1 -1
  445. package/dist/themes/monochrome-contrast.css +1 -1
  446. package/dist/themes/monochrome.css +1 -1
  447. package/dist/themes/neutral-contrast.css +1 -1
  448. package/dist/themes/neutral.css +1 -1
  449. package/dist/themes/ocean-contrast.css +1 -1
  450. package/dist/themes/ocean.css +1 -1
  451. package/dist/themes/rainbow-contrast.css +1 -1
  452. package/dist/themes/rainbow.css +1 -1
  453. package/dist/themes/sageivory-contrast.css +1 -1
  454. package/dist/themes/sageivory.css +1 -1
  455. package/dist/themes/spring-contrast.css +1 -1
  456. package/dist/themes/spring.css +1 -1
  457. package/dist/themes/summer-contrast.css +1 -1
  458. package/dist/themes/summer.css +1 -1
  459. package/dist/themes/sunset-contrast.css +1 -1
  460. package/dist/themes/sunset.css +1 -1
  461. package/dist/themes/tealcaramel-contrast.css +1 -1
  462. package/dist/themes/tealcaramel.css +1 -1
  463. package/dist/themes/vibrant-contrast.css +1 -1
  464. package/dist/themes/vibrant.css +1 -1
  465. package/dist/vue/create.js +123 -123
  466. package/dist/vue/shadow.js +6 -6
  467. package/package.json +2 -1
  468. package/src/styles/abstract/_mixins.scss +21 -0
  469. package/src/styles/base/_body-theme.scss +22 -0
  470. package/src/styles/base/_document.scss +4 -14
  471. package/src/styles/base/_reset.scss +3 -14
@@ -3,321 +3,321 @@ import createChip from "../chip/chip.js";
3
3
  import { CHIPS_EVENTS } from "../constants.js";
4
4
  import { activeElementOf } from "../../../core/dom/focus.js";
5
5
  export const withController = (config) => (component) => {
6
- const eventListeners = {
7
- change: [],
8
- add: [],
9
- remove: [],
10
- };
11
- let focusedChipIndex = -1;
12
- let keyboardEnabled = true;
13
- const dispatchEvent = (eventName, ...args) => {
14
- if (eventListeners[eventName]) {
15
- eventListeners[eventName].forEach((handler) => handler(...args));
16
- }
17
- };
18
- const selectionValue = (values) => {
19
- const selected = values.filter((value) => value !== null);
20
- return config.multiSelect ? selected : (selected[0] ?? null);
21
- };
22
- const changeEvent = (values, changed) => {
23
- return { value: selectionValue(values), selected: values, changed };
24
- };
25
- const currentValue = () => selectionValue(getSelectedValues());
26
- const selectSingle = (selectedChip) => {
27
- if (config.multiSelect)
28
- return;
29
- component.chipInstances.forEach((chip) => {
30
- if (chip !== selectedChip && chip.isSelected())
31
- chip.setSelected(false);
32
- });
33
- };
34
- const handleSelection = (selectedChip) => {
35
- if (selectedChip.isSelected())
36
- selectSingle(selectedChip);
37
- if (config.selectionRequired && !selectedChip.isSelected() && getSelectedChips().length === 0) {
38
- selectedChip.setSelected(true);
39
- return true;
40
- }
41
- const selectedChips = component.chipInstances.filter((chip) => chip.isSelected());
42
- const selectedValues = selectedChips.map((chip) => chip.getValue());
43
- const changedValue = selectedChip ? selectedChip.getValue() : null;
44
- dispatchEvent(CHIPS_EVENTS.CHANGE, changeEvent(selectedValues, changedValue));
45
- };
46
- const targets = () => component.chipInstances
47
- .filter((chip) => !chip.isDisabled())
48
- .flatMap((chip) => chip.element.hasAttribute("tabindex")
49
- ? [chip.element]
50
- : Array.from(chip.element.querySelectorAll(":scope > button")));
51
- let current = null;
52
- const syncTabStop = () => {
53
- const list = targets();
54
- if (!current || !list.includes(current))
55
- current = list[0] ?? null;
56
- for (const chip of component.chipInstances) {
57
- if (chip.element.hasAttribute("tabindex"))
58
- chip.element.tabIndex = -1;
59
- chip.element.querySelectorAll(":scope > button").forEach((button) => { button.tabIndex = -1; });
60
- }
61
- if (current)
62
- current.tabIndex = 0;
63
- };
64
- const handleKeyboardNavigation = (event) => {
65
- if (!keyboardEnabled)
66
- return;
67
- const list = targets();
68
- if (list.length === 0)
69
- return;
70
- const isVertical = !!(component.layout && component.layout.isVertical());
71
- const rtl = component.element.matches(":dir(rtl)");
72
- const back = isVertical ? "ArrowUp" : rtl ? "ArrowRight" : "ArrowLeft";
73
- const forward = isVertical ? "ArrowDown" : rtl ? "ArrowLeft" : "ArrowRight";
74
- const from = list.indexOf(event.target);
75
- let next;
76
- if (event.key === back)
77
- next = Math.max(0, from - 1);
78
- else if (event.key === forward)
79
- next = Math.min(list.length - 1, from + 1);
80
- else if (event.key === "Home")
81
- next = 0;
82
- else if (event.key === "End")
83
- next = list.length - 1;
84
- else
85
- return;
86
- event.preventDefault();
87
- event.stopPropagation();
88
- if (from === -1)
89
- next = 0;
90
- current = list[next];
91
- syncTabStop();
92
- current.focus();
93
- const owner = component.chipInstances.findIndex((chip) => chip.element.contains(current));
94
- if (owner >= 0) {
95
- focusedChipIndex = owner;
96
- if (component.layout && component.layout.isScrollable())
97
- scrollToChip(owner);
98
- }
99
- };
100
- const scrollToChip = (chipOrIndex) => {
101
- const isScrollable = component.layout && component.layout.isScrollable();
102
- if (!isScrollable)
103
- return;
104
- const index = typeof chipOrIndex === "number"
105
- ? chipOrIndex
106
- : component.chipInstances.indexOf(chipOrIndex);
107
- if (index >= 0 && index < component.chipInstances.length) {
108
- const chipElement = component.chipInstances[index].element;
109
- const container = component.chipContainer || component.element;
110
- const containerRect = container.getBoundingClientRect();
111
- const chipRect = chipElement.getBoundingClientRect();
112
- const isVertical = component.layout && component.layout.isVertical();
113
- if (isVertical) {
114
- const scrollTop = chipElement.offsetTop -
115
- container.offsetTop -
116
- containerRect.height / 2 +
117
- chipRect.height / 2;
118
- container.scrollTo({
119
- top: Math.max(0, scrollTop),
120
- });
121
- }
122
- else {
123
- const scrollLeft = chipElement.offsetLeft -
124
- container.offsetLeft -
125
- containerRect.width / 2 +
126
- chipRect.width / 2;
127
- container.scrollTo({
128
- left: Math.max(0, scrollLeft),
129
- });
130
- }
131
- }
132
- };
133
- const unlist = (index) => {
134
- const chips = component.chipInstances;
135
- const chip = chips[index];
136
- const hadFocus = chip.element.contains(activeElementOf(chip.element));
137
- chip.element.removeEventListener("keydown", handleKeyboardNavigation);
138
- chips.splice(index, 1);
139
- if (index === focusedChipIndex)
140
- focusedChipIndex = -1;
141
- else if (index < focusedChipIndex)
142
- focusedChipIndex--;
143
- syncTabStop();
144
- if (!hadFocus)
145
- return;
146
- let next = Math.min(index, chips.length - 1);
147
- while (next >= 0 && chips[next].isDisabled())
148
- next--;
149
- if (next < 0)
150
- next = chips.findIndex(candidate => !candidate.isDisabled());
151
- if (next >= 0) {
152
- focusedChipIndex = next;
153
- chips[next].focus();
154
- }
155
- };
156
- let tearingDown = false;
157
- const watchChipDestroy = (chip) => {
158
- const destroy = chip.destroy.bind(chip);
159
- chip.destroy = () => {
160
- const index = tearingDown ? -1 : component.chipInstances.indexOf(chip);
161
- if (index >= 0)
162
- unlist(index);
163
- destroy();
164
- };
165
- };
166
- const addChip = (chipConfig) => {
167
- const chipInstance = createChip({
168
- ...chipConfig,
169
- managedSelection: true,
170
- onSelected: selectSingle,
171
- cell: true,
172
- onRemoved: removeChip,
173
- });
174
- const container = component.chipContainer || component.element;
175
- const fragment = document.createDocumentFragment();
176
- fragment.appendChild(chipInstance.element);
177
- container.appendChild(fragment);
178
- component.chipInstances.push(chipInstance);
179
- if (chipInstance.isSelected())
180
- selectSingle(chipInstance);
181
- chipInstance.on("click", () => {
182
- if (!chipInstance.isDisabled() && ["filter", "input"].includes(chipInstance.getType())) {
183
- chipInstance.toggleSelected();
184
- if (!handleSelection(chipInstance))
185
- chipConfig.onSelect?.(chipInstance);
186
- focusedChipIndex = component.chipInstances.indexOf(chipInstance);
187
- }
188
- });
189
- chipInstance.on("focus", () => {
190
- focusedChipIndex = component.chipInstances.indexOf(chipInstance);
191
- });
192
- chipInstance.element.addEventListener("keydown", handleKeyboardNavigation);
193
- syncTabStop();
194
- watchChipDestroy(chipInstance);
195
- dispatchEvent(CHIPS_EVENTS.ADD, { value: currentValue(), chip: chipInstance });
196
- return chipInstance;
197
- };
198
- const removeChip = (chipOrIndex) => {
199
- const index = typeof chipOrIndex === "number"
200
- ? chipOrIndex
201
- : component.chipInstances.indexOf(chipOrIndex);
202
- if (index >= 0 && index < component.chipInstances.length) {
203
- const chip = component.chipInstances[index];
204
- const chipValue = chip.getValue();
205
- unlist(index);
206
- chip.destroy();
207
- dispatchEvent(CHIPS_EVENTS.REMOVE, { value: currentValue(), chip, chipValue });
208
- }
209
- };
210
- const getChips = () => {
211
- return [...component.chipInstances];
212
- };
213
- const getSelectedChips = () => {
214
- return component.chipInstances.filter((chip) => chip.isSelected());
215
- };
216
- const getSelectedValues = () => {
217
- return getSelectedChips().map((chip) => chip.getValue());
218
- };
219
- const selectByValue = (values, triggerEvent = false, exclusive = !config.multiSelect) => {
220
- const valueArray = Array.isArray(values) ? values : [values];
221
- let selectionChanged = false;
222
- if (exclusive) {
223
- component.chipInstances.forEach((chip) => {
224
- const chipValue = chip.getValue();
225
- const shouldSelect = chipValue !== null && valueArray.includes(chipValue);
226
- if (!shouldSelect && chip.isSelected()) {
227
- chip.setSelected(false);
228
- selectionChanged = true;
229
- }
230
- });
231
- }
232
- component.chipInstances.forEach((chip) => {
233
- const chipValue = chip.getValue();
234
- const shouldSelect = chipValue !== null && valueArray.includes(chipValue);
235
- if (shouldSelect && !chip.isSelected()) {
236
- chip.setSelected(true);
237
- selectionChanged = true;
238
- }
239
- });
240
- if (selectionChanged && triggerEvent) {
241
- const selectedValues = getSelectedValues();
242
- dispatchEvent(CHIPS_EVENTS.CHANGE, changeEvent(selectedValues, null));
243
- }
244
- };
245
- const clearSelection = (triggerEvent = false) => {
246
- const selectedValues = getSelectedValues();
247
- const hadSelectedChips = selectedValues.length > 0;
248
- component.chipInstances.forEach((chip) => {
249
- chip.setSelected(false);
250
- });
251
- if (hadSelectedChips && triggerEvent) {
252
- dispatchEvent(CHIPS_EVENTS.CHANGE, changeEvent([], null));
253
- }
254
- };
255
- const enableKeyboardNavigation = () => {
256
- keyboardEnabled = true;
257
- component.chipInstances.forEach((chip) => {
258
- chip.element.addEventListener("keydown", handleKeyboardNavigation);
259
- });
260
- };
261
- const disableKeyboardNavigation = () => {
262
- keyboardEnabled = false;
263
- component.chipInstances.forEach((chip) => {
264
- chip.element.removeEventListener("keydown", handleKeyboardNavigation);
265
- });
266
- };
267
- enableKeyboardNavigation();
268
- const trackFocus = (event) => {
269
- const target = event.target;
270
- if (targets().includes(target)) {
271
- current = target;
272
- syncTabStop();
273
- }
274
- };
275
- if (component.element) {
276
- component.element.addEventListener("keydown", handleKeyboardNavigation);
277
- component.element.addEventListener("focusin", trackFocus);
278
- }
279
- getCleanup(component).add(() => {
280
- tearingDown = true;
281
- component.element.removeEventListener("keydown", handleKeyboardNavigation);
282
- component.element.removeEventListener("focusin", trackFocus);
283
- component.chipInstances.forEach(chip => {
284
- chip.element.removeEventListener("keydown", handleKeyboardNavigation);
285
- chip.destroy();
286
- });
287
- component.chipInstances.length = 0;
288
- Object.keys(eventListeners).forEach(event => { eventListeners[event].length = 0; });
289
- });
290
- return {
291
- ...component,
292
- chips: {
293
- addChip,
294
- removeChip,
295
- getChips,
296
- getSelectedChips,
297
- getSelectedValues,
298
- selectByValue,
299
- clearSelection,
300
- scrollToChip,
301
- },
302
- keyboard: {
303
- enable: enableKeyboardNavigation,
304
- disable: disableKeyboardNavigation,
305
- },
306
- on(event, handler) {
307
- if (!eventListeners[event]) {
308
- eventListeners[event] = [];
309
- }
310
- eventListeners[event].push(handler);
311
- return this;
312
- },
313
- off(event, handler) {
314
- if (eventListeners[event]) {
315
- const index = eventListeners[event].indexOf(handler);
316
- if (index !== -1) {
317
- eventListeners[event].splice(index, 1);
318
- }
319
- }
320
- return this;
321
- },
322
- };
6
+ const eventListeners = {
7
+ change: [],
8
+ add: [],
9
+ remove: [],
10
+ };
11
+ let focusedChipIndex = -1;
12
+ let keyboardEnabled = true;
13
+ const dispatchEvent = (eventName, ...args) => {
14
+ if (eventListeners[eventName]) {
15
+ eventListeners[eventName].forEach((handler) => handler(...args));
16
+ }
17
+ };
18
+ const selectionValue = (values) => {
19
+ const selected = values.filter((value) => value !== null);
20
+ return config.multiSelect ? selected : (selected[0] ?? null);
21
+ };
22
+ const changeEvent = (values, changed) => {
23
+ return { value: selectionValue(values), selected: values, changed };
24
+ };
25
+ const currentValue = () => selectionValue(getSelectedValues());
26
+ const selectSingle = (selectedChip) => {
27
+ if (config.multiSelect)
28
+ return;
29
+ component.chipInstances.forEach((chip) => {
30
+ if (chip !== selectedChip && chip.isSelected())
31
+ chip.setSelected(false);
32
+ });
33
+ };
34
+ const handleSelection = (selectedChip) => {
35
+ if (selectedChip.isSelected())
36
+ selectSingle(selectedChip);
37
+ if (config.selectionRequired && !selectedChip.isSelected() && getSelectedChips().length === 0) {
38
+ selectedChip.setSelected(true);
39
+ return true;
40
+ }
41
+ const selectedChips = component.chipInstances.filter((chip) => chip.isSelected());
42
+ const selectedValues = selectedChips.map((chip) => chip.getValue());
43
+ const changedValue = selectedChip ? selectedChip.getValue() : null;
44
+ dispatchEvent(CHIPS_EVENTS.CHANGE, changeEvent(selectedValues, changedValue));
45
+ };
46
+ const targets = () => component.chipInstances
47
+ .filter((chip) => !chip.isDisabled())
48
+ .flatMap((chip) => chip.element.hasAttribute("tabindex")
49
+ ? [chip.element]
50
+ : Array.from(chip.element.querySelectorAll(":scope > button")));
51
+ let current = null;
52
+ const syncTabStop = () => {
53
+ const list = targets();
54
+ if (!current || !list.includes(current))
55
+ current = list[0] ?? null;
56
+ for (const chip of component.chipInstances) {
57
+ if (chip.element.hasAttribute("tabindex"))
58
+ chip.element.tabIndex = -1;
59
+ chip.element.querySelectorAll(":scope > button").forEach((button) => { button.tabIndex = -1; });
60
+ }
61
+ if (current)
62
+ current.tabIndex = 0;
63
+ };
64
+ const handleKeyboardNavigation = (event) => {
65
+ if (!keyboardEnabled)
66
+ return;
67
+ const list = targets();
68
+ if (list.length === 0)
69
+ return;
70
+ const isVertical = !!(component.layout && component.layout.isVertical());
71
+ const rtl = component.element.matches(":dir(rtl)");
72
+ const back = isVertical ? "ArrowUp" : rtl ? "ArrowRight" : "ArrowLeft";
73
+ const forward = isVertical ? "ArrowDown" : rtl ? "ArrowLeft" : "ArrowRight";
74
+ const from = list.indexOf(event.target);
75
+ let next;
76
+ if (event.key === back)
77
+ next = Math.max(0, from - 1);
78
+ else if (event.key === forward)
79
+ next = Math.min(list.length - 1, from + 1);
80
+ else if (event.key === "Home")
81
+ next = 0;
82
+ else if (event.key === "End")
83
+ next = list.length - 1;
84
+ else
85
+ return;
86
+ event.preventDefault();
87
+ event.stopPropagation();
88
+ if (from === -1)
89
+ next = 0;
90
+ current = list[next];
91
+ syncTabStop();
92
+ current.focus();
93
+ const owner = component.chipInstances.findIndex((chip) => chip.element.contains(current));
94
+ if (owner >= 0) {
95
+ focusedChipIndex = owner;
96
+ if (component.layout && component.layout.isScrollable())
97
+ scrollToChip(owner);
98
+ }
99
+ };
100
+ const scrollToChip = (chipOrIndex) => {
101
+ const isScrollable = component.layout && component.layout.isScrollable();
102
+ if (!isScrollable)
103
+ return;
104
+ const index = typeof chipOrIndex === "number"
105
+ ? chipOrIndex
106
+ : component.chipInstances.indexOf(chipOrIndex);
107
+ if (index >= 0 && index < component.chipInstances.length) {
108
+ const chipElement = component.chipInstances[index].element;
109
+ const container = component.chipContainer || component.element;
110
+ const containerRect = container.getBoundingClientRect();
111
+ const chipRect = chipElement.getBoundingClientRect();
112
+ const isVertical = component.layout && component.layout.isVertical();
113
+ if (isVertical) {
114
+ const scrollTop = chipElement.offsetTop -
115
+ container.offsetTop -
116
+ containerRect.height / 2 +
117
+ chipRect.height / 2;
118
+ container.scrollTo({
119
+ top: Math.max(0, scrollTop),
120
+ });
121
+ }
122
+ else {
123
+ const scrollLeft = chipElement.offsetLeft -
124
+ container.offsetLeft -
125
+ containerRect.width / 2 +
126
+ chipRect.width / 2;
127
+ container.scrollTo({
128
+ left: Math.max(0, scrollLeft),
129
+ });
130
+ }
131
+ }
132
+ };
133
+ const unlist = (index) => {
134
+ const chips = component.chipInstances;
135
+ const chip = chips[index];
136
+ const hadFocus = chip.element.contains(activeElementOf(chip.element));
137
+ chip.element.removeEventListener("keydown", handleKeyboardNavigation);
138
+ chips.splice(index, 1);
139
+ if (index === focusedChipIndex)
140
+ focusedChipIndex = -1;
141
+ else if (index < focusedChipIndex)
142
+ focusedChipIndex--;
143
+ syncTabStop();
144
+ if (!hadFocus)
145
+ return;
146
+ let next = Math.min(index, chips.length - 1);
147
+ while (next >= 0 && chips[next].isDisabled())
148
+ next--;
149
+ if (next < 0)
150
+ next = chips.findIndex(candidate => !candidate.isDisabled());
151
+ if (next >= 0) {
152
+ focusedChipIndex = next;
153
+ chips[next].focus();
154
+ }
155
+ };
156
+ let tearingDown = false;
157
+ const watchChipDestroy = (chip) => {
158
+ const destroy = chip.destroy.bind(chip);
159
+ chip.destroy = () => {
160
+ const index = tearingDown ? -1 : component.chipInstances.indexOf(chip);
161
+ if (index >= 0)
162
+ unlist(index);
163
+ destroy();
164
+ };
165
+ };
166
+ const addChip = (chipConfig) => {
167
+ const chipInstance = createChip({
168
+ ...chipConfig,
169
+ managedSelection: true,
170
+ onSelected: selectSingle,
171
+ cell: true,
172
+ onRemoved: removeChip,
173
+ });
174
+ const container = component.chipContainer || component.element;
175
+ const fragment = document.createDocumentFragment();
176
+ fragment.appendChild(chipInstance.element);
177
+ container.appendChild(fragment);
178
+ component.chipInstances.push(chipInstance);
179
+ if (chipInstance.isSelected())
180
+ selectSingle(chipInstance);
181
+ chipInstance.on("click", () => {
182
+ if (!chipInstance.isDisabled() && ["filter", "input"].includes(chipInstance.getType())) {
183
+ chipInstance.toggleSelected();
184
+ if (!handleSelection(chipInstance))
185
+ chipConfig.onSelect?.(chipInstance);
186
+ focusedChipIndex = component.chipInstances.indexOf(chipInstance);
187
+ }
188
+ });
189
+ chipInstance.on("focus", () => {
190
+ focusedChipIndex = component.chipInstances.indexOf(chipInstance);
191
+ });
192
+ chipInstance.element.addEventListener("keydown", handleKeyboardNavigation);
193
+ syncTabStop();
194
+ watchChipDestroy(chipInstance);
195
+ dispatchEvent(CHIPS_EVENTS.ADD, { value: currentValue(), chip: chipInstance });
196
+ return chipInstance;
197
+ };
198
+ const removeChip = (chipOrIndex) => {
199
+ const index = typeof chipOrIndex === "number"
200
+ ? chipOrIndex
201
+ : component.chipInstances.indexOf(chipOrIndex);
202
+ if (index >= 0 && index < component.chipInstances.length) {
203
+ const chip = component.chipInstances[index];
204
+ const chipValue = chip.getValue();
205
+ unlist(index);
206
+ chip.destroy();
207
+ dispatchEvent(CHIPS_EVENTS.REMOVE, { value: currentValue(), chip, chipValue });
208
+ }
209
+ };
210
+ const getChips = () => {
211
+ return [...component.chipInstances];
212
+ };
213
+ const getSelectedChips = () => {
214
+ return component.chipInstances.filter((chip) => chip.isSelected());
215
+ };
216
+ const getSelectedValues = () => {
217
+ return getSelectedChips().map((chip) => chip.getValue());
218
+ };
219
+ const selectByValue = (values, triggerEvent = false, exclusive = !config.multiSelect) => {
220
+ const valueArray = Array.isArray(values) ? values : [values];
221
+ let selectionChanged = false;
222
+ if (exclusive) {
223
+ component.chipInstances.forEach((chip) => {
224
+ const chipValue = chip.getValue();
225
+ const shouldSelect = chipValue !== null && valueArray.includes(chipValue);
226
+ if (!shouldSelect && chip.isSelected()) {
227
+ chip.setSelected(false);
228
+ selectionChanged = true;
229
+ }
230
+ });
231
+ }
232
+ component.chipInstances.forEach((chip) => {
233
+ const chipValue = chip.getValue();
234
+ const shouldSelect = chipValue !== null && valueArray.includes(chipValue);
235
+ if (shouldSelect && !chip.isSelected()) {
236
+ chip.setSelected(true);
237
+ selectionChanged = true;
238
+ }
239
+ });
240
+ if (selectionChanged && triggerEvent) {
241
+ const selectedValues = getSelectedValues();
242
+ dispatchEvent(CHIPS_EVENTS.CHANGE, changeEvent(selectedValues, null));
243
+ }
244
+ };
245
+ const clearSelection = (triggerEvent = false) => {
246
+ const selectedValues = getSelectedValues();
247
+ const hadSelectedChips = selectedValues.length > 0;
248
+ component.chipInstances.forEach((chip) => {
249
+ chip.setSelected(false);
250
+ });
251
+ if (hadSelectedChips && triggerEvent) {
252
+ dispatchEvent(CHIPS_EVENTS.CHANGE, changeEvent([], null));
253
+ }
254
+ };
255
+ const enableKeyboardNavigation = () => {
256
+ keyboardEnabled = true;
257
+ component.chipInstances.forEach((chip) => {
258
+ chip.element.addEventListener("keydown", handleKeyboardNavigation);
259
+ });
260
+ };
261
+ const disableKeyboardNavigation = () => {
262
+ keyboardEnabled = false;
263
+ component.chipInstances.forEach((chip) => {
264
+ chip.element.removeEventListener("keydown", handleKeyboardNavigation);
265
+ });
266
+ };
267
+ enableKeyboardNavigation();
268
+ const trackFocus = (event) => {
269
+ const target = event.target;
270
+ if (targets().includes(target)) {
271
+ current = target;
272
+ syncTabStop();
273
+ }
274
+ };
275
+ if (component.element) {
276
+ component.element.addEventListener("keydown", handleKeyboardNavigation);
277
+ component.element.addEventListener("focusin", trackFocus);
278
+ }
279
+ getCleanup(component).add(() => {
280
+ tearingDown = true;
281
+ component.element.removeEventListener("keydown", handleKeyboardNavigation);
282
+ component.element.removeEventListener("focusin", trackFocus);
283
+ component.chipInstances.forEach(chip => {
284
+ chip.element.removeEventListener("keydown", handleKeyboardNavigation);
285
+ chip.destroy();
286
+ });
287
+ component.chipInstances.length = 0;
288
+ Object.keys(eventListeners).forEach(event => { eventListeners[event].length = 0; });
289
+ });
290
+ return {
291
+ ...component,
292
+ chips: {
293
+ addChip,
294
+ removeChip,
295
+ getChips,
296
+ getSelectedChips,
297
+ getSelectedValues,
298
+ selectByValue,
299
+ clearSelection,
300
+ scrollToChip,
301
+ },
302
+ keyboard: {
303
+ enable: enableKeyboardNavigation,
304
+ disable: disableKeyboardNavigation,
305
+ },
306
+ on(event, handler) {
307
+ if (!eventListeners[event]) {
308
+ eventListeners[event] = [];
309
+ }
310
+ eventListeners[event].push(handler);
311
+ return this;
312
+ },
313
+ off(event, handler) {
314
+ if (eventListeners[event]) {
315
+ const index = eventListeners[event].indexOf(handler);
316
+ if (index !== -1) {
317
+ eventListeners[event].splice(index, 1);
318
+ }
319
+ }
320
+ return this;
321
+ },
322
+ };
323
323
  };