@shortfuse/materialdesignweb 0.8.0 → 0.9.1

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 (405) hide show
  1. package/README.md +50 -198
  2. package/bin/mdw-css.js +1 -1
  3. package/components/Badge.js +15 -5
  4. package/components/Body.js +7 -0
  5. package/components/BottomAppBar.js +7 -10
  6. package/components/BottomSheet.js +472 -0
  7. package/components/Box.js +11 -49
  8. package/components/Button.js +81 -82
  9. package/components/Card.js +74 -62
  10. package/components/Checkbox.js +15 -25
  11. package/components/CheckboxIcon.js +19 -31
  12. package/components/Chip.js +18 -13
  13. package/components/Dialog.js +70 -100
  14. package/components/DialogActions.js +4 -0
  15. package/components/Display.js +64 -0
  16. package/components/Divider.js +5 -0
  17. package/components/Fab.js +94 -17
  18. package/components/FabContainer.js +57 -0
  19. package/components/FilterChip.js +43 -32
  20. package/components/Grid.js +187 -0
  21. package/components/Headline.js +9 -28
  22. package/components/Icon.js +80 -71
  23. package/components/IconButton.js +77 -120
  24. package/components/Input.js +745 -86
  25. package/components/InputChip.js +193 -0
  26. package/components/Label.js +7 -0
  27. package/components/List.js +11 -5
  28. package/components/ListItem.js +92 -23
  29. package/components/ListOption.js +143 -65
  30. package/components/Listbox.js +57 -17
  31. package/components/Menu.js +39 -27
  32. package/components/MenuItem.js +49 -36
  33. package/components/NavBar.js +66 -21
  34. package/components/NavBarItem.js +5 -0
  35. package/components/NavDrawer.js +33 -16
  36. package/components/NavDrawerItem.js +7 -4
  37. package/components/NavItem.js +61 -34
  38. package/components/NavRail.js +32 -21
  39. package/components/NavRailItem.js +10 -2
  40. package/components/Page.js +119 -0
  41. package/components/Pane.js +24 -0
  42. package/components/Popup.js +23 -8
  43. package/components/Progress.js +25 -5
  44. package/components/Radio.js +8 -7
  45. package/components/RadioIcon.js +24 -15
  46. package/components/Ripple.js +25 -7
  47. package/components/Root.js +225 -0
  48. package/components/Scrim.js +95 -0
  49. package/components/Search.js +30 -25
  50. package/components/SegmentedButton.js +53 -40
  51. package/components/SegmentedButtonGroup.js +15 -12
  52. package/components/Select.js +19 -10
  53. package/components/Shape.js +10 -66
  54. package/components/SideSheet.js +337 -0
  55. package/components/Slider.js +93 -36
  56. package/components/Snackbar.js +52 -20
  57. package/components/SnackbarContainer.js +51 -0
  58. package/components/Surface.js +20 -10
  59. package/components/Switch.js +21 -18
  60. package/components/SwitchIcon.js +62 -33
  61. package/components/Tab.js +78 -38
  62. package/components/TabContent.js +33 -12
  63. package/components/TabList.js +95 -34
  64. package/components/TabPanel.js +10 -1
  65. package/components/Table.js +151 -0
  66. package/components/TextArea.js +48 -16
  67. package/components/Title.js +8 -9
  68. package/components/Tooltip.js +51 -22
  69. package/components/TopAppBar.js +71 -78
  70. package/constants/shapes.js +36 -0
  71. package/constants/typography.js +127 -0
  72. package/core/Composition.js +391 -201
  73. package/core/CompositionAdapter.js +35 -18
  74. package/core/CustomElement.js +634 -254
  75. package/core/css.js +117 -12
  76. package/core/customTypes.js +161 -49
  77. package/core/dom.js +18 -11
  78. package/core/jsonMergePatch.js +27 -11
  79. package/core/observe.js +308 -256
  80. package/core/optimizations.js +9 -9
  81. package/core/template.js +14 -57
  82. package/dist/CustomElement.min.js +2 -0
  83. package/dist/CustomElement.min.js.map +7 -0
  84. package/dist/core/CustomElement.min.js +2 -0
  85. package/dist/core/CustomElement.min.js.map +7 -0
  86. package/dist/index.min.js +85 -115
  87. package/dist/index.min.js.map +4 -4
  88. package/dist/meta.json +1 -1
  89. package/dom/HTMLOptionsCollectionProxy.js +108 -0
  90. package/{theming/themableMixinLoader.js → loaders/palette.js} +4 -3
  91. package/loaders/theme.js +12 -0
  92. package/mixins/AriaReflectorMixin.js +64 -15
  93. package/mixins/AriaToolbarMixin.js +6 -0
  94. package/mixins/ControlMixin.js +79 -33
  95. package/mixins/DelegatesFocusMixin.js +62 -0
  96. package/mixins/DensityMixin.js +7 -3
  97. package/mixins/ElevationMixin.js +61 -0
  98. package/mixins/FlexableMixin.js +87 -39
  99. package/mixins/FormAssociatedMixin.js +76 -10
  100. package/mixins/HyperlinkMixin.js +76 -0
  101. package/mixins/InputMixin.js +227 -32
  102. package/mixins/KeyboardNavMixin.js +11 -7
  103. package/mixins/NavigationListenerMixin.js +33 -0
  104. package/mixins/PopupMixin.js +216 -219
  105. package/mixins/RTLObserverMixin.js +2 -0
  106. package/mixins/ResizeObserverMixin.js +18 -4
  107. package/mixins/RippleMixin.js +11 -7
  108. package/mixins/ScrollListenerMixin.js +14 -2
  109. package/mixins/SemiStickyMixin.js +51 -98
  110. package/mixins/ShapeMaskedMixin.js +125 -0
  111. package/mixins/ShapeMixin.js +30 -203
  112. package/mixins/StateMixin.js +74 -34
  113. package/mixins/TextFieldMixin.js +128 -145
  114. package/mixins/ThemableMixin.js +57 -56
  115. package/mixins/TooltipTriggerMixin.js +305 -359
  116. package/mixins/TouchTargetMixin.js +5 -2
  117. package/mixins/TypographyMixin.js +128 -0
  118. package/package.json +125 -81
  119. package/services/rtl.js +10 -0
  120. package/services/svgAlias.js +17 -0
  121. package/{theming/index.js → services/theme.js} +25 -176
  122. package/types/bin/mdw-css.d.ts +3 -0
  123. package/types/bin/mdw-css.d.ts.map +1 -0
  124. package/types/components/Badge.d.ts +39 -0
  125. package/types/components/Badge.d.ts.map +1 -0
  126. package/types/components/Body.d.ts +29 -0
  127. package/types/components/Body.d.ts.map +1 -0
  128. package/types/components/BottomAppBar.d.ts +72 -0
  129. package/types/components/BottomAppBar.d.ts.map +1 -0
  130. package/types/components/BottomSheet.d.ts +135 -0
  131. package/types/components/BottomSheet.d.ts.map +1 -0
  132. package/types/components/Box.d.ts +16 -0
  133. package/types/components/Box.d.ts.map +1 -0
  134. package/types/components/Button.d.ts +245 -0
  135. package/types/components/Button.d.ts.map +1 -0
  136. package/types/components/Card.d.ts +147 -0
  137. package/types/components/Card.d.ts.map +1 -0
  138. package/types/components/Checkbox.d.ts +207 -0
  139. package/types/components/Checkbox.d.ts.map +1 -0
  140. package/types/components/CheckboxIcon.d.ts +44 -0
  141. package/types/components/CheckboxIcon.d.ts.map +1 -0
  142. package/types/components/Chip.d.ts +248 -0
  143. package/types/components/Chip.d.ts.map +1 -0
  144. package/types/components/Dialog.d.ts +103 -0
  145. package/types/components/Dialog.d.ts.map +1 -0
  146. package/types/components/DialogActions.d.ts +4 -0
  147. package/types/components/DialogActions.d.ts.map +1 -0
  148. package/types/components/Display.d.ts +46 -0
  149. package/types/components/Display.d.ts.map +1 -0
  150. package/types/components/Divider.d.ts +10 -0
  151. package/types/components/Divider.d.ts.map +1 -0
  152. package/types/components/Fab.d.ts +273 -0
  153. package/types/components/Fab.d.ts.map +1 -0
  154. package/types/components/FabContainer.d.ts +10 -0
  155. package/types/components/FabContainer.d.ts.map +1 -0
  156. package/types/components/FilterChip.d.ts +256 -0
  157. package/types/components/FilterChip.d.ts.map +1 -0
  158. package/types/components/Grid.d.ts +38 -0
  159. package/types/components/Grid.d.ts.map +1 -0
  160. package/types/components/Headline.d.ts +46 -0
  161. package/types/components/Headline.d.ts.map +1 -0
  162. package/types/components/Icon.d.ts +55 -0
  163. package/types/components/Icon.d.ts.map +1 -0
  164. package/types/components/IconButton.d.ts +284 -0
  165. package/types/components/IconButton.d.ts.map +1 -0
  166. package/types/components/Input.d.ts +2528 -0
  167. package/types/components/Input.d.ts.map +1 -0
  168. package/types/components/InputChip.d.ts +85 -0
  169. package/types/components/InputChip.d.ts.map +1 -0
  170. package/types/components/Label.d.ts +29 -0
  171. package/types/components/Label.d.ts.map +1 -0
  172. package/types/components/List.d.ts +35 -0
  173. package/types/components/List.d.ts.map +1 -0
  174. package/types/components/ListItem.d.ts +124 -0
  175. package/types/components/ListItem.d.ts.map +1 -0
  176. package/types/components/ListOption.d.ts +158 -0
  177. package/types/components/ListOption.d.ts.map +1 -0
  178. package/types/components/Listbox.d.ts +763 -0
  179. package/types/components/Listbox.d.ts.map +1 -0
  180. package/types/components/Menu.d.ts +130 -0
  181. package/types/components/Menu.d.ts.map +1 -0
  182. package/types/components/MenuItem.d.ts +232 -0
  183. package/types/components/MenuItem.d.ts.map +1 -0
  184. package/types/components/NavBar.d.ts +20 -0
  185. package/types/components/NavBar.d.ts.map +1 -0
  186. package/types/components/NavBarItem.d.ts +97 -0
  187. package/types/components/NavBarItem.d.ts.map +1 -0
  188. package/types/components/NavDrawer.d.ts +107 -0
  189. package/types/components/NavDrawer.d.ts.map +1 -0
  190. package/types/components/NavDrawerItem.d.ts +97 -0
  191. package/types/components/NavDrawerItem.d.ts.map +1 -0
  192. package/types/components/NavItem.d.ts +99 -0
  193. package/types/components/NavItem.d.ts.map +1 -0
  194. package/types/components/NavRail.d.ts +108 -0
  195. package/types/components/NavRail.d.ts.map +1 -0
  196. package/types/components/NavRailItem.d.ts +97 -0
  197. package/types/components/NavRailItem.d.ts.map +1 -0
  198. package/types/components/Page.d.ts +25 -0
  199. package/types/components/Page.d.ts.map +1 -0
  200. package/types/components/Pane.d.ts +44 -0
  201. package/types/components/Pane.d.ts.map +1 -0
  202. package/types/components/Popup.d.ts +78 -0
  203. package/types/components/Popup.d.ts.map +1 -0
  204. package/types/components/Progress.d.ts +21 -0
  205. package/types/components/Progress.d.ts.map +1 -0
  206. package/types/components/Radio.d.ts +201 -0
  207. package/types/components/Radio.d.ts.map +1 -0
  208. package/types/components/RadioIcon.d.ts +46 -0
  209. package/types/components/RadioIcon.d.ts.map +1 -0
  210. package/types/components/Ripple.d.ts +35 -0
  211. package/types/components/Ripple.d.ts.map +1 -0
  212. package/types/components/Root.d.ts +68 -0
  213. package/types/components/Root.d.ts.map +1 -0
  214. package/types/components/Scrim.d.ts +6 -0
  215. package/types/components/Scrim.d.ts.map +1 -0
  216. package/types/components/Search.d.ts +516 -0
  217. package/types/components/Search.d.ts.map +1 -0
  218. package/types/components/SegmentedButton.d.ts +252 -0
  219. package/types/components/SegmentedButton.d.ts.map +1 -0
  220. package/types/components/SegmentedButtonGroup.d.ts +43 -0
  221. package/types/components/SegmentedButtonGroup.d.ts.map +1 -0
  222. package/types/components/Select.d.ts +158 -0
  223. package/types/components/Select.d.ts.map +1 -0
  224. package/types/components/Shape.d.ts +10 -0
  225. package/types/components/Shape.d.ts.map +1 -0
  226. package/types/components/SideSheet.d.ts +111 -0
  227. package/types/components/SideSheet.d.ts.map +1 -0
  228. package/types/components/Slider.d.ts +203 -0
  229. package/types/components/Slider.d.ts.map +1 -0
  230. package/types/components/Snackbar.d.ts +73 -0
  231. package/types/components/Snackbar.d.ts.map +1 -0
  232. package/types/components/SnackbarContainer.d.ts +6 -0
  233. package/types/components/SnackbarContainer.d.ts.map +1 -0
  234. package/types/components/Surface.d.ts +45 -0
  235. package/types/components/Surface.d.ts.map +1 -0
  236. package/types/components/Switch.d.ts +187 -0
  237. package/types/components/Switch.d.ts.map +1 -0
  238. package/types/components/SwitchIcon.d.ts +61 -0
  239. package/types/components/SwitchIcon.d.ts.map +1 -0
  240. package/types/components/Tab.d.ts +139 -0
  241. package/types/components/Tab.d.ts.map +1 -0
  242. package/types/components/TabContent.d.ts +124 -0
  243. package/types/components/TabContent.d.ts.map +1 -0
  244. package/types/components/TabList.d.ts +1111 -0
  245. package/types/components/TabList.d.ts.map +1 -0
  246. package/types/components/TabPanel.d.ts +28 -0
  247. package/types/components/TabPanel.d.ts.map +1 -0
  248. package/types/components/Table.d.ts +25 -0
  249. package/types/components/Table.d.ts.map +1 -0
  250. package/types/components/TextArea.d.ts +201 -0
  251. package/types/components/TextArea.d.ts.map +1 -0
  252. package/types/components/Title.d.ts +46 -0
  253. package/types/components/Title.d.ts.map +1 -0
  254. package/types/components/Tooltip.d.ts +49 -0
  255. package/types/components/Tooltip.d.ts.map +1 -0
  256. package/types/components/TopAppBar.d.ts +129 -0
  257. package/types/components/TopAppBar.d.ts.map +1 -0
  258. package/types/constants/colorKeywords.d.ts +2 -0
  259. package/types/constants/colorKeywords.d.ts.map +1 -0
  260. package/types/constants/shapes.d.ts +38 -0
  261. package/types/constants/shapes.d.ts.map +1 -0
  262. package/types/constants/typography.d.ts +212 -0
  263. package/types/constants/typography.d.ts.map +1 -0
  264. package/types/core/Composition.d.ts +260 -0
  265. package/types/core/Composition.d.ts.map +1 -0
  266. package/types/core/CompositionAdapter.d.ts +114 -0
  267. package/types/core/CompositionAdapter.d.ts.map +1 -0
  268. package/types/core/CustomElement.d.ts +304 -0
  269. package/types/core/CustomElement.d.ts.map +1 -0
  270. package/types/core/css.d.ts +44 -0
  271. package/types/core/css.d.ts.map +1 -0
  272. package/types/core/customTypes.d.ts +22 -0
  273. package/types/core/customTypes.d.ts.map +1 -0
  274. package/types/core/dom.d.ts +32 -0
  275. package/types/core/dom.d.ts.map +1 -0
  276. package/types/core/jsonMergePatch.d.ts +31 -0
  277. package/types/core/jsonMergePatch.d.ts.map +1 -0
  278. package/types/core/observe.d.ts +114 -0
  279. package/types/core/observe.d.ts.map +1 -0
  280. package/types/core/optimizations.d.ts +7 -0
  281. package/types/core/optimizations.d.ts.map +1 -0
  282. package/types/core/template.d.ts +47 -0
  283. package/types/core/template.d.ts.map +1 -0
  284. package/types/core/uid.d.ts +6 -0
  285. package/types/core/uid.d.ts.map +1 -0
  286. package/types/dom/HTMLOptionsCollectionProxy.d.ts +18 -0
  287. package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -0
  288. package/types/index.d.ts +88 -0
  289. package/types/index.d.ts.map +1 -0
  290. package/types/loaders/palette.d.ts +2 -0
  291. package/types/loaders/palette.d.ts.map +1 -0
  292. package/types/loaders/theme.d.ts +2 -0
  293. package/types/loaders/theme.d.ts.map +1 -0
  294. package/types/mixins/AriaReflectorMixin.d.ts +31 -0
  295. package/types/mixins/AriaReflectorMixin.d.ts.map +1 -0
  296. package/types/mixins/AriaToolbarMixin.d.ts +34 -0
  297. package/types/mixins/AriaToolbarMixin.d.ts.map +1 -0
  298. package/types/mixins/ControlMixin.d.ts +124 -0
  299. package/types/mixins/ControlMixin.d.ts.map +1 -0
  300. package/types/mixins/DelegatesFocusMixin.d.ts +13 -0
  301. package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -0
  302. package/types/mixins/DensityMixin.d.ts +8 -0
  303. package/types/mixins/DensityMixin.d.ts.map +1 -0
  304. package/types/mixins/ElevationMixin.d.ts +32 -0
  305. package/types/mixins/ElevationMixin.d.ts.map +1 -0
  306. package/types/mixins/FlexableMixin.d.ts +14 -0
  307. package/types/mixins/FlexableMixin.d.ts.map +1 -0
  308. package/types/mixins/FormAssociatedMixin.d.ts +123 -0
  309. package/types/mixins/FormAssociatedMixin.d.ts.map +1 -0
  310. package/types/mixins/HyperlinkMixin.d.ts +25 -0
  311. package/types/mixins/HyperlinkMixin.d.ts.map +1 -0
  312. package/types/mixins/InputMixin.d.ts +173 -0
  313. package/types/mixins/InputMixin.d.ts.map +1 -0
  314. package/types/mixins/KeyboardNavMixin.d.ts +46 -0
  315. package/types/mixins/KeyboardNavMixin.d.ts.map +1 -0
  316. package/types/mixins/NavigationListenerMixin.d.ts +8 -0
  317. package/types/mixins/NavigationListenerMixin.d.ts.map +1 -0
  318. package/types/mixins/PopupMixin.d.ts +98 -0
  319. package/types/mixins/PopupMixin.d.ts.map +1 -0
  320. package/types/mixins/RTLObserverMixin.d.ts +8 -0
  321. package/types/mixins/RTLObserverMixin.d.ts.map +1 -0
  322. package/types/mixins/ResizeObserverMixin.d.ts +13 -0
  323. package/types/mixins/ResizeObserverMixin.d.ts.map +1 -0
  324. package/types/mixins/RippleMixin.d.ts +94 -0
  325. package/types/mixins/RippleMixin.d.ts.map +1 -0
  326. package/types/mixins/ScrollListenerMixin.d.ts +46 -0
  327. package/types/mixins/ScrollListenerMixin.d.ts.map +1 -0
  328. package/types/mixins/SemiStickyMixin.d.ts +50 -0
  329. package/types/mixins/SemiStickyMixin.d.ts.map +1 -0
  330. package/types/mixins/ShapeMaskedMixin.d.ts +12 -0
  331. package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -0
  332. package/types/mixins/ShapeMixin.d.ts +39 -0
  333. package/types/mixins/ShapeMixin.d.ts.map +1 -0
  334. package/types/mixins/StateMixin.d.ts +29 -0
  335. package/types/mixins/StateMixin.d.ts.map +1 -0
  336. package/types/mixins/TextFieldMixin.d.ts +153 -0
  337. package/types/mixins/TextFieldMixin.d.ts.map +1 -0
  338. package/types/mixins/ThemableMixin.d.ts +10 -0
  339. package/types/mixins/ThemableMixin.d.ts.map +1 -0
  340. package/types/mixins/TooltipTriggerMixin.d.ts +114 -0
  341. package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -0
  342. package/types/mixins/TouchTargetMixin.d.ts +6 -0
  343. package/types/mixins/TouchTargetMixin.d.ts.map +1 -0
  344. package/types/mixins/TypographyMixin.d.ts +20 -0
  345. package/types/mixins/TypographyMixin.d.ts.map +1 -0
  346. package/types/services/rtl.d.ts +3 -0
  347. package/types/services/rtl.d.ts.map +1 -0
  348. package/types/services/svgAlias.d.ts +13 -0
  349. package/types/services/svgAlias.d.ts.map +1 -0
  350. package/types/services/theme.d.ts +45 -0
  351. package/types/services/theme.d.ts.map +1 -0
  352. package/types/utils/cli.d.ts +3 -0
  353. package/types/utils/cli.d.ts.map +1 -0
  354. package/types/utils/function.d.ts +3 -0
  355. package/types/utils/function.d.ts.map +1 -0
  356. package/types/utils/jsx-runtime.d.ts +20 -0
  357. package/types/utils/jsx-runtime.d.ts.map +1 -0
  358. package/types/utils/material-color/blend.d.ts +34 -0
  359. package/types/utils/material-color/blend.d.ts.map +1 -0
  360. package/types/utils/material-color/hct/Cam16.d.ts +142 -0
  361. package/types/utils/material-color/hct/Cam16.d.ts.map +1 -0
  362. package/types/utils/material-color/hct/Hct.d.ts +93 -0
  363. package/types/utils/material-color/hct/Hct.d.ts.map +1 -0
  364. package/types/utils/material-color/hct/ViewingConditions.d.ts +69 -0
  365. package/types/utils/material-color/hct/ViewingConditions.d.ts.map +1 -0
  366. package/types/utils/material-color/hct/hctSolver.d.ts +30 -0
  367. package/types/utils/material-color/hct/hctSolver.d.ts.map +1 -0
  368. package/types/utils/material-color/helper.d.ts +8 -0
  369. package/types/utils/material-color/helper.d.ts.map +1 -0
  370. package/types/utils/material-color/palettes/CorePalette.d.ts +75 -0
  371. package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -0
  372. package/types/utils/material-color/palettes/TonalPalette.d.ts +38 -0
  373. package/types/utils/material-color/palettes/TonalPalette.d.ts.map +1 -0
  374. package/types/utils/material-color/scheme/Scheme.d.ts +264 -0
  375. package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -0
  376. package/types/utils/material-color/utils/color.d.ts +172 -0
  377. package/types/utils/material-color/utils/color.d.ts.map +1 -0
  378. package/types/utils/material-color/utils/math.d.ts +94 -0
  379. package/types/utils/material-color/utils/math.d.ts.map +1 -0
  380. package/types/utils/pixelmatch.d.ts +22 -0
  381. package/types/utils/pixelmatch.d.ts.map +1 -0
  382. package/types/utils/popup.d.ts +106 -0
  383. package/types/utils/popup.d.ts.map +1 -0
  384. package/types/utils/searchParams.d.ts +3 -0
  385. package/types/utils/searchParams.d.ts.map +1 -0
  386. package/types/utils/svg.d.ts +7 -0
  387. package/types/utils/svg.d.ts.map +1 -0
  388. package/utils/jsx-runtime.js +9 -4
  389. package/utils/material-color/scheme/Scheme.js +1 -1
  390. package/utils/pixelmatch.js +363 -0
  391. package/utils/popup.js +86 -10
  392. package/utils/searchParams.js +22 -0
  393. package/components/Button.md +0 -61
  394. package/components/ExtendedFab.js +0 -32
  395. package/components/Layout.js +0 -504
  396. package/components/Nav.js +0 -38
  397. package/core/DomAdapter.js +0 -586
  398. package/core/ICustomElement.d.ts +0 -291
  399. package/core/ICustomElement.js +0 -1
  400. package/core/test.js +0 -126
  401. package/core/typings.d.ts +0 -142
  402. package/core/typings.js +0 -1
  403. package/mixins/SurfaceMixin.js +0 -127
  404. package/theming/loader.js +0 -22
  405. /package/{utils/color_keywords.js → constants/colorKeywords.js} +0 -0
