mtrl 0.9.8 → 0.10.0-next.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 (357) hide show
  1. package/dist/components/badge/api.d.ts +14 -20
  2. package/dist/components/badge/api.js +4 -5
  3. package/dist/components/badge/config.d.ts +549 -17
  4. package/dist/components/badge/config.js +7 -0
  5. package/dist/components/badge/features.d.ts +9 -7
  6. package/dist/components/badge/features.js +13 -12
  7. package/dist/components/badge/types.d.ts +38 -0
  8. package/dist/components/bottom-app-bar/bottom-app-bar.js +6 -2
  9. package/dist/components/bottom-app-bar/constants.d.ts +2 -2
  10. package/dist/components/bottom-app-bar/constants.js +2 -2
  11. package/dist/components/bottom-app-bar/types.d.ts +4 -4
  12. package/dist/components/bottom-sheet/config.d.ts +531 -17
  13. package/dist/components/bottom-sheet/constants.d.ts +6 -6
  14. package/dist/components/bottom-sheet/constants.js +6 -6
  15. package/dist/components/bottom-sheet/features/structure.d.ts +3 -3
  16. package/dist/components/button/api.d.ts +3 -2
  17. package/dist/components/button/api.js +1 -1
  18. package/dist/components/button/button.d.ts +2 -2
  19. package/dist/components/button/config.d.ts +531 -17
  20. package/dist/components/button/constants.d.ts +2 -2
  21. package/dist/components/button/constants.js +2 -2
  22. package/dist/components/button/features/progress.js +4 -4
  23. package/dist/components/button/types.d.ts +50 -6
  24. package/dist/components/button-group/button-group.js +5 -5
  25. package/dist/components/button-group/config.d.ts +64 -25
  26. package/dist/components/button-group/types.d.ts +24 -2
  27. package/dist/components/card/config.d.ts +532 -18
  28. package/dist/components/card/features.js +10 -8
  29. package/dist/components/card/types.d.ts +10 -0
  30. package/dist/components/carousel/config.d.ts +531 -17
  31. package/dist/components/checkbox/config.d.ts +531 -17
  32. package/dist/components/checkbox/config.js +1 -1
  33. package/dist/components/checkbox/constants.d.ts +3 -3
  34. package/dist/components/checkbox/constants.js +3 -3
  35. package/dist/components/checkbox/types.d.ts +10 -0
  36. package/dist/components/chips/api.d.ts +12 -3
  37. package/dist/components/chips/chip/config.d.ts +534 -20
  38. package/dist/components/chips/config.d.ts +562 -53
  39. package/dist/components/chips/config.js +10 -8
  40. package/dist/components/chips/features/chip-items.d.ts +33 -2
  41. package/dist/components/chips/features/container.d.ts +68 -1
  42. package/dist/components/chips/features/container.js +1 -1
  43. package/dist/components/chips/features/controller.d.ts +53 -2
  44. package/dist/components/chips/features/controller.js +2 -6
  45. package/dist/components/chips/features/dom.js +2 -2
  46. package/dist/components/chips/features/label.d.ts +69 -1
  47. package/dist/components/chips/features/label.js +2 -2
  48. package/dist/components/chips/schema.d.ts +8 -6
  49. package/dist/components/chips/schema.js +2 -2
  50. package/dist/components/chips/types.d.ts +49 -0
  51. package/dist/components/datepicker/config.d.ts +1596 -54
  52. package/dist/components/datepicker/datepicker.js +6 -5
  53. package/dist/components/dialog/api.d.ts +6 -1
  54. package/dist/components/dialog/api.js +1 -1
  55. package/dist/components/dialog/config.d.ts +549 -63
  56. package/dist/components/dialog/constants.d.ts +9 -9
  57. package/dist/components/dialog/constants.js +9 -9
  58. package/dist/components/dialog/features.d.ts +18 -8
  59. package/dist/components/dialog/features.js +44 -42
  60. package/dist/components/dialog/types.d.ts +77 -0
  61. package/dist/components/divider/features.d.ts +4 -4
  62. package/dist/components/divider/types.d.ts +31 -13
  63. package/dist/components/drawer/config.d.ts +533 -19
  64. package/dist/components/drawer/drawer.d.ts +2 -2
  65. package/dist/components/extended-fab/config.d.ts +531 -17
  66. package/dist/components/extended-fab/constants.d.ts +2 -2
  67. package/dist/components/extended-fab/constants.js +2 -2
  68. package/dist/components/fab/config.d.ts +533 -19
  69. package/dist/components/fab/config.js +7 -6
  70. package/dist/components/fab/constants.d.ts +1 -1
  71. package/dist/components/fab/constants.js +1 -1
  72. package/dist/components/fab/fab.d.ts +1 -1
  73. package/dist/components/fab/fab.js +1 -1
  74. package/dist/components/fab/types.d.ts +6 -1
  75. package/dist/components/icon-button/config.d.ts +534 -20
  76. package/dist/components/icon-button/config.js +8 -7
  77. package/dist/components/icon-button/icon-button.d.ts +1 -1
  78. package/dist/components/icon-button/icon-button.js +1 -1
  79. package/dist/components/icon-button/types.d.ts +6 -1
  80. package/dist/components/index.d.ts +0 -2
  81. package/dist/components/index.js +0 -2
  82. package/dist/components/list/api.d.ts +865 -13
  83. package/dist/components/list/api.js +18 -18
  84. package/dist/components/list/config.d.ts +589 -42
  85. package/dist/components/list/config.js +3 -2
  86. package/dist/components/list/features/renderer.d.ts +4 -1
  87. package/dist/components/list/features/renderer.js +3 -8
  88. package/dist/components/list/features/selection.d.ts +2 -1
  89. package/dist/components/list/features/selection.js +42 -32
  90. package/dist/components/list/list.d.ts +4 -22
  91. package/dist/components/list/list.js +0 -1
  92. package/dist/components/list/types.d.ts +103 -0
  93. package/dist/components/loading-indicator/config.d.ts +531 -17
  94. package/dist/components/menu/api.d.ts +5 -1
  95. package/dist/components/menu/config.d.ts +535 -47
  96. package/dist/components/menu/config.js +9 -11
  97. package/dist/components/menu/features/controller.d.ts +4 -2
  98. package/dist/components/menu/features/controller.js +26 -46
  99. package/dist/components/menu/features/keyboard.d.ts +3 -19
  100. package/dist/components/menu/features/keyboard.js +11 -11
  101. package/dist/components/menu/features/opener.d.ts +8 -2
  102. package/dist/components/menu/features/opener.js +1 -5
  103. package/dist/components/menu/features/position.d.ts +3 -3
  104. package/dist/components/menu/features/submenu.d.ts +20 -2
  105. package/dist/components/menu/features/submenu.js +4 -11
  106. package/dist/components/menu/features/tasks.d.ts +1 -1
  107. package/dist/components/menu/types.d.ts +131 -0
  108. package/dist/components/navigation-rail/navigation-rail.js +2 -1
  109. package/dist/components/navigation-rail/types.d.ts +10 -0
  110. package/dist/components/progress/api.js +3 -2
  111. package/dist/components/progress/config.d.ts +567 -29
  112. package/dist/components/progress/config.js +9 -15
  113. package/dist/components/progress/features/canvas.js +1 -1
  114. package/dist/components/progress/features/state.d.ts +2 -3
  115. package/dist/components/progress/features/state.js +2 -1
  116. package/dist/components/radios/config.d.ts +537 -21
  117. package/dist/components/radios/radio.d.ts +19 -2
  118. package/dist/components/radios/radio.js +18 -13
  119. package/dist/components/search/config.d.ts +548 -34
  120. package/dist/components/search/features/input.d.ts +85 -2
  121. package/dist/components/search/features/states.d.ts +99 -2
  122. package/dist/components/search/features/structure.d.ts +10 -2
  123. package/dist/components/search/features/suggestions.d.ts +53 -1
  124. package/dist/components/segmented-button/config.d.ts +5 -5
  125. package/dist/components/segmented-button/segment.js +1 -1
  126. package/dist/components/segmented-button/segmented-button.js +20 -7
  127. package/dist/components/select/features.js +26 -4
  128. package/dist/components/select/types.d.ts +2 -2
  129. package/dist/components/side-sheet/config.d.ts +531 -17
  130. package/dist/components/side-sheet/constants.d.ts +8 -8
  131. package/dist/components/side-sheet/constants.js +8 -8
  132. package/dist/components/side-sheet/features/structure.d.ts +3 -3
  133. package/dist/components/slider/api.d.ts +10 -6
  134. package/dist/components/slider/config.d.ts +570 -56
  135. package/dist/components/slider/config.js +7 -6
  136. package/dist/components/slider/features/controller.d.ts +520 -2
  137. package/dist/components/slider/features/controller.js +9 -11
  138. package/dist/components/slider/features/dom.js +5 -5
  139. package/dist/components/slider/features/handlers.d.ts +11 -20
  140. package/dist/components/slider/features/handlers.js +21 -18
  141. package/dist/components/slider/features/range.d.ts +7 -1
  142. package/dist/components/slider/features/range.js +3 -3
  143. package/dist/components/slider/features/states.d.ts +71 -1
  144. package/dist/components/slider/features/tracks.d.ts +28 -2
  145. package/dist/components/slider/features/tracks.js +9 -9
  146. package/dist/components/slider/types.d.ts +135 -0
  147. package/dist/components/snackbar/config.d.ts +531 -17
  148. package/dist/components/snackbar/constants.d.ts +3 -3
  149. package/dist/components/snackbar/constants.js +3 -3
  150. package/dist/components/snackbar/index.d.ts +1 -1
  151. package/dist/components/snackbar/types.d.ts +27 -4
  152. package/dist/components/split-button/api.js +2 -2
  153. package/dist/components/split-button/config.d.ts +531 -17
  154. package/dist/components/switch/config.d.ts +531 -17
  155. package/dist/components/switch/constants.d.ts +8 -8
  156. package/dist/components/switch/constants.js +8 -8
  157. package/dist/components/switch/features.js +8 -8
  158. package/dist/components/switch/types.d.ts +10 -0
  159. package/dist/components/tabs/api.d.ts +6 -9
  160. package/dist/components/tabs/api.js +14 -3
  161. package/dist/components/tabs/config.d.ts +3 -18
  162. package/dist/components/tabs/config.js +1 -12
  163. package/dist/components/tabs/constants.d.ts +3 -3
  164. package/dist/components/tabs/constants.js +3 -3
  165. package/dist/components/tabs/features.d.ts +5 -3
  166. package/dist/components/tabs/features.js +5 -3
  167. package/dist/components/tabs/indicator.js +4 -4
  168. package/dist/components/tabs/scroll-indicators.js +11 -11
  169. package/dist/components/tabs/tab.d.ts +13 -0
  170. package/dist/components/tabs/tab.js +5 -13
  171. package/dist/components/tabs/types.d.ts +20 -6
  172. package/dist/components/tabs/utils.d.ts +31 -1
  173. package/dist/components/tabs/utils.js +44 -29
  174. package/dist/components/textfield/config.d.ts +536 -20
  175. package/dist/components/textfield/config.js +3 -3
  176. package/dist/components/textfield/constants.d.ts +5 -5
  177. package/dist/components/textfield/constants.js +5 -5
  178. package/dist/components/textfield/features/density.d.ts +1 -1
  179. package/dist/components/textfield/features/leading-icon.d.ts +16 -2
  180. package/dist/components/textfield/features/leading-icon.js +1 -1
  181. package/dist/components/textfield/features/placement.js +3 -3
  182. package/dist/components/textfield/features/prefix-text.d.ts +16 -2
  183. package/dist/components/textfield/features/prefix-text.js +1 -1
  184. package/dist/components/textfield/features/suffix-text.d.ts +16 -2
  185. package/dist/components/textfield/features/suffix-text.js +1 -1
  186. package/dist/components/textfield/features/supporting-text.js +2 -2
  187. package/dist/components/textfield/features/trailing-icon.d.ts +16 -2
  188. package/dist/components/textfield/features/trailing-icon.js +1 -1
  189. package/dist/components/textfield/types.d.ts +10 -0
  190. package/dist/components/timepicker/api.d.ts +2 -2
  191. package/dist/components/timepicker/api.js +3 -1
  192. package/dist/components/timepicker/clockdial.js +7 -8
  193. package/dist/components/timepicker/config.d.ts +1602 -60
  194. package/dist/components/timepicker/render.d.ts +2 -2
  195. package/dist/components/timepicker/render.js +44 -29
  196. package/dist/components/timepicker/types.d.ts +11 -0
  197. package/dist/components/tooltip/config.d.ts +534 -19
  198. package/dist/components/tooltip/constants.d.ts +1 -1
  199. package/dist/components/tooltip/constants.js +1 -1
  200. package/dist/components/tooltip/tooltip.d.ts +2 -2
  201. package/dist/components/top-app-bar/constants.d.ts +6 -6
  202. package/dist/components/top-app-bar/constants.js +6 -6
  203. package/dist/components/top-app-bar/top-app-bar.js +11 -7
  204. package/dist/components/top-app-bar/types.d.ts +5 -5
  205. package/dist/core/compose/component.d.ts +5 -3
  206. package/dist/core/compose/component.js +1 -1
  207. package/dist/core/compose/features/events.d.ts +3 -3
  208. package/dist/core/compose/features/icon.js +1 -1
  209. package/dist/core/compose/features/input.d.ts +18 -5
  210. package/dist/core/compose/features/input.js +2 -1
  211. package/dist/core/compose/features/text.js +1 -1
  212. package/dist/core/compose/features/textinput.d.ts +22 -8
  213. package/dist/core/compose/features/textinput.js +2 -1
  214. package/dist/core/compose/features/textlabel.js +1 -1
  215. package/dist/core/compose/features/track.js +3 -3
  216. package/dist/core/compose/features/withEvents.d.ts +2 -2
  217. package/dist/core/compose/features/withEvents.js +8 -2
  218. package/dist/core/config/component.d.ts +546 -42
  219. package/dist/core/config/component.js +3 -11
  220. package/dist/core/config/global.d.ts +0 -22
  221. package/dist/core/config.d.ts +0 -33
  222. package/dist/core/config.js +1 -58
  223. package/dist/core/dom/attributes.js +9 -3
  224. package/dist/core/dom/classes.js +8 -26
  225. package/dist/core/dom/create.d.ts +11 -1
  226. package/dist/core/dom/create.js +3 -7
  227. package/dist/core/dom/utils.js +2 -1
  228. package/dist/core/index.d.ts +1 -5
  229. package/dist/core/index.js +1 -3
  230. package/dist/core/state/index.d.ts +0 -4
  231. package/dist/core/state/index.js +0 -2
  232. package/dist/core/utils/attributes.d.ts +29 -0
  233. package/dist/core/utils/attributes.js +11 -0
  234. package/dist/core/utils/warn.d.ts +8 -0
  235. package/dist/core/utils/warn.js +15 -0
  236. package/dist/index.cjs +0 -0
  237. package/dist/package.json +1 -1
  238. package/dist/styles/badge.css +2 -2
  239. package/dist/styles/base.css +2 -2
  240. package/dist/styles/bottom-app-bar.css +2 -2
  241. package/dist/styles/bottom-sheet.css +2 -2
  242. package/dist/styles/button-group.css +2 -2
  243. package/dist/styles/button.css +2 -2
  244. package/dist/styles/card.css +2 -2
  245. package/dist/styles/carousel.css +2 -2
  246. package/dist/styles/checkbox.css +2 -2
  247. package/dist/styles/chips.css +2 -2
  248. package/dist/styles/dialog.css +2 -2
  249. package/dist/styles/divider.css +2 -2
  250. package/dist/styles/drawer.css +2 -2
  251. package/dist/styles/extended-fab.css +2 -2
  252. package/dist/styles/fab.css +2 -2
  253. package/dist/styles/icon-button.css +2 -2
  254. package/dist/styles/list.css +2 -2
  255. package/dist/styles/loading-indicator.css +2 -2
  256. package/dist/styles/menu.css +2 -2
  257. package/dist/styles/navigation-rail.css +2 -2
  258. package/dist/styles/progress.css +2 -2
  259. package/dist/styles/radios.css +2 -2
  260. package/dist/styles/search.css +2 -2
  261. package/dist/styles/segmented-button.css +2 -2
  262. package/dist/styles/select.css +2 -2
  263. package/dist/styles/side-sheet.css +2 -2
  264. package/dist/styles/slider.css +2 -2
  265. package/dist/styles/snackbar.css +2 -2
  266. package/dist/styles/split-button.css +2 -2
  267. package/dist/styles/switch.css +2 -2
  268. package/dist/styles/tabs.css +2 -2
  269. package/dist/styles/textfield.css +2 -2
  270. package/dist/styles/timepicker.css +2 -2
  271. package/dist/styles/tooltip.css +2 -2
  272. package/dist/styles/top-app-bar.css +2 -2
  273. package/dist/styles/utilities.css +2 -2
  274. package/dist/styles.css +2 -2
  275. package/dist/themes/autumn.css +1 -1
  276. package/dist/themes/baseline.css +1 -1
  277. package/dist/themes/brownbeige.css +1 -1
  278. package/dist/themes/browngreen.css +1 -1
  279. package/dist/themes/desert.css +1 -1
  280. package/dist/themes/forest.css +1 -1
  281. package/dist/themes/highcontrast.css +1 -1
  282. package/dist/themes/legacy.css +1 -1
  283. package/dist/themes/material.css +1 -1
  284. package/dist/themes/ocean.css +1 -1
  285. package/dist/themes/sageivory.css +1 -1
  286. package/dist/themes/spring.css +1 -1
  287. package/dist/themes/summer.css +1 -1
  288. package/dist/themes/sunset.css +1 -1
  289. package/dist/themes/tealcaramel.css +1 -1
  290. package/dist/themes/winter.css +1 -1
  291. package/package.json +5 -1
  292. package/src/styles/components/_badge.scss +1 -1
  293. package/src/styles/components/_bottom-app-bar.scss +5 -5
  294. package/src/styles/components/_bottom-sheet.scss +17 -17
  295. package/src/styles/components/_button-group.scss +2 -2
  296. package/src/styles/components/_button.scss +12 -12
  297. package/src/styles/components/_checkbox.scss +25 -25
  298. package/src/styles/components/_chips.scss +5 -5
  299. package/src/styles/components/_dialog.scss +36 -36
  300. package/src/styles/components/_extended-fab.scss +7 -7
  301. package/src/styles/components/_fab.scss +4 -4
  302. package/src/styles/components/_icon-button.scss +5 -5
  303. package/src/styles/components/_menu.scss +25 -25
  304. package/src/styles/components/_progress.scss +1 -1
  305. package/src/styles/components/_radios.scss +18 -18
  306. package/src/styles/components/_segmented-button.scss +6 -6
  307. package/src/styles/components/_select.scss +22 -22
  308. package/src/styles/components/_side-sheet.scss +20 -20
  309. package/src/styles/components/_slider.scss +20 -20
  310. package/src/styles/components/_snackbar.scss +7 -7
  311. package/src/styles/components/_split-button.scss +1 -1
  312. package/src/styles/components/_switch.scss +36 -36
  313. package/src/styles/components/_tabs.scss +31 -20
  314. package/src/styles/components/_textfield.scss +153 -153
  315. package/src/styles/components/_timepicker.scss +24 -8
  316. package/src/styles/components/_top-app-bar.scss +20 -20
  317. package/src/styles/main.scss +0 -1
  318. package/dist/components/navigation/api.d.ts +0 -8
  319. package/dist/components/navigation/api.js +0 -117
  320. package/dist/components/navigation/config.d.ts +0 -45
  321. package/dist/components/navigation/config.js +0 -39
  322. package/dist/components/navigation/constants.d.ts +0 -137
  323. package/dist/components/navigation/constants.js +0 -65
  324. package/dist/components/navigation/features/controller.d.ts +0 -28
  325. package/dist/components/navigation/features/controller.js +0 -173
  326. package/dist/components/navigation/features/items.d.ts +0 -32
  327. package/dist/components/navigation/features/items.js +0 -236
  328. package/dist/components/navigation/index.d.ts +0 -3
  329. package/dist/components/navigation/index.js +0 -2
  330. package/dist/components/navigation/nav-item.d.ts +0 -30
  331. package/dist/components/navigation/nav-item.js +0 -119
  332. package/dist/components/navigation/navigation.d.ts +0 -8
  333. package/dist/components/navigation/navigation.js +0 -52
  334. package/dist/components/navigation/system/core.d.ts +0 -72
  335. package/dist/components/navigation/system/core.js +0 -148
  336. package/dist/components/navigation/system/events.d.ts +0 -35
  337. package/dist/components/navigation/system/events.js +0 -126
  338. package/dist/components/navigation/system/index.d.ts +0 -10
  339. package/dist/components/navigation/system/index.js +0 -92
  340. package/dist/components/navigation/system/mobile.d.ts +0 -52
  341. package/dist/components/navigation/system/mobile.js +0 -140
  342. package/dist/components/navigation/system/state.d.ts +0 -22
  343. package/dist/components/navigation/system/state.js +0 -44
  344. package/dist/components/navigation/system/types.d.ts +0 -337
  345. package/dist/components/navigation/system/types.js +0 -1
  346. package/dist/components/navigation/types.d.ts +0 -225
  347. package/dist/components/navigation/types.js +0 -33
  348. package/dist/core/state/disabled.d.ts +0 -32
  349. package/dist/core/state/disabled.js +0 -26
  350. package/dist/core/state/lifecycle.d.ts +0 -56
  351. package/dist/core/state/lifecycle.js +0 -51
  352. package/dist/styles/navigation.css +0 -2
  353. package/dist/styles/navigation.d.ts +0 -1
  354. package/dist/styles/navigation.js +0 -2
  355. package/src/styles/components/_navigation-mobile.scss +0 -244
  356. package/src/styles/components/_navigation-system.scss +0 -153
  357. package/src/styles/components/_navigation.scss +0 -407
