@m3e/core 1.0.0-rc.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 (357) hide show
  1. package/LICENSE +22 -0
  2. package/NOTICE.md +8 -0
  3. package/README.md +59 -0
  4. package/cem.config.mjs +16 -0
  5. package/demo/index.html +58 -0
  6. package/dist/a11y.js +1431 -0
  7. package/dist/a11y.js.map +1 -0
  8. package/dist/a11y.min.js +87 -0
  9. package/dist/a11y.min.js.map +1 -0
  10. package/dist/anchoring.js +1748 -0
  11. package/dist/anchoring.js.map +1 -0
  12. package/dist/anchoring.min.js +7 -0
  13. package/dist/anchoring.min.js.map +1 -0
  14. package/dist/bidi.js +106 -0
  15. package/dist/bidi.js.map +1 -0
  16. package/dist/bidi.min.js +16 -0
  17. package/dist/bidi.min.js.map +1 -0
  18. package/dist/css-custom-data.json +257 -0
  19. package/dist/custom-elements.json +13504 -0
  20. package/dist/html-custom-data.json +199 -0
  21. package/dist/index.js +4342 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/index.min.js +520 -0
  24. package/dist/index.min.js.map +1 -0
  25. package/dist/layout.js +64 -0
  26. package/dist/layout.js.map +1 -0
  27. package/dist/layout.min.js +15 -0
  28. package/dist/layout.min.js.map +1 -0
  29. package/dist/platform.js +56 -0
  30. package/dist/platform.js.map +1 -0
  31. package/dist/platform.min.js +15 -0
  32. package/dist/platform.min.js.map +1 -0
  33. package/dist/src/a11y/AriaDescriber.d.ts +31 -0
  34. package/dist/src/a11y/AriaDescriber.d.ts.map +1 -0
  35. package/dist/src/a11y/FocusTrapElement.d.ts +25 -0
  36. package/dist/src/a11y/FocusTrapElement.d.ts.map +1 -0
  37. package/dist/src/a11y/InteractivityChecker.d.ts +22 -0
  38. package/dist/src/a11y/InteractivityChecker.d.ts.map +1 -0
  39. package/dist/src/a11y/LiveAnnouncer.d.ts +56 -0
  40. package/dist/src/a11y/LiveAnnouncer.d.ts.map +1 -0
  41. package/dist/src/a11y/aria-reference.d.ts +30 -0
  42. package/dist/src/a11y/aria-reference.d.ts.map +1 -0
  43. package/dist/src/a11y/index.d.ts +8 -0
  44. package/dist/src/a11y/index.d.ts.map +1 -0
  45. package/dist/src/a11y/keycodes/KeyCode.d.ts +118 -0
  46. package/dist/src/a11y/keycodes/KeyCode.d.ts.map +1 -0
  47. package/dist/src/a11y/keycodes/ModifierKeys.d.ts +5 -0
  48. package/dist/src/a11y/keycodes/ModifierKeys.d.ts.map +1 -0
  49. package/dist/src/a11y/keycodes/getKeyCode.d.ts +7 -0
  50. package/dist/src/a11y/keycodes/getKeyCode.d.ts.map +1 -0
  51. package/dist/src/a11y/keycodes/hasModifierKey.d.ts +9 -0
  52. package/dist/src/a11y/keycodes/hasModifierKey.d.ts.map +1 -0
  53. package/dist/src/a11y/keycodes/index.d.ts +6 -0
  54. package/dist/src/a11y/keycodes/index.d.ts.map +1 -0
  55. package/dist/src/a11y/keycodes/isModifierAllowed.d.ts +9 -0
  56. package/dist/src/a11y/keycodes/isModifierAllowed.d.ts.map +1 -0
  57. package/dist/src/a11y/list-key/FocusKeyManager.d.ts +17 -0
  58. package/dist/src/a11y/list-key/FocusKeyManager.d.ts.map +1 -0
  59. package/dist/src/a11y/list-key/ListKeyManager.d.ts +114 -0
  60. package/dist/src/a11y/list-key/ListKeyManager.d.ts.map +1 -0
  61. package/dist/src/a11y/list-key/ListManager.d.ts +37 -0
  62. package/dist/src/a11y/list-key/ListManager.d.ts.map +1 -0
  63. package/dist/src/a11y/list-key/RadioKeyManager.d.ts +20 -0
  64. package/dist/src/a11y/list-key/RadioKeyManager.d.ts.map +1 -0
  65. package/dist/src/a11y/list-key/RovingTabIndexManager.d.ts +22 -0
  66. package/dist/src/a11y/list-key/RovingTabIndexManager.d.ts.map +1 -0
  67. package/dist/src/a11y/list-key/SelectionManager.d.ts +46 -0
  68. package/dist/src/a11y/list-key/SelectionManager.d.ts.map +1 -0
  69. package/dist/src/a11y/list-key/Typeahead.d.ts +64 -0
  70. package/dist/src/a11y/list-key/Typeahead.d.ts.map +1 -0
  71. package/dist/src/a11y/list-key/index.d.ts +8 -0
  72. package/dist/src/a11y/list-key/index.d.ts.map +1 -0
  73. package/dist/src/a11y/visuallyHide.d.ts +6 -0
  74. package/dist/src/a11y/visuallyHide.d.ts.map +1 -0
  75. package/dist/src/anchoring/AnchorOptions.d.ts +15 -0
  76. package/dist/src/anchoring/AnchorOptions.d.ts.map +1 -0
  77. package/dist/src/anchoring/AnchorPosition.d.ts +3 -0
  78. package/dist/src/anchoring/AnchorPosition.d.ts.map +1 -0
  79. package/dist/src/anchoring/index.d.ts +4 -0
  80. package/dist/src/anchoring/index.d.ts.map +1 -0
  81. package/dist/src/anchoring/positionAnchor.d.ts +12 -0
  82. package/dist/src/anchoring/positionAnchor.d.ts.map +1 -0
  83. package/dist/src/bidi/Directionality.d.ts +27 -0
  84. package/dist/src/bidi/Directionality.d.ts.map +1 -0
  85. package/dist/src/bidi/index.d.ts +2 -0
  86. package/dist/src/bidi/index.d.ts.map +1 -0
  87. package/dist/src/index.d.ts +2 -0
  88. package/dist/src/index.d.ts.map +1 -0
  89. package/dist/src/layout/Breakpoint.d.ts +26 -0
  90. package/dist/src/layout/Breakpoint.d.ts.map +1 -0
  91. package/dist/src/layout/BreakpointObserver.d.ts +18 -0
  92. package/dist/src/layout/BreakpointObserver.d.ts.map +1 -0
  93. package/dist/src/layout/index.d.ts +3 -0
  94. package/dist/src/layout/index.d.ts.map +1 -0
  95. package/dist/src/platform/Platform.d.ts +34 -0
  96. package/dist/src/platform/Platform.d.ts.map +1 -0
  97. package/dist/src/platform/index.d.ts +2 -0
  98. package/dist/src/platform/index.d.ts.map +1 -0
  99. package/dist/src/shared/controllers/FocusController.d.ts +30 -0
  100. package/dist/src/shared/controllers/FocusController.d.ts.map +1 -0
  101. package/dist/src/shared/controllers/HoverController.d.ts +40 -0
  102. package/dist/src/shared/controllers/HoverController.d.ts.map +1 -0
  103. package/dist/src/shared/controllers/IntersectionController.d.ts +40 -0
  104. package/dist/src/shared/controllers/IntersectionController.d.ts.map +1 -0
  105. package/dist/src/shared/controllers/LongPressController.d.ts +32 -0
  106. package/dist/src/shared/controllers/LongPressController.d.ts.map +1 -0
  107. package/dist/src/shared/controllers/MonitorControllerBase.d.ts +62 -0
  108. package/dist/src/shared/controllers/MonitorControllerBase.d.ts.map +1 -0
  109. package/dist/src/shared/controllers/MutationController.d.ts +37 -0
  110. package/dist/src/shared/controllers/MutationController.d.ts.map +1 -0
  111. package/dist/src/shared/controllers/PressedController.d.ts +45 -0
  112. package/dist/src/shared/controllers/PressedController.d.ts.map +1 -0
  113. package/dist/src/shared/controllers/ResizeController.d.ts +40 -0
  114. package/dist/src/shared/controllers/ResizeController.d.ts.map +1 -0
  115. package/dist/src/shared/controllers/ScrollController.d.ts +34 -0
  116. package/dist/src/shared/controllers/ScrollController.d.ts.map +1 -0
  117. package/dist/src/shared/controllers/index.d.ts +9 -0
  118. package/dist/src/shared/controllers/index.d.ts.map +1 -0
  119. package/dist/src/shared/decorators/debounce.d.ts +7 -0
  120. package/dist/src/shared/decorators/debounce.d.ts.map +1 -0
  121. package/dist/src/shared/decorators/index.d.ts +2 -0
  122. package/dist/src/shared/decorators/index.d.ts.map +1 -0
  123. package/dist/src/shared/directives/index.d.ts +2 -0
  124. package/dist/src/shared/directives/index.d.ts.map +1 -0
  125. package/dist/src/shared/directives/safeStyleMap.d.ts +44 -0
  126. package/dist/src/shared/directives/safeStyleMap.d.ts.map +1 -0
  127. package/dist/src/shared/index.d.ts +8 -0
  128. package/dist/src/shared/index.d.ts.map +1 -0
  129. package/dist/src/shared/mixins/AttachInternals.d.ts +24 -0
  130. package/dist/src/shared/mixins/AttachInternals.d.ts.map +1 -0
  131. package/dist/src/shared/mixins/Checked.d.ts +24 -0
  132. package/dist/src/shared/mixins/Checked.d.ts.map +1 -0
  133. package/dist/src/shared/mixins/CheckedIndeterminate.d.ts +25 -0
  134. package/dist/src/shared/mixins/CheckedIndeterminate.d.ts.map +1 -0
  135. package/dist/src/shared/mixins/CheckedOrSelected.d.ts +23 -0
  136. package/dist/src/shared/mixins/CheckedOrSelected.d.ts.map +1 -0
  137. package/dist/src/shared/mixins/ConstraintValidation.d.ts +48 -0
  138. package/dist/src/shared/mixins/ConstraintValidation.d.ts.map +1 -0
  139. package/dist/src/shared/mixins/Constructor.d.ts +3 -0
  140. package/dist/src/shared/mixins/Constructor.d.ts.map +1 -0
  141. package/dist/src/shared/mixins/Dirty.d.ts +27 -0
  142. package/dist/src/shared/mixins/Dirty.d.ts.map +1 -0
  143. package/dist/src/shared/mixins/Disabled.d.ts +25 -0
  144. package/dist/src/shared/mixins/Disabled.d.ts.map +1 -0
  145. package/dist/src/shared/mixins/DisabledInteractive.d.ts +25 -0
  146. package/dist/src/shared/mixins/DisabledInteractive.d.ts.map +1 -0
  147. package/dist/src/shared/mixins/EventAttribute.d.ts +11 -0
  148. package/dist/src/shared/mixins/EventAttribute.d.ts.map +1 -0
  149. package/dist/src/shared/mixins/Focusable.d.ts +11 -0
  150. package/dist/src/shared/mixins/Focusable.d.ts.map +1 -0
  151. package/dist/src/shared/mixins/FormAssociated.d.ts +34 -0
  152. package/dist/src/shared/mixins/FormAssociated.d.ts.map +1 -0
  153. package/dist/src/shared/mixins/FormSubmitter.d.ts +31 -0
  154. package/dist/src/shared/mixins/FormSubmitter.d.ts.map +1 -0
  155. package/dist/src/shared/mixins/HtmlFor.d.ts +30 -0
  156. package/dist/src/shared/mixins/HtmlFor.d.ts.map +1 -0
  157. package/dist/src/shared/mixins/KeyboardClick.d.ts +11 -0
  158. package/dist/src/shared/mixins/KeyboardClick.d.ts.map +1 -0
  159. package/dist/src/shared/mixins/Labelled.d.ts +22 -0
  160. package/dist/src/shared/mixins/Labelled.d.ts.map +1 -0
  161. package/dist/src/shared/mixins/LinkButton.d.ts +36 -0
  162. package/dist/src/shared/mixins/LinkButton.d.ts.map +1 -0
  163. package/dist/src/shared/mixins/ReadOnly.d.ts +25 -0
  164. package/dist/src/shared/mixins/ReadOnly.d.ts.map +1 -0
  165. package/dist/src/shared/mixins/Required.d.ts +26 -0
  166. package/dist/src/shared/mixins/Required.d.ts.map +1 -0
  167. package/dist/src/shared/mixins/RequiredConstraintValidation.d.ts +21 -0
  168. package/dist/src/shared/mixins/RequiredConstraintValidation.d.ts.map +1 -0
  169. package/dist/src/shared/mixins/Role.d.ts +13 -0
  170. package/dist/src/shared/mixins/Role.d.ts.map +1 -0
  171. package/dist/src/shared/mixins/Selected.d.ts +24 -0
  172. package/dist/src/shared/mixins/Selected.d.ts.map +1 -0
  173. package/dist/src/shared/mixins/Touched.d.ts +27 -0
  174. package/dist/src/shared/mixins/Touched.d.ts.map +1 -0
  175. package/dist/src/shared/mixins/Vertical.d.ts +24 -0
  176. package/dist/src/shared/mixins/Vertical.d.ts.map +1 -0
  177. package/dist/src/shared/mixins/hasKeys.d.ts +9 -0
  178. package/dist/src/shared/mixins/hasKeys.d.ts.map +1 -0
  179. package/dist/src/shared/mixins/index.d.ts +25 -0
  180. package/dist/src/shared/mixins/index.d.ts.map +1 -0
  181. package/dist/src/shared/primitives/CollapsibleElement.d.ts +58 -0
  182. package/dist/src/shared/primitives/CollapsibleElement.d.ts.map +1 -0
  183. package/dist/src/shared/primitives/ElevationElement.d.ts +88 -0
  184. package/dist/src/shared/primitives/ElevationElement.d.ts.map +1 -0
  185. package/dist/src/shared/primitives/ElevationLevel.d.ts +3 -0
  186. package/dist/src/shared/primitives/ElevationLevel.d.ts.map +1 -0
  187. package/dist/src/shared/primitives/ElevationToken.d.ts +15 -0
  188. package/dist/src/shared/primitives/ElevationToken.d.ts.map +1 -0
  189. package/dist/src/shared/primitives/FocusRingElement.d.ts +78 -0
  190. package/dist/src/shared/primitives/FocusRingElement.d.ts.map +1 -0
  191. package/dist/src/shared/primitives/FocusRingToken.d.ts +17 -0
  192. package/dist/src/shared/primitives/FocusRingToken.d.ts.map +1 -0
  193. package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts +50 -0
  194. package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts.map +1 -0
  195. package/dist/src/shared/primitives/PseudoRadioElement.d.ts +41 -0
  196. package/dist/src/shared/primitives/PseudoRadioElement.d.ts.map +1 -0
  197. package/dist/src/shared/primitives/RippleElement.d.ts +110 -0
  198. package/dist/src/shared/primitives/RippleElement.d.ts.map +1 -0
  199. package/dist/src/shared/primitives/RippleToken.d.ts +12 -0
  200. package/dist/src/shared/primitives/RippleToken.d.ts.map +1 -0
  201. package/dist/src/shared/primitives/ScrollContainerElement.d.ts +64 -0
  202. package/dist/src/shared/primitives/ScrollContainerElement.d.ts.map +1 -0
  203. package/dist/src/shared/primitives/ScrollDividers.d.ts +3 -0
  204. package/dist/src/shared/primitives/ScrollDividers.d.ts.map +1 -0
  205. package/dist/src/shared/primitives/SlideElement.d.ts +48 -0
  206. package/dist/src/shared/primitives/SlideElement.d.ts.map +1 -0
  207. package/dist/src/shared/primitives/StateLayerElement.d.ts +77 -0
  208. package/dist/src/shared/primitives/StateLayerElement.d.ts.map +1 -0
  209. package/dist/src/shared/primitives/StateLayerToken.d.ts +13 -0
  210. package/dist/src/shared/primitives/StateLayerToken.d.ts.map +1 -0
  211. package/dist/src/shared/primitives/TextOverflowElement.d.ts +39 -0
  212. package/dist/src/shared/primitives/TextOverflowElement.d.ts.map +1 -0
  213. package/dist/src/shared/primitives/index.d.ts +13 -0
  214. package/dist/src/shared/primitives/index.d.ts.map +1 -0
  215. package/dist/src/shared/tokens/ColorToken.d.ts +96 -0
  216. package/dist/src/shared/tokens/ColorToken.d.ts.map +1 -0
  217. package/dist/src/shared/tokens/DensityToken.d.ts +15 -0
  218. package/dist/src/shared/tokens/DensityToken.d.ts.map +1 -0
  219. package/dist/src/shared/tokens/DesignToken.d.ts +366 -0
  220. package/dist/src/shared/tokens/DesignToken.d.ts.map +1 -0
  221. package/dist/src/shared/tokens/ElevationToken.d.ts +16 -0
  222. package/dist/src/shared/tokens/ElevationToken.d.ts.map +1 -0
  223. package/dist/src/shared/tokens/MotionToken.d.ts +69 -0
  224. package/dist/src/shared/tokens/MotionToken.d.ts.map +1 -0
  225. package/dist/src/shared/tokens/ScrollbarToken.d.ts +10 -0
  226. package/dist/src/shared/tokens/ScrollbarToken.d.ts.map +1 -0
  227. package/dist/src/shared/tokens/ShapeToken.d.ts +79 -0
  228. package/dist/src/shared/tokens/ShapeToken.d.ts.map +1 -0
  229. package/dist/src/shared/tokens/StateToken.d.ts +10 -0
  230. package/dist/src/shared/tokens/StateToken.d.ts.map +1 -0
  231. package/dist/src/shared/tokens/TypescaleToken.d.ts +220 -0
  232. package/dist/src/shared/tokens/TypescaleToken.d.ts.map +1 -0
  233. package/dist/src/shared/tokens/index.d.ts +2 -0
  234. package/dist/src/shared/tokens/index.d.ts.map +1 -0
  235. package/dist/src/shared/utils/getTextContent.d.ts +8 -0
  236. package/dist/src/shared/utils/getTextContent.d.ts.map +1 -0
  237. package/dist/src/shared/utils/guid.d.ts +6 -0
  238. package/dist/src/shared/utils/guid.d.ts.map +1 -0
  239. package/dist/src/shared/utils/hasAssignedNodes.d.ts +7 -0
  240. package/dist/src/shared/utils/hasAssignedNodes.d.ts.map +1 -0
  241. package/dist/src/shared/utils/index.d.ts +6 -0
  242. package/dist/src/shared/utils/index.d.ts.map +1 -0
  243. package/dist/src/shared/utils/prefersReducedMotion.d.ts +6 -0
  244. package/dist/src/shared/utils/prefersReducedMotion.d.ts.map +1 -0
  245. package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts +8 -0
  246. package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts.map +1 -0
  247. package/eslint.config.mjs +21 -0
  248. package/package.json +87 -0
  249. package/rollup.config.js +132 -0
  250. package/src/a11y/AriaDescriber.ts +130 -0
  251. package/src/a11y/FocusTrapElement.ts +136 -0
  252. package/src/a11y/InteractivityChecker.ts +62 -0
  253. package/src/a11y/LiveAnnouncer.ts +143 -0
  254. package/src/a11y/aria-reference.ts +51 -0
  255. package/src/a11y/index.ts +8 -0
  256. package/src/a11y/keycodes/KeyCode.ts +128 -0
  257. package/src/a11y/keycodes/ModifierKeys.ts +5 -0
  258. package/src/a11y/keycodes/getKeyCode.ts +8 -0
  259. package/src/a11y/keycodes/hasModifierKey.ts +11 -0
  260. package/src/a11y/keycodes/index.ts +5 -0
  261. package/src/a11y/keycodes/isModifierAllowed.ts +12 -0
  262. package/src/a11y/list-key/FocusKeyManager.ts +25 -0
  263. package/src/a11y/list-key/ListKeyManager.ts +350 -0
  264. package/src/a11y/list-key/ListManager.ts +66 -0
  265. package/src/a11y/list-key/RadioKeyManager.ts +49 -0
  266. package/src/a11y/list-key/RovingTabIndexManager.ts +56 -0
  267. package/src/a11y/list-key/SelectionManager.ts +132 -0
  268. package/src/a11y/list-key/Typeahead.ts +131 -0
  269. package/src/a11y/list-key/index.ts +7 -0
  270. package/src/a11y/visuallyHide.ts +18 -0
  271. package/src/anchoring/AnchorOptions.ts +19 -0
  272. package/src/anchoring/AnchorPosition.ts +14 -0
  273. package/src/anchoring/index.ts +3 -0
  274. package/src/anchoring/positionAnchor.ts +53 -0
  275. package/src/bidi/Directionality.ts +85 -0
  276. package/src/bidi/index.ts +1 -0
  277. package/src/index.ts +1 -0
  278. package/src/layout/Breakpoint.ts +26 -0
  279. package/src/layout/BreakpointObserver.ts +44 -0
  280. package/src/layout/index.ts +2 -0
  281. package/src/platform/Platform.ts +67 -0
  282. package/src/platform/index.ts +1 -0
  283. package/src/shared/controllers/FocusController.ts +60 -0
  284. package/src/shared/controllers/HoverController.ts +140 -0
  285. package/src/shared/controllers/IntersectionController.ts +81 -0
  286. package/src/shared/controllers/LongPressController.ts +87 -0
  287. package/src/shared/controllers/MonitorControllerBase.ts +99 -0
  288. package/src/shared/controllers/MutationController.ts +89 -0
  289. package/src/shared/controllers/PressedController.ts +137 -0
  290. package/src/shared/controllers/ResizeController.ts +83 -0
  291. package/src/shared/controllers/ScrollController.ts +100 -0
  292. package/src/shared/controllers/index.ts +8 -0
  293. package/src/shared/decorators/debounce.ts +19 -0
  294. package/src/shared/decorators/index.ts +1 -0
  295. package/src/shared/directives/index.ts +1 -0
  296. package/src/shared/directives/safeStyleMap.ts +108 -0
  297. package/src/shared/index.ts +7 -0
  298. package/src/shared/mixins/AttachInternals.ts +48 -0
  299. package/src/shared/mixins/Checked.ts +50 -0
  300. package/src/shared/mixins/CheckedIndeterminate.ts +47 -0
  301. package/src/shared/mixins/CheckedOrSelected.ts +36 -0
  302. package/src/shared/mixins/ConstraintValidation.ts +213 -0
  303. package/src/shared/mixins/Constructor.ts +2 -0
  304. package/src/shared/mixins/Dirty.ts +71 -0
  305. package/src/shared/mixins/Disabled.ts +49 -0
  306. package/src/shared/mixins/DisabledInteractive.ts +78 -0
  307. package/src/shared/mixins/EventAttribute.ts +25 -0
  308. package/src/shared/mixins/Focusable.ts +52 -0
  309. package/src/shared/mixins/FormAssociated.ts +152 -0
  310. package/src/shared/mixins/FormSubmitter.ts +123 -0
  311. package/src/shared/mixins/HtmlFor.ts +89 -0
  312. package/src/shared/mixins/KeyboardClick.ts +46 -0
  313. package/src/shared/mixins/Labelled.ts +88 -0
  314. package/src/shared/mixins/LinkButton.ts +169 -0
  315. package/src/shared/mixins/ReadOnly.ts +48 -0
  316. package/src/shared/mixins/Required.ts +50 -0
  317. package/src/shared/mixins/RequiredConstraintValidation.ts +45 -0
  318. package/src/shared/mixins/Role.ts +134 -0
  319. package/src/shared/mixins/Selected.ts +50 -0
  320. package/src/shared/mixins/Touched.ts +71 -0
  321. package/src/shared/mixins/Vertical.ts +44 -0
  322. package/src/shared/mixins/hasKeys.ts +10 -0
  323. package/src/shared/mixins/index.ts +24 -0
  324. package/src/shared/primitives/CollapsibleElement.ts +227 -0
  325. package/src/shared/primitives/ElevationElement.ts +254 -0
  326. package/src/shared/primitives/ElevationLevel.ts +2 -0
  327. package/src/shared/primitives/ElevationToken.ts +18 -0
  328. package/src/shared/primitives/FocusRingElement.ts +199 -0
  329. package/src/shared/primitives/FocusRingToken.ts +24 -0
  330. package/src/shared/primitives/PseudoCheckboxElement.ts +116 -0
  331. package/src/shared/primitives/PseudoRadioElement.ts +83 -0
  332. package/src/shared/primitives/RippleElement.ts +289 -0
  333. package/src/shared/primitives/RippleToken.ts +15 -0
  334. package/src/shared/primitives/ScrollContainerElement.ts +151 -0
  335. package/src/shared/primitives/ScrollDividers.ts +2 -0
  336. package/src/shared/primitives/SlideElement.ts +128 -0
  337. package/src/shared/primitives/StateLayerElement.ts +191 -0
  338. package/src/shared/primitives/StateLayerToken.ts +16 -0
  339. package/src/shared/primitives/TextOverflowElement.ts +60 -0
  340. package/src/shared/primitives/index.ts +12 -0
  341. package/src/shared/tokens/ColorToken.ts +142 -0
  342. package/src/shared/tokens/DensityToken.ts +23 -0
  343. package/src/shared/tokens/DesignToken.ts +35 -0
  344. package/src/shared/tokens/ElevationToken.ts +115 -0
  345. package/src/shared/tokens/MotionToken.ts +107 -0
  346. package/src/shared/tokens/ScrollbarToken.ts +13 -0
  347. package/src/shared/tokens/ShapeToken.ts +138 -0
  348. package/src/shared/tokens/StateToken.ts +13 -0
  349. package/src/shared/tokens/TypescaleToken.ts +230 -0
  350. package/src/shared/tokens/index.ts +1 -0
  351. package/src/shared/utils/getTextContent.ts +31 -0
  352. package/src/shared/utils/guid.ts +11 -0
  353. package/src/shared/utils/hasAssignedNodes.ts +8 -0
  354. package/src/shared/utils/index.ts +5 -0
  355. package/src/shared/utils/prefersReducedMotion.ts +9 -0
  356. package/src/shared/utils/scrollIntoViewIfNeeded.ts +18 -0
  357. package/tsconfig.json +9 -0