@@ -0,0 +1,472 @@
1
+ import CustomElement from '../core/CustomElement.js';
2
+ import { ELEMENT_ANIMATION_TYPE, EVENT_HANDLER_TYPE } from '../core/customTypes.js';
3
+ import AriaReflectorMixin from '../mixins/AriaReflectorMixin.js';
4
+ import DelegatesFocusMixin from '../mixins/DelegatesFocusMixin.js';
5
+ import FlexableMixin from '../mixins/FlexableMixin.js';
6
+ import ResizeObserverMixin from '../mixins/ResizeObserverMixin.js';
7
+ import ShapeMixin from '../mixins/ShapeMixin.js';
8
+ import StateMixin from '../mixins/StateMixin.js';
9
+ import ThemableMixin from '../mixins/ThemableMixin.js';
10
+
11
+ import Scrim from './Scrim.js';
12
+
13
+ const SUPPORTS_SCROLLEND = 'onscrollend' in window;
14
+
15
+ /* Weak Collection of Events that cane from drag handle */
16
+ const dragHandleEvent = new WeakSet();
17
+
18
+ CustomElement
19
+ .extend()
20
+ .mixin(StateMixin)
21
+ .set({
22
+ stateLayer: true,
23
+ })
24
+ .html`
25
+ <div id=container>
26
+ <div id=icon aria-hidden=true></div>
27
+ </div>
28
+ `
29
+ .recompose(({ refs: { container, state } }) => {
30
+ container.prepend(state);
31
+ })
32
+ .css`
33
+ :host {
34
+ --mdw-state__hovered-opacity: 0;
35
+ --mdw-state__pressed-opacity: 0;
36
+ position: absolute;
37
+ inset-block-start: 0;
38
+ inset-inline: 0;
39
+ align-self: stretch;
40
+
41
+ display: flex;
42
+ align-items: center;
43
+ justify-content: center;
44
+
45
+ cursor: grab;
46
+
47
+ outline:none;
48
+ pointer-events: auto;
49
+ user-select: none;
50
+ touch-action: none;
51
+
52
+ color: rgb(var(--mdw-color__on-surface-variant));
53
+ }
54
+
55
+ :host(:active) {
56
+ cursor: grabbing !important;
57
+ }
58
+
59
+ #container {
60
+ position: relative;
61
+
62
+ display: flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+
66
+ min-block-size: 48px;
67
+ min-inline-size: 48px;
68
+ }
69
+
70
+ #state {
71
+ border-radius: 50%;
72
+ }
73
+
74
+ #state[pointed] {
75
+ --mdw-state__focused-opacity: 0;
76
+ }
77
+
78
+
79
+ #icon {
80
+ block-size: 4px;
81
+ inline-size: 32px;
82
+
83
+ background-color: currentColor;
84
+ border-radius: 8px;
85
+ }
86
+ `
87
+ .events({
88
+ touchmove(event) {
89
+ event.preventDefault();
90
+ },
91
+ })
92
+ .autoRegister('mdw-bottom-sheet-handle');
93
+
94
+ /**
95
+ * Bottom sheets show secondary content anchored to the bottom of the screen
96
+ * @see https://m3.material.io/components/bottom-sheets/specs
97
+ */
98
+ export default CustomElement
99
+ .extend()
100
+ .mixin(ThemableMixin)
101
+ .mixin(FlexableMixin)
102
+ .mixin(ShapeMixin)
103
+ .mixin(AriaReflectorMixin)
104
+ .mixin(DelegatesFocusMixin)
105
+ .mixin(ResizeObserverMixin)
106
+ .observe({
107
+ /** Overrides default of shape top to be true */
108
+ shapeTop: {
109
+ type: 'boolean',
110
+ empty: true,
111
+ },
112
+ /** Whether the bottom sheet displays as a modal and shows a scrim. */
113
+ modal: 'boolean',
114
+ /** If true, the sheet is fixed (not translated) and anchors to layout. */
115
+ fixed: 'boolean',
116
+ /** Whether the bottom sheet is currently open. */
117
+ open: 'boolean',
118
+ /** Whether the bottom sheet is expanded to show full content. */
119
+ expanded: 'boolean',
120
+ /** Last measured block size in pixels (used for layout calculations). */
121
+ _lastComputedBlockSize: {
122
+ type: 'float',
123
+ nullable: false,
124
+ },
125
+ /** Last measured offsetTop in pixels. */
126
+ _lastOffsetTop: {
127
+ type: 'float',
128
+ nullable: false,
129
+ },
130
+ /** Current animation duration (milliseconds). */
131
+ _animationDuration: {
132
+ type: 'integer',
133
+ value: 0,
134
+ },
135
+ /** Current animation easing string for transitions. */
136
+ _animationEasing: {
137
+ value: 'ease-out',
138
+ },
139
+ /** Current CSS translateY value applied to the sheet. */
140
+ _translateY: { value: '100%' },
141
+ /** Timestamp of last child scroll event (used to debounce drag). */
142
+ _lastChildScrollTime: 'float',
143
+ /** ARIA `valuenow` value used by the drag handle for accessibility. */
144
+ _ariaValueNow: {
145
+ type: 'integer',
146
+ },
147
+ /** When true, a drag handle is rendered to allow pointer dragging. */
148
+ dragHandle: 'boolean',
149
+ /** Event handler: called when the sheet opens. */
150
+ onopen: EVENT_HANDLER_TYPE,
151
+ /** Event handler: called when the sheet closes. */
152
+ onclose: EVENT_HANDLER_TYPE,
153
+ })
154
+ .set({
155
+ _hasCheckedResize: false,
156
+ /** @type {InstanceType<Scrim>} */
157
+ _scrim: null,
158
+ _dragTimestamp: 0,
159
+ /** @type {number} */
160
+ _dragDeltaY: null,
161
+ /** @type {number} */
162
+ _dragStartY: null,
163
+ })
164
+ .observe({
165
+ hostStyles: {
166
+ ...ELEMENT_ANIMATION_TYPE,
167
+ get({
168
+ open, fixed, _lastComputedBlockSize, _translateY,
169
+ _animationDuration, _animationEasing,
170
+ }) {
171
+ const computedMargin = (fixed) ? `${-1 * _lastComputedBlockSize}px` : 0;
172
+ return {
173
+ styles: {
174
+ marginBottom: computedMargin,
175
+ transform: fixed ? 'none' : `translateY(${_translateY})`,
176
+ },
177
+ timing: {
178
+ duration: _animationDuration,
179
+ easing: _animationEasing,
180
+ },
181
+ };
182
+ },
183
+ },
184
+ })
185
+ .html`
186
+ <mdw-bottom-sheet-handle id=drag-handle mdw-if={dragHandle} tabindex=0
187
+ role=separator aria-valuemin=-100 aria-valuemax=0 aria-valuenow={_ariaValueNow}></mdw-bottom-sheet-handle>
188
+ <slot id=slot></slot>
189
+ `
190
+ .methods({
191
+ /**
192
+ * Ensure a scrim is present when the sheet is modal and open.
193
+ * @param {boolean} [animate=false] - If true, animate scrim changes.
194
+ * @return {void}
195
+ */
196
+ checkForScrim(animate = false) {
197
+ let { open, modal, _scrim } = this;
198
+ if (open && modal) {
199
+ if (!_scrim) {
200
+ _scrim = new Scrim();
201
+ _scrim.addEventListener('click', () => {
202
+ this.open = false;
203
+ if (!this.dispatchEvent(new Event('close', { cancelable: true }))) {
204
+ // Revert if cancelled
205
+ this.open = true;
206
+ }
207
+ });
208
+ this._scrim = _scrim;
209
+ }
210
+ this.before(_scrim);
211
+ _scrim.hidden = false;
212
+ } else if (_scrim) {
213
+ if (!animate) {
214
+ _scrim.remove();
215
+ }
216
+ _scrim.hidden = true;
217
+ }
218
+ },
219
+ /**
220
+ * Evaluate drag state and settle the sheet (close or snap open).
221
+ * @return {void}
222
+ */
223
+ checkDragFinished() {
224
+ const { open, _dragStartY, _dragDeltaY, _lastComputedBlockSize, modal, fixed, _lastOffsetTop } = this;
225
+ if (!open || fixed || _dragStartY == null || _dragDeltaY == null) return;
226
+ const containerHeight = _lastOffsetTop + _lastComputedBlockSize - 72;
227
+ const min = (_lastComputedBlockSize > containerHeight)
228
+ ? _lastComputedBlockSize - containerHeight
229
+ : 0;
230
+ // visiblity = (max - position) / range
231
+ const visibility = (_lastComputedBlockSize - _dragDeltaY) / (_lastComputedBlockSize - min);
232
+ this._dragStartY = null;
233
+ if (modal && visibility < 0.5) {
234
+ // Should close
235
+ this._animationDuration = 200 * visibility;
236
+ this._animationEasing = 'ease-out';
237
+ this._translateY = '100%';
238
+ this._dragDeltaY = null;
239
+ this.open = false;
240
+ this.dispatchEvent(new Event('close', { cancelable: false }));
241
+ } else {
242
+ // Should snap back to fully open
243
+ this._animationDuration = 250 * (0.5 * visibility);
244
+ this._dragDeltaY = min;
245
+ this._translateY = `${0}px`;
246
+ this._animationEasing = 'ease-in';
247
+ this.expanded = true;
248
+ }
249
+ },
250
+ /**
251
+ * Pointer active on the drag handle; registers the pointer for dragging.
252
+ * @param {PointerEvent} event
253
+ * @return {void}
254
+ */
255
+ onDragHandleActive(event) {
256
+ if (!event.isTrusted) return;
257
+ if (!event.isPrimary) return;
258
+ if (event.pointerType === 'touch') return;
259
+ if (event.buttons !== 1) return;
260
+ dragHandleEvent.add(event);
261
+ },
262
+ /**
263
+ * Pointer inactive on the drag handle; finalizes potential drag.
264
+ * @param {PointerEvent} event
265
+ * @return {void}
266
+ */
267
+ onDragHandleInactive(event) {
268
+ if (!event.isTrusted) return;
269
+ if (!event.isPrimary) return;
270
+ if (event.pointerType === 'touch') return;
271
+ if (event.type !== 'pointerup' && event.buttons !== 1) return;
272
+ this.checkDragFinished();
273
+ },
274
+ /**
275
+ * Handle pointer or touch move events during dragging.
276
+ * @param {PointerEvent|TouchEvent} event
277
+ * @return {void}
278
+ */
279
+ onPointerOrTouchMove(event) {
280
+ /** @type {{clientY:number,pageY:number}} */
281
+ let source;
282
+ const isTouch = (event.type === 'touchmove');
283
+ if (isTouch) {
284
+ const { touches } = /** @type {TouchEvent} */ (event);
285
+ if (!touches.length) return;
286
+ source = touches[0];
287
+ } else {
288
+ source = /** @type {PointerEvent} */ (event);
289
+ // if (!dragHandleEvent.has(event)) return;
290
+ }
291
+ const { open, _lastChildScrollTime, _dragStartY, _dragTimestamp, expanded } = this;
292
+ if (!open || _dragStartY == null) return;
293
+ if (_lastChildScrollTime && performance.now() - _lastChildScrollTime <= (SUPPORTS_SCROLLEND ? 5000 : 500)) {
294
+ // Assume still scrolling
295
+ return;
296
+ }
297
+ let { clientY, pageY } = source;
298
+ clientY ??= pageY - window.scrollY; // Safari
299
+ const { _lastOffsetTop, _lastComputedBlockSize } = this;
300
+ const containerHeight = _lastOffsetTop + _lastComputedBlockSize - 72;
301
+ const min = _lastComputedBlockSize > containerHeight
302
+ ? _lastComputedBlockSize - containerHeight
303
+ : 0;
304
+ const delta = Math.max((clientY - _dragStartY), min);
305
+ this._dragDeltaY = delta;
306
+
307
+ if (isTouch && expanded && performance.now() - _dragTimestamp < 100) {
308
+ // Store location, but don't animate until sure not scrolling
309
+ return;
310
+ }
311
+ if (expanded && delta !== min) {
312
+ // Buggy in demos
313
+ // this.expanded = false;
314
+ }
315
+
316
+ this._animationDuration = 0;
317
+ this._translateY = `${delta}px`;
318
+ },
319
+ })
320
+ .overrides({
321
+ /**
322
+ * Called by ResizeObserverMixin when the element's size changes.
323
+ * @param {ResizeObserverEntry} entry
324
+ * @return {void}
325
+ */
326
+ onResizeObserved(entry) {
327
+ this._lastComputedBlockSize = entry.borderBoxSize[0]?.blockSize;
328
+ this._lastOffsetTop = this.offsetTop;
329
+ },
330
+ })
331
+ .events({
332
+ '~pointerdown'(event) {
333
+ if (event.pointerType !== 'touch') {
334
+ if (event.buttons !== 1) return;
335
+ // Pointer down isn't from drag-handle. Ignore
336
+ if (!dragHandleEvent.has(event)) return;
337
+ }
338
+ if (!this.open) return;
339
+ let { clientY, pageY } = event;
340
+ clientY ??= pageY - window.scrollY; // Safari
341
+ this._dragStartY = clientY - (this._dragDeltaY ?? 0);
342
+ this._dragDeltaY = 0;
343
+ this._dragTimestamp = performance.now();
344
+ },
345
+ '~pointermove': 'onPointerOrTouchMove',
346
+ '~pointerup'(event) {
347
+ if (event.pointerType === 'touch') return;
348
+ this.checkDragFinished();
349
+ },
350
+ 'pointerleave'(event) {
351
+ if (event.pointerType === 'touch') return;
352
+ this.checkDragFinished();
353
+ },
354
+ '~touchmove': 'onPointerOrTouchMove',
355
+ touchcancel: 'checkDragFinished',
356
+ '~touchend': 'checkDragFinished',
357
+ /** Scroll events do no bubble but can be captured, passively */
358
+ '*~scroll'() {
359
+ if (this.fixed) return;
360
+ this.checkDragFinished();
361
+ this._lastChildScrollTime = performance.now();
362
+ // Wiping touch state
363
+ this._dragStartY = null;
364
+ this._dragDeltaY = null;
365
+ },
366
+ '*scrollend'() {
367
+ if (this.fixed) return;
368
+ this._lastChildScrollTime = null;
369
+ },
370
+ })
371
+ .childEvents({
372
+ dragHandle: {
373
+ '~pointerdown': 'onDragHandleActive',
374
+ '~pointermove': 'onDragHandleActive',
375
+ },
376
+ })
377
+ .on({
378
+ openChanged(previous, open) {
379
+ // Refresh metrics
380
+ const _lastOffsetTop = this.offsetTop;
381
+ this._lastOffsetTop = _lastOffsetTop;
382
+ // No longer using initial animation timing of 0
383
+ this._animationDuration = open ? 250 : 200;
384
+ if (open) {
385
+ let y = 0;
386
+ if (!this.fixed) {
387
+ const { _lastComputedBlockSize } = this;
388
+ const containerHeight = _lastOffsetTop + _lastComputedBlockSize;
389
+ if (_lastComputedBlockSize > containerHeight / 2) {
390
+ // Bottom Sheet is oversized, clamp to 50%
391
+ y = _lastComputedBlockSize - (containerHeight / 2);
392
+ }
393
+ }
394
+ this._translateY = `${y}px`;
395
+ this._dragDeltaY = y;
396
+ } else {
397
+ this._translateY = '100%';
398
+ this.expanded = false;
399
+ }
400
+ this._animationEasing = open ? 'ease-in' : 'ease-out';
401
+ this.checkForScrim(true);
402
+ if (open) {
403
+ this.focus();
404
+ }
405
+ },
406
+ modalChanged() {
407
+ this._animationDuration = 0;
408
+ this.checkForScrim(false);
409
+ },
410
+ })
411
+ .css`
412
+ :host {
413
+ --mdw-bg: var(--mdw-color__surface-container-low);
414
+ --mdw-ink: var(--mdw-color__on-surface);
415
+ --mdw-shape__size: var(--mdw-shape__extra-large);
416
+ --mdw-shape__size__bottom-start-size: 0px;
417
+ --mdw-shape__size__bottom-end-size: 0px;
418
+ position: sticky;
419
+ inset-block-end: 0;
420
+ inset-inline: 0;
421
+
422
+ overflow-y: clip;
423
+
424
+ overscroll-behavior: none;
425
+ overscroll-behavior: contain;
426
+
427
+ box-sizing: border-box;
428
+ max-inline-size: 640px;
429
+ margin-inline: auto;
430
+ padding-block-start: 16px;
431
+
432
+ pointer-events: none;
433
+
434
+ transform: translateY(100%);
435
+
436
+ visibility: hidden;
437
+
438
+ background-color: rgb(var(--mdw-bg));
439
+ color: rgb(var(--mdw-ink));
440
+
441
+ transition: visibility 200ms;
442
+
443
+ will-change: transform, margin-block-end, visibility;
444
+ }
445
+
446
+ :host(:where([open])) {
447
+ pointer-events: auto;
448
+
449
+ visibility: inherit;
450
+
451
+ transition: visibility 0s;
452
+ }
453
+
454
+ :host(:where(:not([fixed]))) {
455
+ position: fixed;
456
+
457
+ max-block-size: calc(100% - 72px);
458
+ touch-action: none;
459
+
460
+ z-index: 24;
461
+ }
462
+
463
+ :host(:where([expanded])) {
464
+ overflow-y:auto;
465
+ touch-action: auto;
466
+ }
467
+
468
+ :host(:where([drag-handle])) {
469
+ padding-block-start: 48px;
470
+ }
471
+ `
472
+ .autoRegister('mdw-bottom-sheet');
package/components/Box.js CHANGED
@@ -3,35 +3,16 @@ import FlexableMixin from '../mixins/FlexableMixin.js';
3
3
  import ThemableMixin from '../mixins/ThemableMixin.js';