@@ -1,36 +1,38 @@
1
- import { BadgeConfig } from "./types.js";
1
+ import { BadgeConfig, BadgeFeatureHost, BadgeVisibility } from "./types.js";
2
2
  /**
3
3
  * Higher-order function that adds visibility control features to a component
4
4
  * @returns {Function} Component enhancer with visibility features
5
5
  */
6
- export declare const withVisibility: () => (component: any) => any;
6
+ export declare const withVisibility: () => <C extends BadgeFeatureHost>(component: C) => C & {
7
+ visibility: BadgeVisibility;
8
+ };
7
9
  /**
8
10
  * Higher-order function that adds variant features to a badge component
9
11
  * @param {BadgeConfig} config - Badge configuration
10
12
  * @returns {Function} Component enhancer with variant features
11
13
  */
12
- export declare const withVariant: (config: BadgeConfig) => (component: any) => any;
14
+ export declare const withVariant: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
13
15
  /**
14
16
  * Higher-order function that adds color features to a badge component
15
17
  * @param {BadgeConfig} config - Badge configuration
16
18
  * @returns {Function} Component enhancer with color features
17
19
  */
18
- export declare const withColor: (config: BadgeConfig) => (component: any) => any;
20
+ export declare const withColor: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
19
21
  /**
20
22
  * Higher-order function that adds positioning features to a badge component
21
23
  * @param {BadgeConfig} config - Badge configuration
22
24
  * @returns {Function} Component enhancer with positioning features
23
25
  */