@@ -0,0 +1,254 @@
1
+ import { css, CSSResultGroup, html, LitElement, PropertyValues, unsafeCSS } from "lit";
2
+ import { customElement, property, query } from "lit/decorators.js";
3
+
4
+ import { FocusController, HoverController, PressedController } from "../controllers";
5
+ import { HtmlFor, Role } from "../mixins";
6
+
7
+ import { ElevationLevel } from "./ElevationLevel";
8
+ import { ElevationToken } from "./ElevationToken";
9
+ import { DesignToken } from "../tokens";
10
+
11
+ /**
12
+ * @summary
13
+ * Visually depicts elevation using a shadow.
14
+ *
15
+ * @description
16
+ * The `m3e-elevation` component is an absolute positioned element used to depict elevation using a shadow.
17
+ * The parenting element must be a relative positioned element and allow for overflow. Use the `level` attribute
18
+ * to specify the elevation level.
19
+ *
20
+ * The component can also be attached to another element using the `for` attribute. When attached, elevation will
21
+ * be lifted by 1 level on hover. This can be disabled using the `disabled` attribute.
22
+ *
23
+ * Alternately, use the `attach` and `detach` methods to programmatically attach and detach this element to another.
24
+ *
25
+ * @example
26
+ * The following example illustrates basic markup. Note how the parenting element's position is `relative`. A parenting
27
+ * element's position must be `relative` and overflow must be visible.
28
+ *
29
+ * ```html
30
+ * <div style="position: relative;">
31
+ * <m3e-elevation level="1"></m3e-elevation>
32
+ * <div>
33
+ * ```
34
+ * @example
35
+ * The following example illustrates attaching elevation to an interactive element. In this example, the parenting div
36
+ * is given an `id` referenced by `m3e-elevation` using the `for` attribute. Note that `#myDiv` is not used when
37
+ * specifying the attached element's identifier. The `#` is inferred.
38
+ *
39
+ * ```html
40
+ * <div id="myDiv" style="position: relative;">
41
+ * <m3e-elevation for="myDiv" level="1"></m3e-elevation>
42
+ * <div>
43
+ * ```
44
+ *
45
+ * @tag m3e-elevation
46
+ *
47
+ * @attr disabled - Whether hover and press events will not trigger changes in elevation, when attached to an interactive element.
48
+ * @attr for - The identifier of the interactive control to which this element is attached.
49
+ * @attr level - The level at which to visually depict elevation.
50
+ *
51
+ * @cssprop --m3e-elevation-color - Color used to depict elevation.
52
+ * @cssprop --m3e-elevation-lift-duration - Duration when lifting.
53
+ * @cssprop --m3e-elevation-lift-easing - Easing curve when lifting.
54
+ * @cssprop --m3e-elevation-settle-duration - Duration when settling.
55
+ * @cssprop --m3e-elevation-settle-easing - Easing curve when settling.
56
+ * @cssprop --m3e-elevation-level - Elevation when resting (box-shadow).
57
+ * @cssprop --m3e-elevation-hover-level - Elevation on hover (box-shadow).
58
+ * @cssprop --m3e-elevation-focus-level - Elevation on focus (box-shadow).
59
+ * @cssprop --m3e-elevation-pressed-level - Elevation on pressed (box-shadow).
60
+ */
61
+ @customElement("m3e-elevation")
62
+ export class M3eElevationElement extends HtmlFor(Role(LitElement, "none")) {
63
+ /** The styles of the element. */
64
+ static override styles: CSSResultGroup = css`
65
+ :host {
66
+ display: block;
67
+ }
68
+ :host,
69
+ .shadow {
70
+ position: absolute;
71
+ left: 0;
72
+ top: 0;
73
+ right: 0;
74
+ bottom: 0;
75
+ pointer-events: none;
76
+ border-radius: inherit;
77
+ }
78
+ .shadow.resting,
79
+ .shadow.focus,
80
+ .shadow.pressed {
81
+ will-change: box-shadow;
82
+ transition: ${unsafeCSS(`box-shadow ${ElevationToken.settleDuration} ${ElevationToken.settleEasing};`)};
83
+ }
84
+ .shadow.hover {
85
+ will-change: box-shadow;
86
+ transition: ${unsafeCSS(`box-shadow ${ElevationToken.liftDuration} ${ElevationToken.liftEasing};`)};
87
+ }
88
+ .shadow {
89
+ box-shadow: ${ElevationToken.level};
90
+ }
91
+ .shadow.focus {
92
+ box-shadow: ${ElevationToken.focusLevel};
93
+ }
94
+ .shadow.hover {
95
+ box-shadow: ${ElevationToken.hoverLevel};
96
+ }
97
+ .shadow.pressed {
98
+ box-shadow: ${ElevationToken.pressedLevel};
99
+ }
100
+ :host([level="0"]) .shadow {
101
+ --m3e-elevation-level: ${DesignToken.elevation.level0};
102
+ --m3e-elevation-hover-level: ${DesignToken.elevation.level1};
103
+ }
104
+ :host([level="1"]) .shadow {
105
+ --m3e-elevation-level: ${DesignToken.elevation.level1};
106
+ --m3e-elevation-hover-level: ${DesignToken.elevation.level2};
107
+ }
108
+ :host([level="2"]) .shadow {
109
+ --m3e-elevation-level: ${DesignToken.elevation.level2};
110
+ --m3e-elevation-hover-level: ${DesignToken.elevation.level3};
111
+ }
112
+ :host([level="3"]) .shadow {
113
+ --m3e-elevation-level: ${DesignToken.elevation.level3};
114
+ --m3e-elevation-hover-level: ${DesignToken.elevation.level4};
115
+ }
116
+ :host([level="4"]) .shadow {
117
+ --m3e-elevation-level: ${DesignToken.elevation.level4};
118
+ --m3e-elevation-hover-level: ${DesignToken.elevation.level5};
119
+ }
120
+ :host([level="5"]) .shadow {
121
+ --m3e-elevation-level: ${DesignToken.elevation.level5};
122
+ --m3e-elevation-hover-level: ${ElevationToken.level};
123
+ }
124
+ :host([level]) .shadow {
125
+ --m3e-elevation-focus-level: ${ElevationToken.level};
126
+ --m3e-elevation-pressed-level: ${ElevationToken.level};
127
+ }
128
+ @media (prefers-reduced-motion) {
129
+ .shadow.resting,
130
+ .shadow.pressed,
131
+ .shadow.focus,
132
+ .shadow.hover {
133
+ transition: none;
134
+ }
135
+ }
136
+ @media (forced-colors: active) {
137
+ .shadow {
138
+ display: none;
139
+ }
140
+ }
141
+ `;
142
+
143
+ /** @private */
144
+ readonly #hoverController = new HoverController(this, {
145
+ target: null,
146
+ callback: (hovering) => this.#handleHoverChange(hovering),
147
+ });
148
+
149
+ /** @private */
150
+ readonly #focusController = new FocusController(this, {
151
+ target: null,
152
+ callback: (focused) => this.#handleFocusChange(focused),
153
+ });
154
+
155
+ /** @private */
156
+ readonly #pressedController = new PressedController(this, {
157
+ target: null,
158
+ callback: (pressed) => this.#handlePressedChange(pressed),
159
+ });
160
+
161
+ @query(".shadow") private readonly _shadow?: HTMLElement;
162
+
163
+ /**
164
+ * Whether hover and press events will not trigger changes in elevation, when attached to an interactive element.
165
+ * @default false
166
+ */
167
+ @property({ type: Boolean, reflect: true }) disabled = false;
168
+
169
+ /**
170
+ * The level at which to visually depict elevation.
171
+ * @default null
172
+ */
173
+ @property({ type: Number, reflect: true }) level: ElevationLevel | null = null;
174
+
175
+ /** @inheritdoc */
176
+ override attach(control: HTMLElement): void {
177
+ super.attach(control);
178
+
179
+ this.#hoverController.observe(control);
180
+ this.#focusController.observe(control);
181
+ this.#pressedController.observe(control);
182
+ }
183
+
184
+ /** @inheritdoc */
185
+ override detach(): void {
186
+ if (this.control) {
187
+ this.#hoverController.unobserve(this.control);
188
+ this.#focusController.unobserve(this.control);
189
+ this.#pressedController.unobserve(this.control);
190
+ }
191
+ super.detach();
192
+ }
193
+
194
+ /** @inheritdoc */
195
+ override connectedCallback(): void {
196
+ this.ariaHidden = "true";
197
+ super.connectedCallback();
198
+ }
199
+
200
+ /** @inheritdoc */
201
+ override disconnectedCallback(): void {
202
+ super.disconnectedCallback();
203
+
204
+ this._shadow?.classList.toggle("hover", false);
205
+ this._shadow?.classList.toggle("focus", false);
206
+ this._shadow?.classList.toggle("pressed", false);
207
+ this._shadow?.classList.toggle("resting", false);
208
+ }
209
+
210
+ /** @inheritdoc */
211
+ protected override updated(_changedProperties: PropertyValues<this>): void {
212
+ super.updated(_changedProperties);
213
+
214
+ if (_changedProperties.has("disabled") && this.disabled) {
215
+ this._shadow?.classList.toggle("hover", false);
216
+ this._shadow?.classList.toggle("focus", false);
217
+ this._shadow?.classList.toggle("pressed", false);
218
+ this._shadow?.classList.toggle("resting", true);
219
+ }
220
+ }
221
+
222
+ /** @inheritdoc */
223
+ protected override render(): unknown {
224
+ return html`<div class="shadow"></div>`;
225
+ }
226
+
227
+ /** @private */
228
+ #handleHoverChange(hovering: boolean): void {
229
+ if (!this.disabled) {
230
+ this._shadow?.classList.toggle("hover", hovering);
231
+ this._shadow?.classList.toggle("resting", !hovering);
232
+ }
233
+ }
234
+
235
+ /** @private */
236
+ #handleFocusChange(focused: boolean): void {
237
+ if (!this.disabled) {
238
+ this._shadow?.classList.toggle("focus", focused);
239
+ }
240
+ }
241
+
242
+ /** @private */
243
+ #handlePressedChange(pressed: boolean): void {
244
+ if (!this.disabled) {
245
+ this._shadow?.classList.toggle("pressed", pressed);
246
+ }
247
+ }
248
+ }
249
+
250
+ declare global {
251
+ interface HTMLElementTagNameMap {
252
+ "m3e-elevation": M3eElevationElement;
253
+ }
254
+ }
@@ -0,0 +1,2 @@
1
+ /** Specifies the possible levels in which to visually depict elevation. */
2
+ export type ElevationLevel = 0 | 1 | 2 | 3 | 4 | 5;
@@ -0,0 +1,18 @@
1
+ import { unsafeCSS } from "lit";
2
+
3
+ import { DesignToken } from "../tokens";
4
+
5
+ /**
6
+ * Component design tokens that control the `M3eElevationElement`.
7
+ * @internal
8
+ */
9
+ export const ElevationToken = {
10
+ liftDuration: unsafeCSS(`var(--m3e-elevation-lift-duration, ${DesignToken.motion.duration.short4})`),
11
+ liftEasing: unsafeCSS(`var(--m3e-elevation-lift-easing, ${DesignToken.motion.easing.standard})`),
12
+ settleDuration: unsafeCSS(`var(--m3e-elevation-settle-duration, ${DesignToken.motion.duration.short3})`),
13
+ settleEasing: unsafeCSS(`var(--m3e-elevation-settle-easing, ${DesignToken.motion.easing.standardAccelerate})`),
14
+ level: unsafeCSS(`var(--m3e-elevation-level, ${DesignToken.elevation.level0})`),
15
+ hoverLevel: unsafeCSS(`var(--m3e-elevation-hover-level, ${DesignToken.elevation.level0})`),
16
+ focusLevel: unsafeCSS(`var(--m3e-elevation-focus-level, ${DesignToken.elevation.level0})`),
17
+ pressedLevel: unsafeCSS(`var(--m3e-elevation-pressed-level, ${DesignToken.elevation.level0})`),
18
+ } as const;
@@ -0,0 +1,199 @@
1
+ import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
2
+ import { customElement, property, query } from "lit/decorators.js";
3
+
4
+ import { FocusController } from "../controllers";
5
+ import { HtmlFor, Role } from "../mixins";
6
+
7
+ import { FocusRingToken } from "./FocusRingToken";
8
+
9
+ /**
10
+ * @summary
11
+ * A focus ring used to depict a strong focus indicator.
12
+ *
13
+ * @description
14
+ * The `m3e-focus-ring` component is an absolute positioned element used to provide a strong focus indicator.
15
+ * The parenting element must be a relative positioned focusable element and allow for overflow.
16
+ *
17
+ * The component can be attached to an interactive element using the `for` attribute or programmatically using the `attach` method.
18
+ * The focus ring is displayed when the interactive element receives visible focus and hidden when focus is lost.
19
+ * This can be disabled using the `disabled` attribute.
20
+ *
21
+ * Alternately, you can use the `show` and `hide` methods to programmatically control the focus ring.
22
+ *
23
+ * @example
24
+ * The following example illustrates attaching a focus ring to an interactive element. In this example, the parenting div
25
+ * has relative positioning and is given an `id` referenced by `m3e-focus-ring` using the `for` attribute. Note that `#myDiv`
26
+ * is not used when specifying the attached element's identifier. The `#` is inferred.
27
+ *
28
+ * ```html
29
+ * <div id="myDiv" tabindex="0" style="position: relative;">
30
+ * <m3e-focus-ring for="myDiv"></m3e-focus-ring>
31
+ * <div>
32
+ * ```
33
+ *
34
+ * @tag m3e-focus-ring
35
+ *
36
+ * @attr disabled - Whether the focus events will not trigger the focus ring. Focus rings can be still controlled manually by using the `show` and `hide` methods.
37
+ * @attr inward - Whether the focus ring animates inward instead of outward.
38
+ *
39
+ * @cssprop --m3e-focus-ring-color - The color of the focus ring.
40
+ * @cssprop --m3e-focus-ring-duration - The duration of the focus ring animation.
41
+ * @cssprop --m3e-focus-ring-growth-factor - The factor by which the focus ring grows.
42
+ * @cssprop --m3e-focus-ring-thickness - The thickness of the focus ring.
43
+ * @cssprop --m3e-focus-ring-visibility - The visibility of the focus ring.
44
+ */
45
+ @customElement("m3e-focus-ring")
46
+ export class M3eFocusRingElement extends HtmlFor(Role(LitElement, "none")) {
47
+ /** The styles of the element. */
48
+ static override styles: CSSResultGroup = css`
49
+ :host {
50
+ display: block;
51
+ position: absolute;
52
+ left: 0;
53
+ top: 0;
54
+ right: 0;
55
+ bottom: 0;
56
+ pointer-events: none;
57
+ border-radius: inherit;
58
+ outline: none;
59
+ }
60
+ .outline {
61
+ position: absolute;
62
+ left: 0;
63
+ top: 0;
64
+ right: 0;
65
+ bottom: 0;
66
+ pointer-events: none;
67
+ border-radius: inherit;
68
+ z-index: 1;
69
+ outline-color: ${FocusRingToken.color};
70
+ outline-width: ${FocusRingToken.thickness};
71
+ visibility: ${FocusRingToken.visibility};
72
+ }
73
+ .outline.visible {
74
+ outline-style: solid;
75
+ }
76
+ :host(:not([inward])) .outline {
77
+ outline-offset: calc(${FocusRingToken.thickness} / ${FocusRingToken.growthFactor});
78
+ }
79
+ :host([inward]) .outline {
80
+ outline-offset: calc(0px - ${FocusRingToken.thickness});
81
+ }
82
+ :host(:not([inward])) .outline.visible {
83
+ animation: grow-shrink ${FocusRingToken.duration};
84
+ }
85
+ :host([inward]) .outline.visible {
86
+ animation: shrink-grow ${FocusRingToken.duration};
87
+ }
88
+ @keyframes grow-shrink {
89
+ 50% {
90
+ outline-width: calc(${FocusRingToken.thickness} * ${FocusRingToken.growthFactor});
91
+ }
92
+ }
93
+ @keyframes shrink-grow {
94
+ 50% {
95
+ outline-offset: calc(0px - calc(${FocusRingToken.thickness} * ${FocusRingToken.growthFactor}));
96
+ outline-width: calc(${FocusRingToken.thickness} * ${FocusRingToken.growthFactor});
97
+ }
98
+ }
99
+ @media (prefers-reduced-motion) {
100
+ :host(:not([inward])) .outline.visible,
101
+ :host([inward]) .outline.visible {
102
+ animation: none;
103
+ }
104
+ }
105
+ @media (forced-colors: active) {
106
+ .outline {
107
+ outline-color: Highlight;
108
+ }
109
+ }
110
+ `;
111
+
112
+ /** @private */
113
+ readonly #focusController = new FocusController(this, {
114
+ target: null,
115
+ callback: (_, focusVisible) => this.#handleFocusChange(focusVisible),
116
+ });
117
+
118
+ /** @private */ @query(".outline") private readonly _outline?: HTMLElement;
119
+
120
+ /**
121
+ * Whether the focus ring animates inward instead of outward.
122
+ * @default false
123
+ */
124
+ @property({ type: Boolean, reflect: true }) inward = false;
125
+
126
+ /**
127
+ * Whether the focus events will not trigger the focus ring.
128
+ * Focus rings can be still controlled manually by using the `show` and `hide` methods.
129
+ * @default false
130
+ */
131
+ @property({ type: Boolean, reflect: true }) disabled = false;
132
+
133
+ /** Launches a manual focus ring. */
134
+ show(): void {
135
+ this._outline?.classList.toggle("visible", true);
136
+ }
137
+
138
+ /** Hides the focus ring. */
139
+ hide(): void {
140
+ this._outline?.classList.toggle("visible", false);
141
+ }
142
+
143
+ /** @inheritdoc */
144
+ override attach(control: HTMLElement): void {
145
+ super.attach(control);
146
+ this.#focusController.observe(control);
147
+ }
148
+
149
+ /** @inheritdoc */
150
+ override detach(): void {
151
+ if (this.control) {
152
+ this.#focusController.unobserve(this.control);
153
+ }
154
+ super.detach();
155
+ }
156
+
157
+ /** @inheritdoc */
158
+ override connectedCallback(): void {
159
+ this.ariaHidden = "true";
160
+ super.connectedCallback();
161
+ }
162
+
163
+ /** @inheritdoc */
164
+ override disconnectedCallback(): void {
165
+ super.disconnectedCallback();
166
+ this.hide();
167
+ }
168
+
169
+ /** @inheritdoc */
170
+ protected override render(): unknown {
171
+ return html`<div class="outline"></div>`;
172
+ }
173
+
174
+ /** @inheritdoc */
175
+ protected override updated(_changedProperties: PropertyValues<this>): void {
176
+ super.updated(_changedProperties);
177
+
178
+ if (_changedProperties.has("disabled") && this.disabled) {
179
+ this.hide();
180
+ }
181
+ }
182
+
183
+ /** @private */
184
+ #handleFocusChange(focusVisible: boolean): void {
185
+ if (!this.disabled) {
186
+ if (focusVisible) {
187
+ this.show();
188
+ } else {
189
+ this.hide();
190
+ }
191
+ }
192
+ }
193
+ }
194
+
195
+ declare global {
196
+ interface HTMLElementTagNameMap {
197
+ "m3e-focus-ring": M3eFocusRingElement;
198
+ }
199
+ }
@@ -0,0 +1,24 @@
1
+ import { unsafeCSS } from "lit";
2
+
3
+ import { DesignToken } from "../tokens";
4
+
5
+ /**
6
+ * Component design tokens that control the `M3eFocusRingElement`.
7
+ * @internal
8
+ */
9
+ export const FocusRingToken = {
10
+ /** The color of the focus ring. */
11
+ color: unsafeCSS(`var(--m3e-focus-ring-color, ${DesignToken.color.secondary})`),
12
+
13
+ /** The duration of the focus ring animation. */
14
+ duration: unsafeCSS(`var(--m3e-focus-ring-duration, ${DesignToken.motion.duration.long2})`),
15
+
16
+ /** The thickness of the focus ring. */
17
+ thickness: unsafeCSS(`var(--m3e-focus-ring-thickness, 0.1875rem)`),
18
+
19
+ /** The visibility of the focus ring. */
20
+ visibility: unsafeCSS(`var(--m3e-focus-ring-visibility, visible)`),
21
+
22
+ /** The factor by which the focus ring grows. */
23
+ growthFactor: unsafeCSS(`var(--m3e-focus-ring-growth-factor, 2)`),
24
+ } as const;
@@ -0,0 +1,116 @@
1
+ import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
2
+ import { customElement } from "lit/decorators.js";
3
+
4
+ import { CheckedIndeterminate, Disabled, Role } from "../mixins";
5
+ import { DesignToken } from "../tokens";
6
+
7
+ /**
8
+ * @summary
9
+ * An element which looks like a checkbox.
10
+ *
11
+ * @description
12
+ * The `m3e-pseudo-checkbox` component is a pseudo-checkbox supporting checked, indeterminate, and disabled
13
+ * states. It is customizable via CSS properties for expressive, accessible UI design.
14
+ *
15
+ * @example
16
+ * The following example illustrates how to render a checked pseudo-checkbox.
17
+ * ```html
18
+ * <m3e-pseudo-checkbox checked></m3e-pseudo-checkbox>
19
+ * ```
20
+ *
21
+ * @tag m3e-pseudo-checkbox
22
+ *
23
+ * @attr checked - A value indicating whether the element is checked.
24
+ * @attr disabled - A value indicating whether the element is disabled.
25
+ * @attr indeterminate - A value indicating whether the element's checked state is indeterminate.
26
+ *
27
+ * @cssprop --m3e-checkbox-icon-size - Size of the checkbox icon.
28
+ * @cssprop --m3e-checkbox-container-shape - Border radius of the checkbox container.
29
+ * @cssprop --m3e-checkbox-unselected-outline-thickness - Outline thickness for unselected state.
30
+ * @cssprop --m3e-checkbox-unselected-outline-color - Outline color for unselected state.
31
+ * @cssprop --m3e-checkbox-selected-container-color - Background color for selected state.
32
+ * @cssprop --m3e-checkbox-selected-icon-color - Icon color for selected state.
33
+ * @cssprop --m3e-checkbox-unselected-disabled-outline-color - Outline color for unselected disabled state.
34
+ * @cssprop --m3e-checkbox-unselected-disabled-outline-opacity - Outline opacity for unselected disabled state.
35
+ * @cssprop --m3e-checkbox-selected-disabled-container-color - Background color for selected disabled state.
36
+ * @cssprop --m3e-checkbox-selected-disabled-container-opacity - Background opacity for selected disabled state.
37
+ * @cssprop --m3e-checkbox-selected-disabled-icon-color - Icon color for selected disabled state.
38
+ * @cssprop --m3e-checkbox-selected-disabled-icon-opacity - Icon opacity for selected disabled state.
39
+ */
40
+ @customElement("m3e-pseudo-checkbox")
41
+ export class M3ePseudoCheckboxElement extends CheckedIndeterminate(Disabled(Role(LitElement, "none"))) {
42
+ /** The styles of the element. */
43
+ static override styles: CSSResultGroup = css`
44
+ :host {
45
+ display: inline-block;
46
+ vertical-align: middle;
47
+ width: var(--m3e-checkbox-icon-size, 1.125rem);
48
+ height: var(--m3e-checkbox-icon-size, 1.125rem);
49
+ border-radius: var(--m3e-checkbox-container-shape, 0.125rem);
50
+ box-sizing: border-box;
51
+ flex: none;
52
+ }
53
+ :host(:not([checked]):not([indeterminate])) {
54
+ border-width: var(--m3e-checkbox-unselected-outline-thickness, 0.125rem);
55
+ border-style: solid;
56
+ }
57
+ :host(:not([disabled])[checked]),
58
+ :host(:not([disabled])[indeterminate]) {
59
+ background-color: var(--m3e-checkbox-selected-container-color, ${DesignToken.color.primary});
60
+ color: var(--m3e-checkbox-selected-icon-color, ${DesignToken.color.onPrimary});
61
+ }
62
+ :host(:not([disabled]):not([checked]):not([indeterminate])) {
63
+ border-color: var(--m3e-checkbox-unselected-outline-color, ${DesignToken.color.onSurfaceVariant});
64
+ }
65
+ :host([disabled]:not([checked]):not([indeterminate])) {
66
+ border-color: color-mix(
67
+ in srgb,
68
+ var(--m3e-checkbox-unselected-disabled-outline-color, ${DesignToken.color.onSurface})
69
+ var(--m3e-checkbox-unselected-disabled-outline-opacity, 38%),
70
+ transparent
71
+ );
72
+ }
73
+ :host([disabled][checked]),
74
+ :host([disabled][indeterminate]) {
75
+ background-color: color-mix(
76
+ in srgb,
77
+ var(--m3e-checkbox-selected-disabled-container-color, ${DesignToken.color.onSurface})
78
+ var(--m3e-checkbox-selected-disabled-container-opacity, 38%),
79
+ transparent
80
+ );
81
+ color: color-mix(
82
+ in srgb,
83
+ var(--m3e-checkbox-selected-disabled-icon-color, ${DesignToken.color.surface})
84
+ var(--m3e-checkbox-selected-disabled-icon-opacity, 100%),
85
+ transparent
86
+ );
87
+ }
88
+ `;
89
+
90
+ /** @inheritdoc */
91
+ override connectedCallback(): void {
92
+ super.connectedCallback();
93
+ this.ariaHidden = "true";
94
+ }
95
+
96
+ /** @inheritdoc */
97
+ protected override render(): unknown {
98
+ if (this.indeterminate) {
99
+ return html`<svg viewBox="0 -960 960 960" fill="currentColor">
100
+ <path Required d="M240-440v-80h480v80H240Z" />
101
+ </svg>`;
102
+ }
103
+ if (this.checked) {
104
+ return html`<svg viewBox="0 -960 960 960" fill="currentColor">
105
+ <path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z" />
106
+ </svg>`;
107
+ }
108
+ return nothing;
109
+ }
110
+ }
111
+
112
+ declare global {
113
+ interface HTMLElementTagNameMap {
114
+ "m3e-pseudo-checkbox": M3ePseudoCheckboxElement;
115
+ }
116
+ }
@@ -0,0 +1,83 @@
1
+ import { css, CSSResultGroup, html, LitElement } from "lit";
2
+ import { customElement } from "lit/decorators.js";
3
+
4
+ import { Checked, Disabled, Role } from "../mixins";
5
+ import { DesignToken } from "../tokens";
6
+
7
+ /**
8
+ * @summary
9
+ * An element which looks like a radio button.
10
+ *
11
+ * @description
12
+ * The `m3e-pseudo-radio` component is a pseudo-radio supporting checked and disabled
13
+ * states. It is customizable via CSS properties for expressive, accessible UI design.
14
+ *
15
+ * @example
16
+ * The following example illustrates how to render a checked pseudo-radio.
17
+ * ```html
18
+ * <m3e-pseudo-radio checked></m3e-pseudo-radio>
19
+ * ```
20
+ *
21
+ * @tag m3e-pseudo-radio
22
+ *
23
+ * @attr checked - A value indicating whether the element is checked.
24
+ * @attr disabled - A value indicating whether the element is disabled.
25
+ *
26
+ * @cssprop --m3e-radio-icon-size - Size of the radio icon.
27
+ * @cssprop --m3e-radio-unselected-icon-color - Color of the unselected radio icon.
28
+ * @cssprop --m3e-radio-selected-icon-color - Color of the selected radio icon.
29
+ * @cssprop --m3e-radio-disabled-icon-color - Color of the disabled radio icon.
30
+ */
31
+ @customElement("m3e-pseudo-radio")
32
+ export class M3ePseudoRadioElement extends Checked(Disabled(Role(LitElement, "none"))) {
33
+ /** The styles of the element. */
34
+ static override styles: CSSResultGroup = css`
35
+ :host {
36
+ display: inline-block;
37
+ vertical-align: middle;
38
+ box-sizing: border-box;
39
+ width: var(--m3e-radio-icon-size, 1.25rem);
40
+ height: var(--m3e-radio-icon-size, 1.25rem);
41
+ flex: none;
42
+ }
43
+ .circle {
44
+ fill: currentColor;
45
+ }
46
+ :host(:not([checked])) .circle.inner {
47
+ opacity: 0;
48
+ }
49
+ :host(:not([checked])) {
50
+ color: var(--m3e-radio-unselected-icon-color, ${DesignToken.color.onSurfaceVariant});
51
+ }
52
+ :host([checked]) {
53
+ color: var(--m3e-radio-selected-icon-color, ${DesignToken.color.primary});
54
+ }
55
+ :host([disabled]) {
56
+ color: color-mix(in srgb, var(--m3e-radio-disabled-icon-color, ${DesignToken.color.onSurface}) 38%, transparent);
57
+ }
58
+ `;
59
+
60
+ /** @inheritdoc */
61
+ override connectedCallback(): void {
62
+ super.connectedCallback();
63
+ this.ariaHidden = "true";
64
+ }
65
+
66
+ /** @inheritdoc */
67
+ protected override render(): unknown {
68
+ return html`<svg class="icon" viewBox="0 0 20 20">
69
+ <mask id="cutout2">
70
+ <rect width="100%" height="100%" fill="white"></rect>
71
+ <circle cx="10" cy="10" r="8" fill="black"></circle>
72
+ </mask>
73
+ <circle class="outer circle" cx="10" cy="10" r="10" mask="url(#cutout2)"></circle>
74
+ <circle class="inner circle" cx="10" cy="10" r="5"></circle>
75
+ </svg>`;
76
+ }
77
+ }
78
+
79
+ declare global {
80
+ interface HTMLElementTagNameMap {
81
+ "m3e-pseudo-radio": M3ePseudoRadioElement;
82
+ }
83
+ }