@shortfuse/materialdesignweb 0.7.6 → 0.9.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 (412) hide show
  1. package/README.md +87 -90
  2. package/bin/mdw-css.js +1 -1
  3. package/components/Badge.js +14 -7
  4. package/components/Body.js +3 -0
  5. package/components/BottomAppBar.js +4 -13
  6. package/components/BottomSheet.js +424 -0
  7. package/components/Box.js +20 -28
  8. package/components/Button.js +85 -79
  9. package/components/Button.md +9 -9
  10. package/components/Card.js +60 -72
  11. package/components/Checkbox.js +33 -42
  12. package/components/CheckboxIcon.js +11 -29
  13. package/components/Chip.js +13 -11
  14. package/components/Dialog.js +214 -394
  15. package/components/DialogActions.js +2 -2
  16. package/components/Display.js +55 -0
  17. package/components/Divider.js +3 -3
  18. package/components/Fab.js +83 -18
  19. package/components/FabContainer.js +48 -0
  20. package/components/FilterChip.js +35 -33
  21. package/components/Grid.js +176 -0
  22. package/components/Headline.js +5 -28
  23. package/components/Icon.js +61 -76
  24. package/components/IconButton.js +72 -126
  25. package/components/Input.js +859 -1
  26. package/components/InputChip.js +161 -0
  27. package/components/Label.js +3 -0
  28. package/components/List.js +4 -6
  29. package/components/ListItem.js +46 -30
  30. package/components/ListOption.js +86 -53
  31. package/components/Listbox.js +248 -0
  32. package/components/Menu.js +69 -528
  33. package/components/MenuItem.js +33 -36
  34. package/components/NavBar.js +49 -86
  35. package/components/NavDrawer.js +16 -15
  36. package/components/NavDrawerItem.js +4 -5
  37. package/components/NavItem.js +58 -41
  38. package/components/NavRail.js +30 -20
  39. package/components/NavRailItem.js +8 -3
  40. package/components/Page.js +105 -0
  41. package/components/Pane.js +11 -274
  42. package/components/Popup.js +29 -0
  43. package/components/Progress.js +24 -23
  44. package/components/Radio.js +40 -36
  45. package/components/RadioIcon.js +12 -16
  46. package/components/Ripple.js +13 -10
  47. package/components/Root.js +209 -0
  48. package/components/Scrim.js +87 -0
  49. package/components/Search.js +77 -0
  50. package/components/SegmentedButton.js +33 -45
  51. package/components/SegmentedButtonGroup.js +25 -13
  52. package/components/Select.js +10 -11
  53. package/components/Shape.js +5 -65
  54. package/components/SideSheet.js +308 -0
  55. package/components/Slider.js +108 -78
  56. package/components/Snackbar.js +26 -21
  57. package/components/SnackbarContainer.js +42 -0
  58. package/components/Surface.js +17 -12
  59. package/components/Switch.js +45 -24
  60. package/components/SwitchIcon.js +49 -39
  61. package/components/Tab.js +64 -43
  62. package/components/TabContent.js +5 -3
  63. package/components/TabList.js +62 -34
  64. package/components/TabPanel.js +11 -8
  65. package/components/Table.js +116 -0
  66. package/components/TextArea.js +54 -50
  67. package/components/Title.js +4 -9
  68. package/components/Tooltip.js +44 -22
  69. package/components/TopAppBar.js +68 -172
  70. package/constants/shapes.js +36 -0
  71. package/constants/typography.js +127 -0
  72. package/core/Composition.js +1164 -645
  73. package/core/CompositionAdapter.js +314 -0
  74. package/core/CustomElement.js +701 -286
  75. package/core/css.js +121 -15
  76. package/core/customTypes.js +157 -40
  77. package/core/dom.js +17 -11
  78. package/{utils → core}/jsonMergePatch.js +42 -18
  79. package/core/observe.js +343 -244
  80. package/core/optimizations.js +23 -0
  81. package/core/template.js +19 -56
  82. package/core/uid.js +13 -0
  83. package/dist/index.min.js +85 -184
  84. package/dist/index.min.js.map +4 -4
  85. package/dist/meta.json +1 -1
  86. package/dom/HTMLOptionsCollectionProxy.js +106 -0
  87. package/loaders/palette.js +13 -0
  88. package/loaders/theme.js +12 -0
  89. package/mixins/AriaReflectorMixin.js +53 -14
  90. package/mixins/AriaToolbarMixin.js +5 -3
  91. package/mixins/ControlMixin.js +92 -41
  92. package/mixins/DelegatesFocusMixin.js +54 -0
  93. package/mixins/DensityMixin.js +2 -3
  94. package/mixins/ElevationMixin.js +62 -0
  95. package/mixins/FlexableMixin.js +67 -39
  96. package/mixins/FormAssociatedMixin.js +71 -16
  97. package/mixins/HyperlinkMixin.js +66 -0
  98. package/mixins/InputMixin.js +205 -39
  99. package/mixins/KeyboardNavMixin.js +22 -7
  100. package/mixins/NavigationListenerMixin.js +33 -0
  101. package/mixins/PopupMixin.js +725 -0
  102. package/mixins/RTLObserverMixin.js +0 -1
  103. package/mixins/ResizeObserverMixin.js +16 -5
  104. package/mixins/RippleMixin.js +11 -10
  105. package/mixins/ScrollListenerMixin.js +42 -33
  106. package/mixins/SemiStickyMixin.js +97 -0
  107. package/mixins/ShapeMaskedMixin.js +117 -0
  108. package/mixins/ShapeMixin.js +17 -194
  109. package/mixins/StateMixin.js +80 -39
  110. package/mixins/TextFieldMixin.js +139 -183
  111. package/mixins/ThemableMixin.js +71 -161
  112. package/mixins/TooltipTriggerMixin.js +292 -366
  113. package/mixins/TouchTargetMixin.js +5 -4
  114. package/mixins/TypographyMixin.js +121 -0
  115. package/package.json +111 -71
  116. package/services/rtl.js +10 -0
  117. package/services/svgAlias.js +17 -0
  118. package/{theming/index.js → services/theme.js} +25 -175
  119. package/types/bin/mdw-css.d.ts +3 -0
  120. package/types/bin/mdw-css.d.ts.map +1 -0
  121. package/types/components/Badge.d.ts +39 -0
  122. package/types/components/Badge.d.ts.map +1 -0
  123. package/types/components/Body.d.ts +29 -0
  124. package/types/components/Body.d.ts.map +1 -0
  125. package/types/components/BottomAppBar.d.ts +73 -0
  126. package/types/components/BottomAppBar.d.ts.map +1 -0
  127. package/types/components/BottomSheet.d.ts +109 -0
  128. package/types/components/BottomSheet.d.ts.map +1 -0
  129. package/types/components/Box.d.ts +16 -0
  130. package/types/components/Box.d.ts.map +1 -0
  131. package/types/components/Button.d.ts +714 -0
  132. package/types/components/Button.d.ts.map +1 -0
  133. package/types/components/Card.d.ts +412 -0
  134. package/types/components/Card.d.ts.map +1 -0
  135. package/types/components/Checkbox.d.ts +205 -0
  136. package/types/components/Checkbox.d.ts.map +1 -0
  137. package/types/components/CheckboxIcon.d.ts +44 -0
  138. package/types/components/CheckboxIcon.d.ts.map +1 -0
  139. package/types/components/Chip.d.ts +1425 -0
  140. package/types/components/Chip.d.ts.map +1 -0
  141. package/types/components/Dialog.d.ts +286 -0
  142. package/types/components/Dialog.d.ts.map +1 -0
  143. package/types/components/DialogActions.d.ts +4 -0
  144. package/types/components/DialogActions.d.ts.map +1 -0
  145. package/types/components/Display.d.ts +45 -0
  146. package/types/components/Display.d.ts.map +1 -0
  147. package/types/components/Divider.d.ts +10 -0
  148. package/types/components/Divider.d.ts.map +1 -0
  149. package/types/components/Fab.d.ts +741 -0
  150. package/types/components/Fab.d.ts.map +1 -0
  151. package/types/components/FabContainer.d.ts +10 -0
  152. package/types/components/FabContainer.d.ts.map +1 -0
  153. package/types/components/FilterChip.d.ts +4283 -0
  154. package/types/components/FilterChip.d.ts.map +1 -0
  155. package/types/components/Grid.d.ts +37 -0
  156. package/types/components/Grid.d.ts.map +1 -0
  157. package/types/components/Headline.d.ts +47 -0
  158. package/types/components/Headline.d.ts.map +1 -0
  159. package/types/components/Icon.d.ts +103 -0
  160. package/types/components/Icon.d.ts.map +1 -0
  161. package/types/components/IconButton.d.ts +1486 -0
  162. package/types/components/IconButton.d.ts.map +1 -0
  163. package/types/components/Input.d.ts +51288 -0
  164. package/types/components/Input.d.ts.map +1 -0
  165. package/types/components/InputChip.d.ts +243 -0
  166. package/types/components/InputChip.d.ts.map +1 -0
  167. package/types/components/Label.d.ts +29 -0
  168. package/types/components/Label.d.ts.map +1 -0
  169. package/types/components/List.d.ts +31 -0
  170. package/types/components/List.d.ts.map +1 -0
  171. package/types/components/ListItem.d.ts +349 -0
  172. package/types/components/ListItem.d.ts.map +1 -0
  173. package/types/components/ListOption.d.ts +1493 -0
  174. package/types/components/ListOption.d.ts.map +1 -0
  175. package/types/components/Listbox.d.ts +12012 -0
  176. package/types/components/Listbox.d.ts.map +1 -0
  177. package/types/components/Menu.d.ts +119 -0
  178. package/types/components/Menu.d.ts.map +1 -0
  179. package/types/components/MenuItem.d.ts +3109 -0
  180. package/types/components/MenuItem.d.ts.map +1 -0
  181. package/types/components/NavBar.d.ts +18 -0
  182. package/types/components/NavBar.d.ts.map +1 -0
  183. package/types/components/NavBarItem.d.ts +186 -0
  184. package/types/components/NavBarItem.d.ts.map +1 -0
  185. package/types/components/NavDrawer.d.ts +108 -0
  186. package/types/components/NavDrawer.d.ts.map +1 -0
  187. package/types/components/NavDrawerItem.d.ts +186 -0
  188. package/types/components/NavDrawerItem.d.ts.map +1 -0
  189. package/types/components/NavItem.d.ts +190 -0
  190. package/types/components/NavItem.d.ts.map +1 -0
  191. package/types/components/NavRail.d.ts +109 -0
  192. package/types/components/NavRail.d.ts.map +1 -0
  193. package/types/components/NavRailItem.d.ts +186 -0
  194. package/types/components/NavRailItem.d.ts.map +1 -0
  195. package/types/components/Page.d.ts +24 -0
  196. package/types/components/Page.d.ts.map +1 -0
  197. package/types/components/Pane.d.ts +44 -0
  198. package/types/components/Pane.d.ts.map +1 -0
  199. package/types/components/Popup.d.ts +76 -0
  200. package/types/components/Popup.d.ts.map +1 -0
  201. package/types/components/Progress.d.ts +19 -0
  202. package/types/components/Progress.d.ts.map +1 -0
  203. package/types/components/Radio.d.ts +199 -0
  204. package/types/components/Radio.d.ts.map +1 -0
  205. package/types/components/RadioIcon.d.ts +46 -0
  206. package/types/components/RadioIcon.d.ts.map +1 -0
  207. package/types/components/Ripple.d.ts +34 -0
  208. package/types/components/Ripple.d.ts.map +1 -0
  209. package/types/components/Root.d.ts +68 -0
  210. package/types/components/Root.d.ts.map +1 -0
  211. package/types/components/Scrim.d.ts +6 -0
  212. package/types/components/Scrim.d.ts.map +1 -0
  213. package/types/components/Search.d.ts +16 -0
  214. package/types/components/Search.d.ts.map +1 -0
  215. package/types/components/SegmentedButton.d.ts +718 -0
  216. package/types/components/SegmentedButton.d.ts.map +1 -0
  217. package/types/components/SegmentedButtonGroup.d.ts +44 -0
  218. package/types/components/SegmentedButtonGroup.d.ts.map +1 -0
  219. package/types/components/Select.d.ts +1361 -0
  220. package/types/components/Select.d.ts.map +1 -0
  221. package/types/components/Shape.d.ts +10 -0
  222. package/types/components/Shape.d.ts.map +1 -0
  223. package/types/components/SideSheet.d.ts +106 -0
  224. package/types/components/SideSheet.d.ts.map +1 -0
  225. package/types/components/Slider.d.ts +382 -0
  226. package/types/components/Slider.d.ts.map +1 -0
  227. package/types/components/Snackbar.d.ts +65 -0
  228. package/types/components/Snackbar.d.ts.map +1 -0
  229. package/types/components/SnackbarContainer.d.ts +6 -0
  230. package/types/components/SnackbarContainer.d.ts.map +1 -0
  231. package/types/components/Surface.d.ts +45 -0
  232. package/types/components/Surface.d.ts.map +1 -0
  233. package/types/components/Switch.d.ts +183 -0
  234. package/types/components/Switch.d.ts.map +1 -0
  235. package/types/components/SwitchIcon.d.ts +169 -0
  236. package/types/components/SwitchIcon.d.ts.map +1 -0
  237. package/types/components/Tab.d.ts +879 -0
  238. package/types/components/Tab.d.ts.map +1 -0
  239. package/types/components/TabContent.d.ts +122 -0
  240. package/types/components/TabContent.d.ts.map +1 -0
  241. package/types/components/TabList.d.ts +6266 -0
  242. package/types/components/TabList.d.ts.map +1 -0
  243. package/types/components/TabPanel.d.ts +28 -0
  244. package/types/components/TabPanel.d.ts.map +1 -0
  245. package/types/components/Table.d.ts +2 -0
  246. package/types/components/Table.d.ts.map +1 -0
  247. package/types/components/TextArea.d.ts +1394 -0
  248. package/types/components/TextArea.d.ts.map +1 -0
  249. package/types/components/Title.d.ts +47 -0
  250. package/types/components/Title.d.ts.map +1 -0
  251. package/types/components/Tooltip.d.ts +49 -0
  252. package/types/components/Tooltip.d.ts.map +1 -0
  253. package/types/components/TopAppBar.d.ts +130 -0
  254. package/types/components/TopAppBar.d.ts.map +1 -0
  255. package/types/constants/colorKeywords.d.ts +2 -0
  256. package/types/constants/colorKeywords.d.ts.map +1 -0
  257. package/types/constants/shapes.d.ts +38 -0
  258. package/types/constants/shapes.d.ts.map +1 -0
  259. package/types/constants/typography.d.ts +212 -0
  260. package/types/constants/typography.d.ts.map +1 -0
  261. package/types/core/Composition.d.ts +252 -0
  262. package/types/core/Composition.d.ts.map +1 -0
  263. package/types/core/CompositionAdapter.d.ts +92 -0
  264. package/types/core/CompositionAdapter.d.ts.map +1 -0
  265. package/types/core/CustomElement.d.ts +302 -0
  266. package/types/core/CustomElement.d.ts.map +1 -0
  267. package/types/core/css.d.ts +44 -0
  268. package/types/core/css.d.ts.map +1 -0
  269. package/types/core/customTypes.d.ts +26 -0
  270. package/types/core/customTypes.d.ts.map +1 -0
  271. package/types/core/dom.d.ts +32 -0
  272. package/types/core/dom.d.ts.map +1 -0
  273. package/types/core/jsonMergePatch.d.ts +31 -0
  274. package/types/core/jsonMergePatch.d.ts.map +1 -0
  275. package/types/core/observe.d.ts +113 -0
  276. package/types/core/observe.d.ts.map +1 -0
  277. package/types/core/optimizations.d.ts +7 -0
  278. package/types/core/optimizations.d.ts.map +1 -0
  279. package/types/core/template.d.ts +47 -0
  280. package/types/core/template.d.ts.map +1 -0
  281. package/types/core/uid.d.ts +6 -0
  282. package/types/core/uid.d.ts.map +1 -0
  283. package/types/dom/HTMLOptionsCollectionProxy.d.ts +18 -0
  284. package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -0
  285. package/types/index.d.ts +88 -0
  286. package/types/index.d.ts.map +1 -0
  287. package/types/loaders/palette.d.ts +2 -0
  288. package/types/loaders/palette.d.ts.map +1 -0
  289. package/types/loaders/theme.d.ts +2 -0
  290. package/types/loaders/theme.d.ts.map +1 -0
  291. package/types/mixins/AriaReflectorMixin.d.ts +23 -0
  292. package/types/mixins/AriaReflectorMixin.d.ts.map +1 -0
  293. package/types/mixins/AriaToolbarMixin.d.ts +32 -0
  294. package/types/mixins/AriaToolbarMixin.d.ts.map +1 -0
  295. package/types/mixins/ControlMixin.d.ts +124 -0
  296. package/types/mixins/ControlMixin.d.ts.map +1 -0
  297. package/types/mixins/DelegatesFocusMixin.d.ts +5 -0
  298. package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -0
  299. package/types/mixins/DensityMixin.d.ts +5 -0
  300. package/types/mixins/DensityMixin.d.ts.map +1 -0
  301. package/types/mixins/ElevationMixin.d.ts +33 -0
  302. package/types/mixins/ElevationMixin.d.ts.map +1 -0
  303. package/types/mixins/FlexableMixin.d.ts +13 -0
  304. package/types/mixins/FlexableMixin.d.ts.map +1 -0
  305. package/types/mixins/FormAssociatedMixin.d.ts +122 -0
  306. package/types/mixins/FormAssociatedMixin.d.ts.map +1 -0
  307. package/types/mixins/HyperlinkMixin.d.ts +22 -0
  308. package/types/mixins/HyperlinkMixin.d.ts.map +1 -0
  309. package/types/mixins/InputMixin.d.ts +179 -0
  310. package/types/mixins/InputMixin.d.ts.map +1 -0
  311. package/types/mixins/KeyboardNavMixin.d.ts +47 -0
  312. package/types/mixins/KeyboardNavMixin.d.ts.map +1 -0
  313. package/types/mixins/NavigationListenerMixin.d.ts +8 -0
  314. package/types/mixins/NavigationListenerMixin.d.ts.map +1 -0
  315. package/types/mixins/PopupMixin.d.ts +82 -0
  316. package/types/mixins/PopupMixin.d.ts.map +1 -0
  317. package/types/mixins/RTLObserverMixin.d.ts +7 -0
  318. package/types/mixins/RTLObserverMixin.d.ts.map +1 -0
  319. package/types/mixins/ResizeObserverMixin.d.ts +12 -0
  320. package/types/mixins/ResizeObserverMixin.d.ts.map +1 -0
  321. package/types/mixins/RippleMixin.d.ts +92 -0
  322. package/types/mixins/RippleMixin.d.ts.map +1 -0
  323. package/types/mixins/ScrollListenerMixin.d.ts +41 -0
  324. package/types/mixins/ScrollListenerMixin.d.ts.map +1 -0
  325. package/types/mixins/SemiStickyMixin.d.ts +50 -0
  326. package/types/mixins/SemiStickyMixin.d.ts.map +1 -0
  327. package/types/mixins/ShapeMaskedMixin.d.ts +9 -0
  328. package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -0
  329. package/types/mixins/ShapeMixin.d.ts +38 -0
  330. package/types/mixins/ShapeMixin.d.ts.map +1 -0
  331. package/types/mixins/StateMixin.d.ts +27 -0
  332. package/types/mixins/StateMixin.d.ts.map +1 -0
  333. package/types/mixins/TextFieldMixin.d.ts +1354 -0
  334. package/types/mixins/TextFieldMixin.d.ts.map +1 -0
  335. package/types/mixins/ThemableMixin.d.ts +9 -0
  336. package/types/mixins/ThemableMixin.d.ts.map +1 -0
  337. package/types/mixins/TooltipTriggerMixin.d.ts +106 -0
  338. package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -0
  339. package/types/mixins/TouchTargetMixin.d.ts +3 -0
  340. package/types/mixins/TouchTargetMixin.d.ts.map +1 -0
  341. package/types/mixins/TypographyMixin.d.ts +17 -0
  342. package/types/mixins/TypographyMixin.d.ts.map +1 -0
  343. package/types/services/rtl.d.ts +3 -0
  344. package/types/services/rtl.d.ts.map +1 -0
  345. package/types/services/svgAlias.d.ts +13 -0
  346. package/types/services/svgAlias.d.ts.map +1 -0
  347. package/types/services/theme.d.ts +45 -0
  348. package/types/services/theme.d.ts.map +1 -0
  349. package/types/utils/cli.d.ts +3 -0
  350. package/types/utils/cli.d.ts.map +1 -0
  351. package/types/utils/function.d.ts +3 -0
  352. package/types/utils/function.d.ts.map +1 -0
  353. package/types/utils/jsx-runtime.d.ts +20 -0
  354. package/types/utils/jsx-runtime.d.ts.map +1 -0
  355. package/types/utils/material-color/blend.d.ts +34 -0
  356. package/types/utils/material-color/blend.d.ts.map +1 -0
  357. package/types/utils/material-color/hct/Cam16.d.ts +142 -0
  358. package/types/utils/material-color/hct/Cam16.d.ts.map +1 -0
  359. package/types/utils/material-color/hct/Hct.d.ts +93 -0
  360. package/types/utils/material-color/hct/Hct.d.ts.map +1 -0
  361. package/types/utils/material-color/hct/ViewingConditions.d.ts +69 -0
  362. package/types/utils/material-color/hct/ViewingConditions.d.ts.map +1 -0
  363. package/types/utils/material-color/hct/hctSolver.d.ts +30 -0
  364. package/types/utils/material-color/hct/hctSolver.d.ts.map +1 -0
  365. package/types/utils/material-color/helper.d.ts +8 -0
  366. package/types/utils/material-color/helper.d.ts.map +1 -0
  367. package/types/utils/material-color/palettes/CorePalette.d.ts +75 -0
  368. package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -0
  369. package/types/utils/material-color/palettes/TonalPalette.d.ts +38 -0
  370. package/types/utils/material-color/palettes/TonalPalette.d.ts.map +1 -0
  371. package/types/utils/material-color/scheme/Scheme.d.ts +264 -0
  372. package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -0
  373. package/types/utils/material-color/utils/color.d.ts +172 -0
  374. package/types/utils/material-color/utils/color.d.ts.map +1 -0
  375. package/types/utils/material-color/utils/math.d.ts +94 -0
  376. package/types/utils/material-color/utils/math.d.ts.map +1 -0
  377. package/types/utils/pixelmatch.d.ts +22 -0
  378. package/types/utils/pixelmatch.d.ts.map +1 -0
  379. package/types/utils/popup.d.ts +106 -0
  380. package/types/utils/popup.d.ts.map +1 -0
  381. package/types/utils/searchParams.d.ts +3 -0
  382. package/types/utils/searchParams.d.ts.map +1 -0
  383. package/types/utils/svg.d.ts +7 -0
  384. package/types/utils/svg.d.ts.map +1 -0
  385. package/utils/{hct → material-color}/blend.js +8 -10
  386. package/utils/{hct → material-color/hct}/Cam16.js +196 -69
  387. package/utils/{hct → material-color/hct}/Hct.js +61 -19
  388. package/utils/{hct → material-color/hct}/ViewingConditions.js +3 -3
  389. package/utils/{hct → material-color/hct}/hctSolver.js +9 -16
  390. package/utils/{hct → material-color}/helper.js +11 -18
  391. package/utils/{hct → material-color/palettes}/CorePalette.js +79 -19
  392. package/utils/{hct → material-color/palettes}/TonalPalette.js +12 -4
  393. package/utils/material-color/scheme/Scheme.js +376 -0
  394. package/utils/{hct/colorUtils.js → material-color/utils/color.js} +61 -1
  395. package/utils/pixelmatch.js +360 -0
  396. package/utils/popup.js +127 -30
  397. package/utils/searchParams.js +19 -0
  398. package/components/ExtendedFab.js +0 -36
  399. package/components/Layout.js +0 -35
  400. package/components/ListSelect.js +0 -220
  401. package/components/Nav.js +0 -40
  402. package/components/Option.js +0 -91
  403. package/core/ICustomElement.d.ts +0 -291
  404. package/core/ICustomElement.js +0 -1
  405. package/core/identify.js +0 -40
  406. package/core/typings.d.ts +0 -136
  407. package/core/typings.js +0 -1
  408. package/mixins/SurfaceMixin.js +0 -181
  409. package/theming/loader.js +0 -22
  410. package/utils/hct/Scheme.js +0 -587
  411. /package/{utils/color_keywords.js → constants/colorKeywords.js} +0 -0
  412. /package/utils/{hct/mathUtils.js → material-color/utils/math.js} +0 -0