24
- export declare const withPosition: (config: BadgeConfig) => (component: any) => any;
26
+ export declare const withPosition: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
25
27
  /**
26
28
  * Higher-order function that adds max value features to a badge component
27
29
  * @param {BadgeConfig} config - Badge configuration
28
30
  * @returns {Function} Component enhancer with max value features
29
31
  */
30
- export declare const withMax: (config: BadgeConfig) => (component: any) => any;
32
+ export declare const withMax: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
31
33
  /**
32
34
  * Higher-order function that attaches badge to a target element
33
35
  * @param {BadgeConfig} config - Badge configuration
34
36
  * @returns {Function} Component enhancer with attachment features
35
37
  */
36
- export declare const withAttachment: (config: BadgeConfig) => (component: any) => any;
38
+ export declare const withAttachment: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
@@ -1,11 +1,12 @@
1
- import { formatBadgeLabel } from "./config.js";
1
+ import { formatBadgeLabel, isBadgeOverflow, isEmptyBadgeLabel } from "./config.js";
2
2
  const VARIANT_SMALL = 'small';
3
3
  const VARIANT_LARGE = 'large';
4
4
  const COLOR_ERROR = 'error';
5
5
  const POSITION_TOP_RIGHT = 'top-right';
6
- export const withVisibility = () => component => {
6
+ export const withVisibility = () => (component) => {
7
7
  const visible = component.config.visible !== false;
8
- if (!visible) {
8
+ const nothingToShow = isEmptyBadgeLabel(formatBadgeLabel(component.config.label ?? "", component.config.max));
9
+ if (!visible || nothingToShow) {
9
10
  component.element.classList.add(`${component.getClass('badge')}--invisible`);
10
11
  }
11
12
  return {
@@ -34,7 +35,7 @@ export const withVisibility = () => component => {
34
35
  }
35
36
  };
36
37
  };
37
- export const withVariant = (config) => component => {
38
+ export const withVariant = (config) => (component) => {
38
39
  const variant = config.variant || VARIANT_LARGE;
39
40
  component.element.classList.add(`${component.getClass('badge')}--${variant}`);
40
41
  if (variant === VARIANT_SMALL) {
@@ -50,39 +51,39 @@ export const withVariant = (config) => component => {
50
51
  }
51
52
  return component;
52
53
  };
53
- export const withColor = (config) => component => {
54
+ export const withColor = (config) => (component) => {
54
55
  const color = config.color || COLOR_ERROR;
55
56
  component.element.classList.add(`${component.getClass('badge')}--${color}`);
56
57
  return component;
57
58
  };
58
- export const withPosition = (config) => component => {
59
+ export const withPosition = (config) => (component) => {
59
60
  const position = config.position || POSITION_TOP_RIGHT;
60
61
  component.element.classList.add(`${component.getClass('badge')}--${position}`);
61
- if (config.target) {
62
+ if (config.target && config.target.parentNode) {
62
63
  component.element.classList.add(`${component.getClass('badge')}--positioned`);
63
64
  }
64
65
  return component;
65
66
  };
66
- export const withMax = (config) => component => {
67
+ export const withMax = (config) => (component) => {
67
68
  if (config.max === undefined || config.variant === VARIANT_SMALL) {
68
69
  return component;
69
70
  }
70
71
  component.config.max = config.max;
71
- if (config.label !== undefined && config.label !== '') {
72
+ if (config.label !== undefined) {
72
73
  const formattedLabel = formatBadgeLabel(config.label, config.max);
73
74
  component.element.textContent = formattedLabel;
74
- if (typeof config.label === 'number' && config.label > config.max) {
75
+ if (isBadgeOverflow(config.label, config.max)) {
75
76
  component.element.classList.add(`${component.getClass('badge')}--overflow`);
76
77
  }
77
78
  }
78
79
  return component;
79
80
  };
80
- export const withAttachment = (config) => component => {
81
+ export const withAttachment = (config) => (component) => {
81
82
  if (!config.target) {
82
83
  return component;
83
84
  }
84
85
  const wrapper = document.createElement('div');
85
- wrapper.classList.add(component.getClass('badge-wrapper'));
86
+ wrapper.classList.add(component.getClass('badge__wrapper'));
86
87
  wrapper.style.position = 'relative';
87
88
  const parent = config.target.parentNode;
88
89
  if (parent) {
@@ -1,3 +1,4 @@
1
+ import { ElementComponent } from "../../core/compose/component.js";
1
2
  /**
2
3
  * Badge variant types - determines the badge size and appearance
3
4
  * @category Components
@@ -96,6 +97,43 @@ export interface BadgeConfig {
96
97
  */
97
98
  componentName?: string;
98
99
  }
100
+ /**
101
+ * The visibility control withVisibility installs on a badge.
102
+ *
103
+ * Named because three places need the same shape: the feature that builds it,
104
+ * getApiConfig that forwards it, and withAPI that wraps it.
105
+ *
106
+ * @category Components
107
+ * @internal
108
+ */
109
+ export interface BadgeVisibility {
110
+ /** Shows the badge */
111
+ show: () => void;
112
+ /** Hides the badge */
113
+ hide: () => void;
114
+ /** Toggles badge visibility, or forces it when given a flag */
115
+ toggle: (visible?: boolean) => void;
116
+ /** Whether the badge is currently visible */
117
+ isVisible: () => boolean;
118
+ }
119
+ /**
120
+ * What a badge feature enhancer needs from the component it is handed.
121
+ *
122
+ * The badge pipe is createBase, withEvents, withElement, then these features --
123
+ * so the element half is installed before any of them runs, which is why
124
+ * `element` and `getClass` are required rather than optional.
125
+ *
126
+ * `config` is the badge's own config: createBase keeps the type it was created
127
+ * with, so a feature reading `config.variant` gets BadgeVariant and not
128
+ * `unknown`. `wrapper` is written by withAttachment, not read by it.
129
+ *
130
+ * @category Components
131
+ * @internal
132
+ */
133
+ export interface BadgeFeatureHost extends ElementComponent {
134
+ config: BadgeConfig & Record<string, unknown>;
135
+ wrapper?: HTMLElement;
136
+ }
99
137
  /**
100
138
  * Badge component interface
101
139
  * Provides methods for controlling a Material Design 3 badge
@@ -4,9 +4,9 @@ export const createBottomAppBar = (config = {}) => {
4
4
  const componentConfig = createConfig(config);
5
5
  const component = createBase(componentConfig);
6
6
  const actionsContainer = document.createElement("div");
7
- actionsContainer.className = `${component.getClass("bottom-app-bar")}-actions`;
7
+ actionsContainer.className = `${component.getClass("bottom-app-bar")}__actions`;
8
8
  const fabContainer = document.createElement("div");
9
- fabContainer.className = `${component.getClass("bottom-app-bar")}-fab-container`;
9
+ fabContainer.className = `${component.getClass("bottom-app-bar")}__fab-container`;
10
10
  const enhancedComponent = withElement({
11
11
  tag: componentConfig.tag,
12
12
  componentName: "bottom-app-bar",
@@ -55,6 +55,10 @@ export const createBottomAppBar = (config = {}) => {
55
55
  }
56
56
  const bottomBar = {
57
57
  ...withLifecycleComponent,
58
+ addClass(...classes) {
59
+ withLifecycleComponent.addClass(...classes);
60
+ return this;
61
+ },
58
62
  destroy() {
59
63
  withLifecycleComponent.lifecycle.destroy();
60
64
  },
@@ -14,8 +14,8 @@ export declare const DEFAULT_TRANSITION_DURATION = 300;
14
14
  */
15
15
  export declare const BOTTOM_APP_BAR_CLASSES: {
16
16
  readonly ROOT: "bottom-app-bar";
17
- readonly ACTIONS: "bottom-app-bar-actions";
18
- readonly FAB_CONTAINER: "bottom-app-bar-fab";
17
+ readonly ACTIONS: "bottom-app-bar__actions";
18
+ readonly FAB_CONTAINER: "bottom-app-bar__fab-container";
19
19
  readonly HIDDEN: "bottom-app-bar--hidden";
20
20
  readonly FAB_CENTER: "bottom-app-bar--fab-center";
21
21
  readonly FAB_END: "bottom-app-bar--fab-end";
@@ -5,8 +5,8 @@ export const FAB_POSITIONS = {
5
5
  export const DEFAULT_TRANSITION_DURATION = 300;
6
6
  export const BOTTOM_APP_BAR_CLASSES = {
7
7
  ROOT: 'bottom-app-bar',
8
- ACTIONS: 'bottom-app-bar-actions',
9
- FAB_CONTAINER: 'bottom-app-bar-fab',
8
+ ACTIONS: 'bottom-app-bar__actions',
9
+ FAB_CONTAINER: 'bottom-app-bar__fab-container',
10
10
  HIDDEN: 'bottom-app-bar--hidden',
11
11
  FAB_CENTER: 'bottom-app-bar--fab-center',
12
12
  FAB_END: 'bottom-app-bar--fab-end'
@@ -66,23 +66,23 @@ export interface BottomAppBar extends ElementComponent {
66
66
  * @param {HTMLElement} button - Button element to add
67
67
  * @returns {BottomAppBar} BottomAppBar instance for chaining
68
68
  */
69
- addAction: (button: HTMLElement) => BottomAppBar;
69
+ addAction(button: HTMLElement): this;
70
70
  /**
71
71
  * Adds a floating action button to the bottom bar
72
72
  * @param {HTMLElement} fab - FAB element to add
73
73
  * @returns {BottomAppBar} BottomAppBar instance for chaining
74
74
  */
75
- addFab: (fab: HTMLElement) => BottomAppBar;
75
+ addFab(fab: HTMLElement): this;
76
76
  /**
77
77
  * Shows the bottom bar
78
78
  * @returns {BottomAppBar} BottomAppBar instance for chaining
79
79
  */
80
- show: () => BottomAppBar;
80
+ show(): this;
81
81
  /**
82
82
  * Hides the bottom bar
83
83
  * @returns {BottomAppBar} BottomAppBar instance for chaining
84
84
  */
85
- hide: () => BottomAppBar;
85
+ hide(): this;
86
86
  /**
87
87
  * Checks if the bottom bar is visible
88
88
  * @returns {boolean} Whether the bottom bar is visible