4
4
 
5
5
  /**
6
- * Containers are stateless elements that may have a color and ink.
6
+ * Boxes are stateless elements that may have a color and ink.
7
7
  * They should have simple geometry for rendering and layout.
8
8
  */
9
9
  export default CustomElement
10
10
  .extend()
11
11
  .mixin(ThemableMixin)
12
12
  .mixin(FlexableMixin)
13
- .observe({
14
- inline: 'boolean',
15
- grid: 'boolean',
16
- block: {
17
- type: 'boolean',
18
- empty: true,
19
- },
20
- })
13
+ .html`<slot id=slot></slot>`
21
14
  .css`
22
- :host {
23
- display: block;
24
- }
25
-
26
- :host([inline]) {
27
- display: inline-block;
28
- }
29
-
30
- :host([flex]:where([inline])) {
31
- display: inline-flex;
32
- }
33
-
34
- :host([color]) {
15
+ :host(:where([color])) {
35
16
  background-color: rgb(var(--mdw-bg));
36
17
  color: rgb(var(--mdw-ink));
37
18
  }
@@ -49,36 +30,17 @@ export default CustomElement
49
30
  font: var(--mdw-type__font);
50
31
  letter-spacing: var(--mdw-type__letter-spacing);
51
32
  }
52
-
53
- #slot {
54
- /* Passthrough from parent */
55
- block-size: inherit;
56
- inline-size: inherit;
57
- }
58
33
 
59
- :host([grid]) {
60
- display: grid;
61
- column-gap: 16px; /* Gutters */
62
- grid-auto-flow: row;
63
- grid-template-columns: repeat(var(--mdw-grid__columns), 1fr);
34
+ #slot::slotted([flex-0]) {
35
+ flex: 0;
64
36
  }
65
37
 
66
- #slot[grid]::slotted(*) { grid-column: auto / span calc(var(--mdw-grid__columns)) }
67
- #slot[grid]::slotted([col-span="1"]) { grid-column: auto / span 1; }
68
- #slot[grid]::slotted([col-span="2"]) { grid-column: auto / span min(2, var(--mdw-grid__columns)); }
69
- #slot[grid]::slotted([col-span="3"]) { grid-column: auto / span min(3, var(--mdw-grid__columns)); }
70
- #slot[grid]::slotted([col-span="4"]) { grid-column: auto / span min(4, var(--mdw-grid__columns)); }
71
- #slot[grid]::slotted([col-span="5"]) { grid-column: auto / span min(5, var(--mdw-grid__columns)); }
72
- #slot[grid]::slotted([col-span="6"]) { grid-column: auto / span min(6, var(--mdw-grid__columns)); }
73
- #slot[grid]::slotted([col-span="7"]) { grid-column: auto / span min(7, var(--mdw-grid__columns)); }
74
- #slot[grid]::slotted([col-span="8"]) { grid-column: auto / span min(8, var(--mdw-grid__columns)); }
75
- #slot[grid]::slotted([col-span="9"]) { grid-column: auto / span min(9, var(--mdw-grid__columns)); }
76
- #slot[grid]::slotted([col-span="10"]) { grid-column: auto / span min(10, var(--mdw-grid__columns)); }
77
- #slot[grid]::slotted([col-span="11"]) { grid-column: auto / span min(11, var(--mdw-grid__columns)); }
78
- #slot[grid]::slotted([col-span="12"]) { grid-column: auto / span min(12, var(--mdw-grid__columns)); }
79
- #slot[grid]::slotted([col-span="50%"]) { grid-column: auto / span max(calc(var(--mdw-grid__columns) / 2), 1); }
80
- #slot[grid]::slotted([col-span="25%"]) { grid-column: auto / span max(calc(var(--mdw-grid__columns) / 4), 1); }
38
+ #slot::slotted([flex-1]) {
39
+ flex: 1;
40
+ }
81
41
 
42
+ #slot::slotted([flex-none]) {
43
+ flex: none;
44
+ }
82
45
  `
83
- .html`<slot id=slot type-style={typeStyle} grid={grid}></slot>`
84
46
  .autoRegister('mdw-box');