@@ -0,0 +1,725 @@
1
+ import { attemptFocus, isRtl } from '../core/dom.js';
2
+ import { canAnchorPopup } from '../utils/popup.js';
3
+
4
+ import DelegatesFocusMixin from './DelegatesFocusMixin.js';
5
+ import '../components/Scrim.js';
6
+ import ResizeObserverMixin from './ResizeObserverMixin.js';
7
+
8
+ const supportsHTMLDialogElement = typeof HTMLDialogElement !== 'undefined';
9
+
10
+ /**
11
+ * @typedef {Object} PopupStack
12
+ * @prop {Element} element
13
+ * @prop {Element} previousFocus
14
+ * @prop {boolean} [centered=false]
15
+ * @prop {Record<string, any>} [state]
16
+ * @prop {Record<string, any>} [previousState]
17
+ * @prop {any} [pendingResizeOperation]
18
+ * @prop {window['history']['scrollRestoration']} [scrollRestoration]
19
+ */
20
+
21
+ /** @type {PopupStack[]} */
22
+ const OPEN_POPUPS = [];
23
+
24
+ /**
25
+ * @return {void}
26
+ */
27
+ function onWindowResize() {
28
+ // Fire in popup order
29
+ for (const { element } of OPEN_POPUPS) {
30
+ element.updatePopupPosition();
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Prevent focus being given to elements via mouse nav back
36
+ * @param {MouseEvent} event
37
+ */
38
+ function onNavMouseDown(event) {
39
+ if (event.button === 3) {
40
+ event.preventDefault();
41
+ }
42
+ }
43
+
44
+ /**
45
+ * @param {PopStateEvent} event
46
+ */
47
+ function onPopState(event) {
48
+ if (!event.state) return;
49
+ const lastOpenPopup = OPEN_POPUPS.at(-1);
50
+ if (!lastOpenPopup || !lastOpenPopup.previousState) {
51
+ return;
52
+ }
53
+ if ((lastOpenPopup.previousState === event.state) || Object.keys(event.state)
54
+ .every((key) => event.state[key] === lastOpenPopup.previousState[key])) {
55
+ // Close (cancel event) can be prevented. Fire and check if prevented
56
+ const cancelEvent = new Event('cancel', { cancelable: true });
57
+ if (lastOpenPopup.element.dispatchEvent(cancelEvent)) {
58
+ lastOpenPopup.element.close();
59
+ } else {
60
+ // Revert pop state by pushing state again
61
+ window.history.pushState(lastOpenPopup.state, lastOpenPopup.state.title);
62
+ }
63
+ }
64
+ }
65
+
66
+ /** @param {BeforeUnloadEvent} event */
67
+ function onBeforeUnload(event) {
68
+ if (!OPEN_POPUPS.length) return;
69
+ console.warn('Popup was open during page unload (refresh?).');
70
+ }
71
+
72
+ /**
73
+ * @param {typeof import('../core/CustomElement.js').default} Base
74
+ */
75
+ export default function PopupMixin(Base) {
76
+ return Base
77
+ .mixin(DelegatesFocusMixin)
78
+ .mixin(ResizeObserverMixin)
79
+ .observe({
80
+ open: 'boolean',
81
+ modal: 'boolean',
82
+ native: 'boolean',
83
+ scrollable: 'boolean',
84
+ matchSourceWidth: 'boolean',
85
+ _currentFlow: 'string',
86
+ flow: {
87
+ type: 'string',
88
+ /** @type {'corner'|'adjacent'|'overflow'|'vcenter'|'hcenter'|'center'} */
89
+ value: null,
90
+ },
91
+ popupMargin: 'float',
92
+ })
93
+ .set({
94
+ useHistory: true,
95
+ returnValue: '',
96
+ _closing: false,
97
+ _useScrim: false,
98
+ })
99
+ .define({
100
+ _dialog() {
101
+ return /** @type {HTMLDialogElement} */ (this.refs.dialog);
102
+ },
103
+ })
104
+ .methods({
105
+ /**
106
+ * @param {DOMRect|Element} [anchor]
107
+ * @return {void}
108
+ */
109
+ updatePopupPosition(anchor = this._anchor) {
110
+ const flow = this._currentFlow ?? this.flow;
111
+ Object.assign(this.style, {
112
+ top: '0',
113
+ left: '0',
114
+ right: 'auto',
115
+ bottom: 'auto',
116
+ maxWidth: null,
117
+ maxHeight: null,
118
+ });
119
+
120
+ const layoutElement = this.native ? this._dialog : this;
121
+ Object.assign(layoutElement.style, { width: 'auto', height: 'auto' });
122
+
123
+ const width = (anchor && this.matchSourceWidth)
124
+ ? anchor.clientWidth
125
+ : 56 * Math.ceil(layoutElement.clientWidth / 56);
126
+
127
+ layoutElement.style.setProperty('width', `${width}px`);
128
+
129
+ const height = layoutElement.clientHeight;
130
+ Object.assign(layoutElement.style, { height: null });
131
+
132
+ /** @type {import('../utils/popup.js').CanAnchorPopUpOptions} */
133
+ const anchorOptions = {
134
+ anchor,
135
+ width,
136
+ height,
137
+ margin: this.popupMargin ?? (window.innerWidth < 648 ? 16 : 24),
138
+ };
139
+
140
+ const isPageRTL = isRtl(this);
141
+ const xStart = isPageRTL ? 'right' : 'left';
142
+ const xEnd = isPageRTL ? 'left' : 'right';
143
+
144
+ /* Automatic Positioning
145
+ *
146
+ * Positions:
147
+ *
148
+ * 3 7 4
149
+ * ┌─────────┐
150
+ * │ │
151
+ * 5 │ 9 │ 6
152
+ * │ │
153
+ * └─────────┘
154
+ * 1 8 2
155
+ *
156
+ * 1: Bottom Left
157
+ * 2: Bottom Right
158
+ * 3: Top Left
159
+ * 4: Top Right
160
+ * 5: VCenter Left
161
+ * 6: VCenter Right
162
+ * 7: HCenter Top
163
+ * 8: HCenter Bottom
164
+ * 9: VCenter HCenter
165
+ *
166
+ * Directions:
167
+ * a - Down LTR
168
+ * b - Down RTL
169
+ * c - Up LTR
170
+ * d - Up RTL
171
+ * e - LTR
172
+ * f - RTL
173
+ * g - Down
174
+ * h - Up
175
+ * i - Center
176
+ *
177
+ *
178
+ * 16 total combos
179
+ * 1a 1b 1c 1d └↘ └↙ └↗ └↖
180
+ * 2a 2b 2c 2d ┘↘ ┘↙ ┘↗ ┘↖
181
+ * 3a 3b 3c 3d ┌↘ ┌↙ ┌↗ ┌↖
182
+ * 4a 4b 4c 4d ┐↘ ┐↙ ┐↗ ┐↖
183
+ *
184
+ * Avoid using opposite angle
185
+ *
186
+ * 1a XX 1c 1d └↘ ██ └↗ └↖
187
+ * XX 2b 2c 2d ██ ┘↙ ┘↗ ┘↖
188
+ * 1a 3b 3c XX ┌↘ ┌↙ ┌↗ ██
189
+ * 4a 4b XX 4d ┐↘ ┐↙ ██ ┐↖
190
+ *
191
+ *
192
+ * Preference Order:
193
+ * - Flow from corner 1a 2b 3c 4d └↘ ┘↙ ┌↗ ┐↖
194
+ * - Open adjacent to target 4a 3b 2c 1d ┐↘ ┌↙ ┘↗ └↖
195
+ * - Overlay target 3a 4b 1c 2d ┌↘ ┐↙ └↗ ┘↖
196
+ * - Open from horizontal side 5e 6f │→ │←
197
+ * - Open from center 9i █·
198
+ */
199
+
200
+ /** @type {import('../utils/popup.js').CanAnchorPopUpOptions[]} */
201
+ const preferences = [
202
+ ((flow ?? 'corner') === 'corner') ? [
203
+ { clientY: 'bottom', clientX: xStart },
204
+ { clientY: 'bottom', clientX: xEnd },
205
+ { clientY: 'top', clientX: xStart },
206
+ { clientY: 'top', clientX: xEnd },
207
+ ] : [],
208
+ ((flow ?? 'adjacent') === 'adjacent') ? [
209
+ { clientY: 'top', clientX: xEnd, directionX: xEnd, directionY: 'down' },
210
+ { clientY: 'top', clientX: xStart, directionX: xStart, directionY: 'down' },
211
+ { clientY: 'bottom', clientX: xEnd, directionX: xEnd, directionY: 'up' },
212
+ { clientY: 'bottom', clientX: xStart, directionX: xStart, directionY: 'up' },
213
+ ] : [],
214
+ ((flow ?? 'overlay') === 'overlay') ? [
215
+ { clientY: 'top', clientX: xStart, directionX: xEnd, directionY: 'down' },
216
+ { clientY: 'top', clientX: xEnd, directionX: xStart, directionY: 'down' },
217
+ { clientY: 'bottom', clientX: xStart, directionX: xEnd, directionY: 'up' },
218
+ { clientY: 'bottom', clientX: xEnd, directionX: xStart, directionY: 'up' },
219
+ ] : [],
220
+ ((flow ?? 'vcenter') === 'vcenter') ? [
221
+ { clientY: 'center', clientX: xEnd, directionX: xEnd, directionY: 'center' },
222
+ { clientY: 'center', clientX: xStart, directionX: xStart, directionY: 'center' },
223
+ ] : [],
224
+ ((flow ?? 'hcenter') === 'hcenter') ? [
225
+ { clientY: 'bottom', clientX: 'center', directionX: 'center', directionY: 'down' },
226
+ { clientY: 'top', clientX: 'center', directionX: 'center', directionY: 'up' },
227
+ ] : [],
228
+ ((flow ?? 'center') === 'center') ? [
229
+ { clientY: 'center', clientX: 'center', directionX: 'center', directionY: 'center' },
230
+ ] : [],
231
+ ].flat();
232
+
233
+ let anchorResult;
234
+ for (const preference of preferences) {
235
+ const result = canAnchorPopup({
236
+ ...anchorOptions,
237
+ ...preference,
238
+ });
239
+ if (!anchorResult || anchorResult.visibility < result.visibility) {
240
+ anchorResult = result;
241
+ }
242
+ if (result.visibility === 1) break;
243
+ }
244
+
245
+ let { maxWidth, maxHeight } = anchorResult.styles;
246
+ if (maxWidth || maxHeight) {
247
+ const styles = window.getComputedStyle(this);
248
+ if (styles.maxWidth) {
249
+ maxWidth = `min(${maxWidth}, ${styles.maxWidth})`;
250
+ }
251
+ if (styles.maxHeight) {
252
+ maxHeight = `min(${maxHeight}, ${styles.maxHeight})`;
253
+ }
254
+ }
255
+ Object.assign(this.style, { ...anchorResult.styles, maxWidth, maxHeight });
256
+ // this.scrollIntoView();
257
+ },
258
+ /**
259
+ * @param {Event & {currentTarget: HTMLSlotElement}} event
260
+ * @return {void}
261
+ */
262
+ onSlotChange({ currentTarget }) {
263
+ const nodes = currentTarget.assignedNodes();
264
+ const hasContent = nodes.some((node) => (node.nodeType === node.ELEMENT_NODE)
265
+ || (node.nodeType === node.TEXT_NODE && node.nodeValue.trim().length));
266
+ currentTarget.toggleAttribute('slotted', hasContent);
267
+ },
268
+
269
+ /**
270
+ * @param {MouseEvent|PointerEvent|HTMLElement|Event} [source]
271
+ * @param {boolean} focus
272
+ * @param {string} flow
273
+ * @return {boolean} handled
274
+ */
275
+ showPopup(source, focus = true, flow = null) {
276
+ if (this.open) return false;
277
+ this.open = true;
278
+ this._source = source;
279
+ this._anchor = source;
280
+
281
+ const { scrim } = this.refs;
282
+ if (this._useScrim) {
283
+ if (this.native) {
284
+ document.body.append(scrim);
285
+ } else {
286
+ this.before(scrim);
287
+ }
288
+ scrim.hidden = false;
289
+ } else {
290
+ scrim.remove();
291
+ }
292
+
293
+ const previousFocus = source instanceof HTMLElement ? source : document.activeElement;
294
+
295
+ if (supportsHTMLDialogElement && focus // Calling show will force focus which is not intended for non-modals
296
+ && !this._dialog.open) {
297
+ this._dialog.show();
298
+ }
299
+
300
+ this._currentFlow = flow;
301
+
302
+ // Short first, then move
303
+ // Native modals can fail update bounds on Chrome
304
+ this.updatePopupPosition(source);
305
+
306
+ let newState;
307
+ let scrollRestoration;
308
+ let previousState;
309
+ if (this.useHistory) {
310
+ newState = { hash: Math.random().toString(36).slice(2, 18) };
311
+
312
+ if (!window.history.state) {
313
+ // Create new previous state
314
+ window.history.replaceState({
315
+ hash: Math.random().toString(36).slice(2, 18),
316
+ }, document.title);
317
+ }
318
+ previousState = window.history.state;
319
+
320
+ scrollRestoration = window.history.scrollRestoration;
321
+
322
+ window.history.scrollRestoration = 'manual';
323
+ window.history.pushState(newState, document.title);
324
+ window.addEventListener('popstate', onPopState);
325
+ window.addEventListener('beforeunload', onBeforeUnload);
326
+ }
327
+
328
+ window.addEventListener('mousedown', onNavMouseDown, { capture: true });
329
+
330
+ window.addEventListener('resize', onWindowResize);
331
+ window.addEventListener('scroll', onWindowResize);
332
+ if (window.visualViewport) {
333
+ window.visualViewport.addEventListener('resize', onWindowResize);
334
+ window.visualViewport.addEventListener('scroll', onWindowResize);
335
+ }
336
+
337
+ OPEN_POPUPS.push({
338
+ element: this,
339
+ previousFocus,
340
+ state: newState,
341
+ previousState,
342
+ scrollRestoration,
343
+ });
344
+
345
+ // Overrideable
346
+ if (focus) {
347
+ this.focus();
348
+ }
349
+
350
+ return true;
351
+ },
352
+ /**
353
+ * @param {MouseEvent|PointerEvent|HTMLElement|Event} [source]
354
+ * @param {boolean} [focus]
355
+ * @param {string} [flow]
356
+ * @return {boolean} handled
357
+ */
358
+ showModal(source, focus, flow) {
359
+ if (this.open) return false;
360
+ this.modal = true;
361
+ if (supportsHTMLDialogElement) {
362
+ this._dialog.showModal();
363
+ this.native = true;
364
+ }
365
+ return this.showPopup(source, focus, flow);
366
+ },
367
+ /**
368
+ * @param {MouseEvent|PointerEvent|HTMLElement|Event} [source]
369
+ * @param {boolean} [focus]
370
+ * @param {string} [flow]
371
+ * @return {boolean} handled
372
+ */
373
+ show(source, focus, flow) {
374
+ // Auto-select type based on default platform convention
375
+ // Mac OS X / iPad does not expect clickthrough
376
+ if (navigator.userAgent.includes('Mac OS X')) {
377
+ return this.showModal(source, focus, flow);
378
+ }
379
+ return this.showPopup(source, focus, flow);
380
+ },
381
+ /**
382
+ * @param {any} [returnValue]
383
+ * @param {boolean} [returnFocus=true]
384
+ * @return {boolean} handled
385
+ */
386
+ close(returnValue = undefined, returnFocus = true) {
387
+ if (!this.open) return false;
388
+ if (this._closing) return false;
389
+ this._source = null;
390
+ this._closing = true;
391
+ this.modal = false;
392
+
393
+ // SCRIM
394
+ this.refs.scrim.hidden = true;
395
+
396
+ if (this.native) {
397
+ this.native = false;
398
+ } else {
399
+ const main = document.querySelector('main');
400
+ if (main) {
401
+ main.removeAttribute('aria-hidden');
402
+ }
403
+ }
404
+ // if (this.dialogElement.getAttribute('aria-hidden') === 'true') return false;
405
+ if (supportsHTMLDialogElement && this._dialog.open) {
406
+ const previousFocus = document.activeElement;
407
+ // Closing a native dialog will return focus automatically.
408
+ this._dialog.close();
409
+ if (!attemptFocus(previousFocus, { preventScroll: true })) {
410
+ document.activeElement?.blur?.();
411
+ }
412
+ } else {
413
+ this._dialog.returnValue = returnValue;
414
+ }
415
+
416
+ // Will invoke observed attribute change: ('aria-hidden', 'true');
417
+ this.open = false;
418
+ this._currentFlow = null;
419
+
420
+ this.dispatchEvent(new Event('close'));
421
+
422
+ const len = OPEN_POPUPS.length;
423
+ for (let i = len - 1; i >= 0; i--) {
424
+ const entry = OPEN_POPUPS[i];
425
+ if (entry.element === this) {
426
+ if (this.useHistory) {
427
+ if (entry.state && window.history
428
+ && window.history.state && entry.state.hash === window.history.state.hash) {
429
+ window.removeEventListener('popstate', onPopState);
430
+ window.history.back();
431
+ // Back does not set state immediately
432
+ // Needed to track submenu
433
+ // TODO: use window.history.go(indexDelta) instead for Safari (not Webkit) submenu support
434
+ window.history.replaceState(entry.previousState, document.title);
435
+ window.history.scrollRestoration = entry.scrollRestoration || 'auto';
436
+ window.addEventListener('popstate', onPopState);
437
+ } else {
438
+ console.warn('Menu state mismatch?', entry, window.history.state);
439
+ }
440
+ }
441
+ if (returnFocus) {
442
+ // console.log('not returning focus');
443
+ entry.previousFocus?.focus?.({ preventScroll: true });
444
+ }
445
+ OPEN_POPUPS.splice(i, 1);
446
+ break;
447
+ } else if (this.contains(entry.element)) {
448
+ // console.debug('Closing submenu first');
449
+ entry.element.close(false);
450
+ // console.debug('Sub menu closed. Continuing...');
451
+ }
452
+ }
453
+ if (!OPEN_POPUPS.length) {
454
+ window.removeEventListener('popstate', onPopState);
455
+ window.removeEventListener('beforeunload', onBeforeUnload);
456
+ window.removeEventListener('resize', onWindowResize);
457
+ window.removeEventListener('mousedown', onNavMouseDown, { capture: true });
458
+ // console.debug('All menus closed');
459
+ }
460
+ this._closing = false;
461
+ return true;
462
+ },
463
+ })
464
+
465
+ .overrides({
466
+ onResizeObserved(entry) {
467
+ if (!this.open || this._closing) return;
468
+ this.updatePopupPosition();
469
+ },
470
+ })
471
+ .expressions({
472
+ _ariaHidden({ open }) { return (open ? 'false' : 'true'); },
473
+ })
474
+ .html`
475
+ <mdw-scrim id=scrim tabindex=-1 aria-hidden=true></mdw-scrim>
476
+ <dialog id=dialog aria-modal=true role=dialog
477
+ aria-hidden={_ariaHidden} scrollable={scrollable}>
478
+ <slot id=slot on-slotchange={onSlotChange}></slot>
479
+ </dialog>
480
+ `
481
+ .css`
482
+ /* https://m3.material.io/components/dialogs/specs */
483
+
484
+ :host([popover]) {
485
+ margin: 0;
486
+ border: 0;
487
+ padding: 0;
488
+ }
489
+
490
+ :host(::backdrop) {
491
+ display: none;
492
+ }
493
+
494
+ :host {
495
+ --mdw-popup__expand-duration: var(--mdw-motion-expand-duration, 250ms);
496
+ --mdw-popup__simple-duration: var(--mdw-motion-simple-duration, 100ms);
497
+ --mdw-popup__standard-easing: var(--mdw-motion-standard-easing, cubic-bezier(0.4, 0.0, 0.2, 1));
498
+ --mdw-popup__deceleration-easing: var(--mdw-motion-deceleration-easing, cubic-bezier(0.0, 0.0, 0.2, 1));
499
+ --mdw-popup__fade-in-duration: var(--mdw-motion-fade-in-duration, 150ms);
500
+
501
+ --mdw-shape__size: 28px;
502
+
503
+ /* padding-inline: 12px; */
504
+
505
+ --mdw-bg: var(--mdw-color__surface);
506
+ --mdw-ink: var(--mdw-color__on-surface);
507
+
508
+ position: fixed;
509
+
510
+ inset-block-start: 0;
511
+ inset-inline-start: 0;
512
+ align-self: center;
513
+ justify-self: center;
514
+
515
+ display: block;
516
+ overflow: auto;
517
+ -webkit-overflow-scrolling: touch;
518
+ overscroll-behavior: none;
519
+ overscroll-behavior: contain;
520
+
521
+ box-sizing: border-box;
522
+ block-size: auto;
523
+ min-block-size: none;
524
+ max-block-size: 100vh;
525
+ inline-size: auto;
526
+ min-inline-size: none;
527
+ max-inline-size: 100vw;
528
+
529
+ outline: none; /* Older Chromium Builds */
530
+
531
+ pointer-events: none;
532
+
533
+ opacity: 0;
534
+ transform: scale(0);
535
+
536
+ visibility: hidden;
537
+ z-index: 24;
538
+
539
+ color: rgb(var(--mdw-ink));
540
+
541
+ font: var(--mdw-type__font);
542
+ letter-spacing: var(--mdw-type__letter-spacing);
543
+
544
+ transition-delay: 200ms, 0s;
545
+ transition-duration: 0s, 200ms, 200ms;
546
+ transition-property: visibility, opacity, transform;
547
+ transition-timing-function: ease-out;
548
+
549
+ will-change: visibility, opacity, transform;
550
+
551
+ }
552
+
553
+ :host([open]) {
554
+ pointer-events: inherit;
555
+
556
+ opacity: 1;
557
+
558
+ transform: none;
559
+ visibility: inherit;
560
+
561
+ transition-delay: 0s;
562
+ transition-timing-function: ease-in;
563
+ }
564
+
565
+ :host([native][open]) {
566
+ opacity: 0;
567
+ }
568
+
569
+ #dialog {
570
+ position: static;
571
+ inset-block-start: 0;
572
+ inset-inline-start: 0;
573
+
574
+ display: contents;
575
+ align-items: inherit;
576
+ flex-direction: inherit;
577
+ gap: inherit;
578
+ justify-content: inherit;
579
+ justify-items: inherit;
580
+ place-items: inherit;
581
+
582
+ box-sizing: border-box;
583
+ block-size: inherit;
584
+ flex: inherit;
585
+ margin:0;
586
+ border: none;
587
+ padding: inherit;
588
+ padding: 0;
589
+
590
+ pointer-events: inherit;
591
+
592
+ filter: inherit;
593
+
594
+ opacity: 1;
595
+
596
+ transform:inherit;
597
+ visibility: inherit;
598
+ /* visiblity:hidden still registers events, hide from pointer with scale(0) */
599
+ z-index: 24;
600
+
601
+ background-color: transparent;
602
+
603
+ color:inherit;
604
+
605
+ }
606
+
607
+ :host([color]) {
608
+ background-color: rgb(var(--mdw-bg));
609
+ color: rgb(var(--mdw-ink));
610
+ }
611
+
612
+ :host(:is([color="none"],[color="transparent"])) {
613
+ background-color: transparent;
614
+ color: inherit;
615
+ }
616
+
617
+ :host([scrollable]) {
618
+ overflow-y:auto;
619
+ }
620
+
621
+ #dialog::backdrop {
622
+ /** Use scrim instead */
623
+ background-color: transparent;
624
+ }
625
+
626
+ #dialog:modal {
627
+ position: inherit;
628
+ inset: inherit;
629
+
630
+ display: inherit;
631
+ align-items: inherit;
632
+ flex-direction: inherit;
633
+ gap: inherit;
634
+ justify-content: inherit;
635
+ justify-items: inherit;
636
+ place-items: inherit;
637
+
638
+ block-size: auto;
639
+ min-block-size: inherit;
640
+ max-block-size: inherit;
641
+
642
+ inline-size:auto;
643
+ min-inline-size: inherit;
644
+ max-inline-size: inherit;
645
+ flex: inherit;
646
+ padding: inherit;
647
+
648
+ pointer-events: inherit;
649
+
650
+ filter: inherit;
651
+ transform: inherit;
652
+ visibility: inherit;
653
+
654
+ background-color: inherit;
655
+ border-radius: inherit;
656
+ }
657
+
658
+ #dialog[scrollable][open] {
659
+ display: inherit;
660
+ align-items: inherit;
661
+ flex-direction: inherit;
662
+ gap: inherit;
663
+ justify-content: inherit;
664
+ justify-items: inherit;
665
+
666
+ place-items: inherit;
667
+
668
+ block-size: 100%;
669
+ max-block-size: none;
670
+ inline-size: 100%;
671
+ max-inline-size: none;
672
+
673
+ flex: 1;
674
+ }
675
+
676
+
677
+
678
+ #dialog[scrollable][open]:modal {
679
+ overflow:auto;
680
+
681
+ block-size:100%;
682
+ min-block-size: none;
683
+ max-block-size: inherit;
684
+ inline-size:100%;
685
+ min-inline-size: none;
686
+ max-inline-size: inherit;
687
+ flex: inherit;
688
+ padding: inherit;
689
+ }
690
+
691
+
692
+ `
693
+ .childEvents({
694
+ dialog: {
695
+ cancel(event) {
696
+ event.stopPropagation();
697
+ const cancelEvent = new Event('cancel', { cancelable: true });
698
+ if (!this.dispatchEvent(cancelEvent)) {
699
+ event.preventDefault();
700
+ }
701
+ },
702
+ close(event) {
703
+ event.stopPropagation();
704
+ this.close(this.returnValue);
705
+ },
706
+ '~click'(event) {
707
+ // Track if click on backdrop
708
+ if (event.target !== event.currentTarget) return;
709
+ if (!this.native) return;
710
+ if (event.offsetX >= 0 && event.offsetX < event.currentTarget.offsetWidth
711
+ && event.offsetY >= 0 && event.offsetY < event.currentTarget.offsetHeight) return;
712
+ const cancelEvent = new Event('cancel', { cancelable: true });
713
+ if (!this.dispatchEvent(cancelEvent)) return;
714
+ this.close();
715
+ },
716
+ },
717
+ scrim: {
718
+ '~click'() {
719
+ const cancelEvent = new Event('cancel', { cancelable: true });
720
+ if (!this.dispatchEvent(cancelEvent)) return;
721
+ this.close();
722
+ },
723
+ },
724
+ });
725
+ }