@radix-ng/primitives 0.12.1 → 0.13.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 (497) hide show
  1. package/README.md +3 -1
  2. package/accordion/index.d.ts +16 -0
  3. package/accordion/src/accordion-content.directive.d.ts +11 -0
  4. package/accordion/src/accordion-header.directive.d.ts +7 -0
  5. package/accordion/src/accordion-item.directive.d.ts +82 -0
  6. package/accordion/src/accordion-root.directive.d.ts +93 -0
  7. package/accordion/src/accordion-trigger.directive.d.ts +15 -0
  8. package/alert-dialog/{index.ts → index.d.ts} +0 -1
  9. package/alert-dialog/src/alert-dialog-cancel.directive.d.ts +7 -0
  10. package/alert-dialog/src/alert-dialog-content.directive.d.ts +9 -0
  11. package/alert-dialog/src/alert-dialog-root.directive.d.ts +9 -0
  12. package/alert-dialog/src/alert-dialog-title.directive.d.ts +5 -0
  13. package/alert-dialog/src/alert-dialog-trigger.directive.d.ts +7 -0
  14. package/alert-dialog/src/alert-dialog.service.d.ts +14 -0
  15. package/avatar/src/avatar-fallback.directive.d.ts +28 -0
  16. package/avatar/src/avatar-image.directive.d.ts +21 -0
  17. package/avatar/src/avatar-root.directive.d.ts +21 -0
  18. package/avatar/src/avatar.config.d.ts +13 -0
  19. package/checkbox/src/checkbox-button.directive.d.ts +8 -0
  20. package/checkbox/src/checkbox-indicator.directive.d.ts +6 -0
  21. package/checkbox/src/checkbox-input.directive.d.ts +9 -0
  22. package/checkbox/src/checkbox.directive.d.ts +75 -0
  23. package/checkbox/src/checkbox.token.d.ts +4 -0
  24. package/collapsible/src/collapsible-content.directive.d.ts +17 -0
  25. package/collapsible/src/collapsible-content.token.d.ts +3 -0
  26. package/collapsible/src/collapsible-root.directive.d.ts +55 -0
  27. package/collapsible/src/collapsible-trigger.directive.d.ts +26 -0
  28. package/compodoc/documentation.json +14249 -0
  29. package/context-menu/index.d.ts +26 -0
  30. package/context-menu/src/context-menu-content.directive.d.ts +15 -0
  31. package/context-menu/src/context-menu-item-checkbox.directive.d.ts +9 -0
  32. package/context-menu/src/context-menu-item-indicator.directive.d.ts +7 -0
  33. package/context-menu/src/context-menu-item-radio-group.directive.d.ts +12 -0
  34. package/context-menu/src/context-menu-item-radio.directive.d.ts +19 -0
  35. package/context-menu/src/context-menu-item-selectable.d.ts +12 -0
  36. package/context-menu/src/context-menu-item.directive.d.ts +17 -0
  37. package/context-menu/src/context-menu-label.directive.d.ts +5 -0
  38. package/context-menu/src/context-menu-separator.directive.d.ts +6 -0
  39. package/context-menu/src/context-menu-trigger.directive.d.ts +31 -0
  40. package/dialog/index.d.ts +23 -0
  41. package/dialog/src/dialog-close.directive.d.ts +7 -0
  42. package/dialog/src/dialog-content.directive.d.ts +21 -0
  43. package/dialog/src/dialog-description.directive.d.ts +5 -0
  44. package/dialog/src/dialog-dismiss.directive.d.ts +7 -0
  45. package/dialog/src/dialog-ref.d.ts +37 -0
  46. package/dialog/src/dialog-title.directive.d.ts +5 -0
  47. package/dialog/src/dialog-trigger.directive.d.ts +16 -0
  48. package/dialog/src/dialog.config.d.ts +39 -0
  49. package/dialog/src/dialog.injectors.d.ts +4 -0
  50. package/dialog/src/{dialog.providers.ts → dialog.providers.d.ts} +3 -11
  51. package/dialog/src/dialog.service.d.ts +26 -0
  52. package/dropdown-menu/index.d.ts +26 -0
  53. package/dropdown-menu/src/dropdown-menu-content.directive.d.ts +15 -0
  54. package/dropdown-menu/src/dropdown-menu-item-checkbox.directive.d.ts +9 -0
  55. package/dropdown-menu/src/dropdown-menu-item-indicator.directive.d.ts +7 -0
  56. package/dropdown-menu/src/dropdown-menu-item-radio-group.directive.d.ts +12 -0
  57. package/dropdown-menu/src/dropdown-menu-item-radio.directive.d.ts +19 -0
  58. package/dropdown-menu/src/dropdown-menu-item-selectable.d.ts +12 -0
  59. package/dropdown-menu/src/dropdown-menu-item.directive.d.ts +17 -0
  60. package/dropdown-menu/src/dropdown-menu-label.directive.d.ts +5 -0
  61. package/dropdown-menu/src/dropdown-menu-separator.directive.d.ts +6 -0
  62. package/dropdown-menu/src/dropdown-menu-trigger.directive.d.ts +46 -0
  63. package/esm2022/accordion/index.mjs +40 -0
  64. package/esm2022/accordion/radix-ng-primitives-accordion.mjs +5 -0
  65. package/esm2022/accordion/src/accordion-content.directive.mjs +42 -0
  66. package/esm2022/accordion/src/accordion-header.directive.mjs +23 -0
  67. package/esm2022/accordion/src/accordion-item.directive.mjs +187 -0
  68. package/esm2022/accordion/src/accordion-root.directive.mjs +172 -0
  69. package/esm2022/accordion/src/accordion-trigger.directive.mjs +42 -0
  70. package/esm2022/alert-dialog/index.mjs +7 -0
  71. package/esm2022/alert-dialog/radix-ng-primitives-alert-dialog.mjs +5 -0
  72. package/esm2022/alert-dialog/src/alert-dialog-cancel.directive.mjs +24 -0
  73. package/esm2022/alert-dialog/src/alert-dialog-content.directive.mjs +34 -0
  74. package/esm2022/alert-dialog/src/alert-dialog-root.directive.mjs +24 -0
  75. package/esm2022/alert-dialog/src/alert-dialog-title.directive.mjs +14 -0
  76. package/esm2022/alert-dialog/src/alert-dialog-trigger.directive.mjs +24 -0
  77. package/esm2022/alert-dialog/src/alert-dialog.service.mjs +46 -0
  78. package/esm2022/avatar/index.mjs +5 -0
  79. package/esm2022/avatar/radix-ng-primitives-avatar.mjs +5 -0
  80. package/esm2022/avatar/src/avatar-fallback.directive.mjs +60 -0
  81. package/esm2022/avatar/src/avatar-image.directive.mjs +52 -0
  82. package/esm2022/avatar/src/avatar-root.directive.mjs +38 -0
  83. package/esm2022/avatar/src/avatar.config.mjs +17 -0
  84. package/esm2022/checkbox/index.mjs +6 -0
  85. package/esm2022/checkbox/radix-ng-primitives-checkbox.mjs +5 -0
  86. package/esm2022/checkbox/src/checkbox-button.directive.mjs +33 -0
  87. package/esm2022/checkbox/src/checkbox-indicator.directive.mjs +24 -0
  88. package/esm2022/checkbox/src/checkbox-input.directive.mjs +41 -0
  89. package/esm2022/checkbox/src/checkbox.directive.mjs +141 -0
  90. package/esm2022/checkbox/src/checkbox.token.mjs +6 -0
  91. package/esm2022/collapsible/index.mjs +4 -0
  92. package/esm2022/collapsible/radix-ng-primitives-collapsible.mjs +5 -0
  93. package/esm2022/collapsible/src/collapsible-content.directive.mjs +45 -0
  94. package/esm2022/collapsible/src/collapsible-content.token.mjs +3 -0
  95. package/esm2022/collapsible/src/collapsible-root.directive.mjs +118 -0
  96. package/esm2022/collapsible/src/collapsible-trigger.directive.mjs +49 -0
  97. package/esm2022/context-menu/index.mjs +65 -0
  98. package/esm2022/context-menu/radix-ng-primitives-context-menu.mjs +5 -0
  99. package/esm2022/context-menu/src/context-menu-content.directive.mjs +56 -0
  100. package/esm2022/context-menu/src/context-menu-item-checkbox.directive.mjs +39 -0
  101. package/esm2022/context-menu/src/context-menu-item-indicator.directive.mjs +22 -0
  102. package/esm2022/context-menu/src/context-menu-item-radio-group.directive.mjs +37 -0
  103. package/esm2022/context-menu/src/context-menu-item-radio.directive.mjs +67 -0
  104. package/esm2022/context-menu/src/context-menu-item-selectable.mjs +31 -0
  105. package/esm2022/context-menu/src/context-menu-item.directive.mjs +70 -0
  106. package/esm2022/context-menu/src/context-menu-label.directive.mjs +14 -0
  107. package/esm2022/context-menu/src/context-menu-separator.directive.mjs +21 -0
  108. package/esm2022/context-menu/src/context-menu-trigger.directive.mjs +92 -0
  109. package/esm2022/dialog/index.mjs +50 -0
  110. package/esm2022/dialog/radix-ng-primitives-dialog.mjs +5 -0
  111. package/esm2022/dialog/src/dialog-close.directive.mjs +25 -0
  112. package/esm2022/dialog/src/dialog-content.directive.mjs +46 -0
  113. package/esm2022/dialog/src/dialog-description.directive.mjs +14 -0
  114. package/esm2022/dialog/src/dialog-dismiss.directive.mjs +25 -0
  115. package/esm2022/dialog/src/dialog-ref.mjs +46 -0
  116. package/esm2022/dialog/src/dialog-title.directive.mjs +14 -0
  117. package/esm2022/dialog/src/dialog-trigger.directive.mjs +54 -0
  118. package/esm2022/dialog/src/dialog.config.mjs +6 -0
  119. package/esm2022/dialog/src/dialog.injectors.mjs +10 -0
  120. package/esm2022/dialog/src/dialog.providers.mjs +26 -0
  121. package/esm2022/dialog/src/dialog.service.mjs +96 -0
  122. package/esm2022/dropdown-menu/index.mjs +68 -0
  123. package/esm2022/dropdown-menu/radix-ng-primitives-dropdown-menu.mjs +5 -0
  124. package/esm2022/dropdown-menu/src/dropdown-menu-content.directive.mjs +56 -0
  125. package/esm2022/dropdown-menu/src/dropdown-menu-item-checkbox.directive.mjs +39 -0
  126. package/esm2022/dropdown-menu/src/dropdown-menu-item-indicator.directive.mjs +22 -0
  127. package/esm2022/dropdown-menu/src/dropdown-menu-item-radio-group.directive.mjs +37 -0
  128. package/esm2022/dropdown-menu/src/dropdown-menu-item-radio.directive.mjs +67 -0
  129. package/esm2022/dropdown-menu/src/dropdown-menu-item-selectable.mjs +31 -0
  130. package/esm2022/dropdown-menu/src/dropdown-menu-item.directive.mjs +71 -0
  131. package/esm2022/dropdown-menu/src/dropdown-menu-label.directive.mjs +14 -0
  132. package/esm2022/dropdown-menu/src/dropdown-menu-separator.directive.mjs +21 -0
  133. package/esm2022/dropdown-menu/src/dropdown-menu-trigger.directive.mjs +179 -0
  134. package/esm2022/index.mjs +2 -0
  135. package/esm2022/label/index.mjs +2 -0
  136. package/esm2022/label/radix-ng-primitives-label.mjs +5 -0
  137. package/esm2022/label/src/label.directive.mjs +59 -0
  138. package/esm2022/menu/index.mjs +45 -0
  139. package/esm2022/menu/radix-ng-primitives-menu.mjs +5 -0
  140. package/esm2022/menu/src/menu-content.directive.mjs +17 -0
  141. package/esm2022/menu/src/menu-directive.mjs +18 -0
  142. package/esm2022/menu/src/menu-group.directive.mjs +20 -0
  143. package/esm2022/menu/src/menu-item.directive.mjs +46 -0
  144. package/esm2022/menu/src/menu-label.directive.mjs +14 -0
  145. package/esm2022/menu/src/menu-separator.directive.mjs +21 -0
  146. package/esm2022/menubar/index.mjs +60 -0
  147. package/esm2022/menubar/radix-ng-primitives-menubar.mjs +5 -0
  148. package/esm2022/menubar/src/menubar-content.directive.mjs +17 -0
  149. package/esm2022/menubar/src/menubar-item-checkbox.directive.mjs +34 -0
  150. package/esm2022/menubar/src/menubar-item-indicator.directive.mjs +17 -0
  151. package/esm2022/menubar/src/menubar-item-radio.directive.mjs +35 -0
  152. package/esm2022/menubar/src/menubar-item.directive.mjs +20 -0
  153. package/esm2022/menubar/src/menubar-radio-group.directive.mjs +17 -0
  154. package/esm2022/menubar/src/menubar-root.directive.mjs +24 -0
  155. package/esm2022/menubar/src/menubar-separator.directive.mjs +17 -0
  156. package/esm2022/menubar/src/menubar-trigger.directive.mjs +45 -0
  157. package/esm2022/progress/index.mjs +25 -0
  158. package/esm2022/progress/radix-ng-primitives-progress.mjs +5 -0
  159. package/esm2022/progress/src/progress-indicator.directive.mjs +34 -0
  160. package/esm2022/progress/src/progress-root.directive.mjs +127 -0
  161. package/esm2022/radio/index.mjs +4 -0
  162. package/esm2022/radio/radix-ng-primitives-radio.mjs +5 -0
  163. package/esm2022/radio/src/radio-indicator.directive.mjs +25 -0
  164. package/esm2022/radio/src/radio-item.directive.mjs +70 -0
  165. package/esm2022/radio/src/radio-root.directive.mjs +194 -0
  166. package/esm2022/radio/src/radio-tokens.mjs +3 -0
  167. package/esm2022/radix-ng-primitives.mjs +5 -0
  168. package/esm2022/separator/index.mjs +2 -0
  169. package/esm2022/separator/radix-ng-primitives-separator.mjs +5 -0
  170. package/esm2022/separator/src/separator.directive.mjs +32 -0
  171. package/esm2022/switch/index.mjs +30 -0
  172. package/esm2022/switch/radix-ng-primitives-switch.mjs +5 -0
  173. package/esm2022/switch/src/switch-input.directive.mjs +32 -0
  174. package/esm2022/switch/src/switch-root.directive.mjs +95 -0
  175. package/esm2022/switch/src/switch-thumb.directive.mjs +23 -0
  176. package/esm2022/tabs/index.mjs +38 -0
  177. package/esm2022/tabs/radix-ng-primitives-tabs.mjs +5 -0
  178. package/esm2022/tabs/src/tabs-content.directive.mjs +29 -0
  179. package/esm2022/tabs/src/tabs-context.service.mjs +43 -0
  180. package/esm2022/tabs/src/tabs-list.directive.mjs +23 -0
  181. package/esm2022/tabs/src/tabs-root.directive.mjs +54 -0
  182. package/esm2022/tabs/src/tabs-trigger.directive.mjs +52 -0
  183. package/esm2022/toggle/index.mjs +2 -0
  184. package/esm2022/toggle/radix-ng-primitives-toggle.mjs +5 -0
  185. package/esm2022/toggle/src/toggle.directive.mjs +39 -0
  186. package/esm2022/toggle-group/index.mjs +6 -0
  187. package/esm2022/toggle-group/radix-ng-primitives-toggle-group.mjs +5 -0
  188. package/esm2022/toggle-group/src/toggle-group-button.directive.mjs +75 -0
  189. package/esm2022/toggle-group/src/toggle-group-button.token.mjs +6 -0
  190. package/esm2022/toggle-group/src/toggle-group-multi.directive.mjs +143 -0
  191. package/esm2022/toggle-group/src/toggle-group.directive.mjs +134 -0
  192. package/esm2022/toggle-group/src/toggle-group.token.mjs +6 -0
  193. package/fesm2022/radix-ng-primitives-accordion.mjs +483 -0
  194. package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -0
  195. package/fesm2022/radix-ng-primitives-alert-dialog.mjs +159 -0
  196. package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -0
  197. package/fesm2022/radix-ng-primitives-avatar.mjs +166 -0
  198. package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -0
  199. package/fesm2022/radix-ng-primitives-checkbox.mjs +241 -0
  200. package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -0
  201. package/fesm2022/radix-ng-primitives-collapsible.mjs +213 -0
  202. package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -0
  203. package/fesm2022/radix-ng-primitives-context-menu.mjs +463 -0
  204. package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -0
  205. package/fesm2022/radix-ng-primitives-dialog.mjs +373 -0
  206. package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -0
  207. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +555 -0
  208. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs.map +1 -0
  209. package/fesm2022/radix-ng-primitives-label.mjs +66 -0
  210. package/fesm2022/radix-ng-primitives-label.mjs.map +1 -0
  211. package/fesm2022/radix-ng-primitives-menu.mjs +158 -0
  212. package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -0
  213. package/fesm2022/radix-ng-primitives-menubar.mjs +245 -0
  214. package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -0
  215. package/fesm2022/radix-ng-primitives-progress.mjs +184 -0
  216. package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -0
  217. package/fesm2022/radix-ng-primitives-radio.mjs +289 -0
  218. package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -0
  219. package/fesm2022/radix-ng-primitives-separator.mjs +39 -0
  220. package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -0
  221. package/fesm2022/radix-ng-primitives-switch.mjs +173 -0
  222. package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -0
  223. package/fesm2022/radix-ng-primitives-tabs.mjs +222 -0
  224. package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -0
  225. package/fesm2022/radix-ng-primitives-toggle-group.mjs +358 -0
  226. package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -0
  227. package/fesm2022/radix-ng-primitives-toggle.mjs +46 -0
  228. package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -0
  229. package/fesm2022/radix-ng-primitives.mjs +4 -0
  230. package/fesm2022/radix-ng-primitives.mjs.map +1 -0
  231. package/label/src/label.directive.d.ts +29 -0
  232. package/menu/index.d.ts +18 -0
  233. package/menu/src/menu-content.directive.d.ts +6 -0
  234. package/menu/src/menu-directive.d.ts +6 -0
  235. package/menu/src/menu-group.directive.d.ts +6 -0
  236. package/menu/src/menu-item.directive.d.ts +12 -0
  237. package/menu/src/menu-label.directive.d.ts +5 -0
  238. package/menu/src/menu-separator.directive.d.ts +6 -0
  239. package/menubar/index.d.ts +24 -0
  240. package/menubar/src/menubar-content.directive.d.ts +6 -0
  241. package/menubar/src/menubar-item-checkbox.directive.d.ts +14 -0
  242. package/menubar/src/menubar-item-indicator.directive.d.ts +5 -0
  243. package/menubar/src/menubar-item-radio.directive.d.ts +14 -0
  244. package/menubar/src/menubar-item.directive.d.ts +8 -0
  245. package/menubar/src/menubar-radio-group.directive.d.ts +6 -0
  246. package/menubar/src/menubar-root.directive.d.ts +7 -0
  247. package/menubar/src/menubar-separator.directive.d.ts +6 -0
  248. package/menubar/src/menubar-trigger.directive.d.ts +11 -0
  249. package/package.json +124 -4
  250. package/progress/index.d.ts +11 -0
  251. package/progress/src/progress-indicator.directive.d.ts +16 -0
  252. package/progress/src/progress-root.directive.d.ts +63 -0
  253. package/radio/{index.ts → index.d.ts} +0 -1
  254. package/radio/src/radio-indicator.directive.d.ts +9 -0
  255. package/radio/src/radio-item.directive.d.ts +21 -0
  256. package/radio/src/radio-root.directive.d.ts +72 -0
  257. package/radio/src/{radio-tokens.ts → radio-tokens.d.ts} +1 -5
  258. package/separator/src/separator.directive.d.ts +22 -0
  259. package/switch/index.d.ts +13 -0
  260. package/switch/src/switch-input.directive.d.ts +6 -0
  261. package/switch/src/switch-root.directive.d.ts +51 -0
  262. package/switch/src/switch-thumb.directive.d.ts +6 -0
  263. package/tabs/index.d.ts +15 -0
  264. package/tabs/src/tabs-content.directive.d.ts +8 -0
  265. package/tabs/src/tabs-context.service.d.ts +22 -0
  266. package/tabs/src/tabs-list.directive.d.ts +6 -0
  267. package/tabs/src/tabs-root.directive.d.ts +37 -0
  268. package/tabs/src/tabs-trigger.directive.d.ts +19 -0
  269. package/toggle/src/toggle.directive.d.ts +30 -0
  270. package/toggle-group/src/toggle-group-button.directive.d.ts +39 -0
  271. package/toggle-group/src/toggle-group-button.token.d.ts +4 -0
  272. package/toggle-group/src/toggle-group-multi.directive.d.ts +93 -0
  273. package/toggle-group/src/toggle-group.directive.d.ts +84 -0
  274. package/toggle-group/src/toggle-group.token.d.ts +5 -0
  275. package/.compodocrc.json +0 -12
  276. package/CHANGELOG.md +0 -189
  277. package/accordion/__tests__/accordion-content.directive.spec.ts +0 -8
  278. package/accordion/__tests__/accordion-header.directive.spec.ts +0 -8
  279. package/accordion/__tests__/accordion-item.directive.spec.ts +0 -8
  280. package/accordion/__tests__/accordion-root.directive.spec.ts +0 -8
  281. package/accordion/__tests__/accordion-trigger.directive.spec.ts +0 -8
  282. package/accordion/index.ts +0 -5
  283. package/accordion/ng-package.json +0 -5
  284. package/accordion/src/accordion-content.directive.ts +0 -46
  285. package/accordion/src/accordion-header.directive.ts +0 -15
  286. package/accordion/src/accordion-item.directive.ts +0 -216
  287. package/accordion/src/accordion-root.directive.ts +0 -205
  288. package/accordion/src/accordion-trigger.directive.ts +0 -37
  289. package/accordion/stories/accordion.docs.mdx +0 -77
  290. package/accordion/stories/accordion.stories.ts +0 -340
  291. package/alert-dialog/ng-package.json +0 -5
  292. package/alert-dialog/src/alert-dialog-cancel.directive.ts +0 -17
  293. package/alert-dialog/src/alert-dialog-content.directive.ts +0 -24
  294. package/alert-dialog/src/alert-dialog-root.directive.ts +0 -15
  295. package/alert-dialog/src/alert-dialog-title.directive.ts +0 -7
  296. package/alert-dialog/src/alert-dialog-trigger.directive.ts +0 -17
  297. package/alert-dialog/src/alert-dialog.service.ts +0 -51
  298. package/alert-dialog/stories/alert-dialog.stories.ts +0 -139
  299. package/avatar/__tests__/avatar-fallback.directive.spec.ts +0 -31
  300. package/avatar/__tests__/avatar-image.directive.spec.ts +0 -36
  301. package/avatar/ng-package.json +0 -5
  302. package/avatar/src/avatar-fallback.directive.ts +0 -62
  303. package/avatar/src/avatar-image.directive.ts +0 -55
  304. package/avatar/src/avatar-root.directive.ts +0 -35
  305. package/avatar/src/avatar.config.ts +0 -29
  306. package/avatar/stories/avatar.docs.mdx +0 -37
  307. package/avatar/stories/avatar.stories.ts +0 -87
  308. package/button/__tests__/.gitkeep +0 -0
  309. package/button/src/button-abstract.directive.ts +0 -46
  310. package/checkbox/ng-package.json +0 -5
  311. package/checkbox/src/checkbox-button.directive.ts +0 -26
  312. package/checkbox/src/checkbox-indicator.directive.ts +0 -16
  313. package/checkbox/src/checkbox-input.directive.ts +0 -36
  314. package/checkbox/src/checkbox.directive.ts +0 -146
  315. package/checkbox/src/checkbox.token.ts +0 -8
  316. package/checkbox/stories/checkbox-group.component.ts +0 -87
  317. package/checkbox/stories/checkbox-group.styles.scss +0 -49
  318. package/checkbox/stories/checkbox-indeterminate.component.ts +0 -52
  319. package/checkbox/stories/checkbox.docs.mdx +0 -58
  320. package/checkbox/stories/checkbox.stories.ts +0 -105
  321. package/collapsible/__tests__/collapsible-content.directive.spec.ts +0 -30
  322. package/collapsible/__tests__/collapsible-root.directive.spec.ts +0 -27
  323. package/collapsible/__tests__/collapsible-trigger.directive.spec.ts +0 -30
  324. package/collapsible/ng-package.json +0 -5
  325. package/collapsible/src/collapsible-content.directive.ts +0 -34
  326. package/collapsible/src/collapsible-content.token.ts +0 -6
  327. package/collapsible/src/collapsible-root.directive.ts +0 -120
  328. package/collapsible/src/collapsible-trigger.directive.ts +0 -44
  329. package/collapsible/stories/collapsible-animation.component.ts +0 -116
  330. package/collapsible/stories/collapsible-external-triggering.component.ts +0 -86
  331. package/collapsible/stories/collapsible.docs.mdx +0 -53
  332. package/collapsible/stories/collapsible.stories.ts +0 -151
  333. package/context-menu/index.ts +0 -10
  334. package/context-menu/ng-package.json +0 -5
  335. package/context-menu/src/context-menu-content.directive.ts +0 -47
  336. package/context-menu/src/context-menu-item-checkbox.directive.ts +0 -30
  337. package/context-menu/src/context-menu-item-indicator.directive.ts +0 -14
  338. package/context-menu/src/context-menu-item-radio-group.directive.ts +0 -31
  339. package/context-menu/src/context-menu-item-radio.directive.ts +0 -69
  340. package/context-menu/src/context-menu-item-selectable.ts +0 -18
  341. package/context-menu/src/context-menu-item.directive.ts +0 -65
  342. package/context-menu/src/context-menu-label.directive.ts +0 -7
  343. package/context-menu/src/context-menu-separator.directive.ts +0 -13
  344. package/context-menu/src/context-menu-trigger.directive.ts +0 -82
  345. package/context-menu/stories/context-menu.docs.mdx +0 -23
  346. package/context-menu/stories/context-menu.stories.ts +0 -253
  347. package/core/index.ts +0 -3
  348. package/core/src/accessor/provide-value-accessor.ts +0 -20
  349. package/core/src/auto-focus.directive.ts +0 -81
  350. package/core/src/inject-ng-control.ts +0 -28
  351. package/core/src/mount.ts +0 -27
  352. package/dialog/__tests__/dialog-content.directive.spec.ts +0 -77
  353. package/dialog/__tests__/dialog-trigger.directive.spec.ts +0 -85
  354. package/dialog/index.ts +0 -31
  355. package/dialog/ng-package.json +0 -5
  356. package/dialog/src/dialog-close.directive.ts +0 -18
  357. package/dialog/src/dialog-content.directive.ts +0 -45
  358. package/dialog/src/dialog-description.directive.ts +0 -7
  359. package/dialog/src/dialog-dismiss.directive.ts +0 -18
  360. package/dialog/src/dialog-ref.ts +0 -70
  361. package/dialog/src/dialog-title.directive.ts +0 -7
  362. package/dialog/src/dialog-trigger.directive.ts +0 -52
  363. package/dialog/src/dialog.config.ts +0 -55
  364. package/dialog/src/dialog.injectors.ts +0 -12
  365. package/dialog/src/dialog.service.ts +0 -94
  366. package/dialog/stories/dialog.docs.mdx +0 -32
  367. package/dialog/stories/dialog.stories.ts +0 -233
  368. package/dropdown-menu/index.ts +0 -10
  369. package/dropdown-menu/ng-package.json +0 -5
  370. package/dropdown-menu/src/dropdown-menu-content.directive.ts +0 -47
  371. package/dropdown-menu/src/dropdown-menu-item-checkbox.directive.ts +0 -30
  372. package/dropdown-menu/src/dropdown-menu-item-indicator.directive.ts +0 -14
  373. package/dropdown-menu/src/dropdown-menu-item-radio-group.directive.ts +0 -31
  374. package/dropdown-menu/src/dropdown-menu-item-radio.directive.ts +0 -72
  375. package/dropdown-menu/src/dropdown-menu-item-selectable.ts +0 -18
  376. package/dropdown-menu/src/dropdown-menu-item.directive.ts +0 -66
  377. package/dropdown-menu/src/dropdown-menu-label.directive.ts +0 -7
  378. package/dropdown-menu/src/dropdown-menu-separator.directive.ts +0 -13
  379. package/dropdown-menu/src/dropdown-menu-trigger.directive.ts +0 -185
  380. package/dropdown-menu/stories/dropdown-menu-item-checkbox.component.ts +0 -104
  381. package/dropdown-menu/stories/dropdown-menu-item-checkbox.styles.scss +0 -106
  382. package/dropdown-menu/stories/dropdown-menu-item-radio.component.ts +0 -95
  383. package/dropdown-menu/stories/dropdown-menu-item-radio.styles.scss +0 -106
  384. package/dropdown-menu/stories/dropdown.docs.mdx +0 -27
  385. package/dropdown-menu/stories/dropdown.stories.ts +0 -212
  386. package/form-field/index.ts +0 -1
  387. package/form-field/src/.gitkeep +0 -0
  388. package/jest.config.ts +0 -21
  389. package/label/__tests__/label-root.directive.spec.ts +0 -99
  390. package/label/ng-package.json +0 -5
  391. package/label/src/label.directive.ts +0 -58
  392. package/label/stories/label.docs.mdx +0 -40
  393. package/label/stories/label.stories.ts +0 -76
  394. package/menu/index.ts +0 -29
  395. package/menu/ng-package.json +0 -5
  396. package/menu/src/menu-content.directive.ts +0 -9
  397. package/menu/src/menu-directive.ts +0 -10
  398. package/menu/src/menu-group.directive.ts +0 -12
  399. package/menu/src/menu-item.directive.ts +0 -44
  400. package/menu/src/menu-label.directive.ts +0 -7
  401. package/menu/src/menu-separator.directive.ts +0 -13
  402. package/menubar/index.ts +0 -38
  403. package/menubar/ng-package.json +0 -5
  404. package/menubar/src/menubar-content.directive.ts +0 -9
  405. package/menubar/src/menubar-item-checkbox.directive.ts +0 -32
  406. package/menubar/src/menubar-item-indicator.directive.ts +0 -10
  407. package/menubar/src/menubar-item-radio.directive.ts +0 -33
  408. package/menubar/src/menubar-item.directive.ts +0 -12
  409. package/menubar/src/menubar-radio-group.directive.ts +0 -9
  410. package/menubar/src/menubar-root.directive.ts +0 -15
  411. package/menubar/src/menubar-separator.directive.ts +0 -9
  412. package/menubar/src/menubar-trigger.directive.ts +0 -40
  413. package/menubar/stories/menubar.stories.ts +0 -229
  414. package/ng-package.json +0 -8
  415. package/portal/stories/portal.docs.mdx +0 -85
  416. package/presence/__test__/presence-test.component.ts +0 -51
  417. package/presence/__test__/presence.spec.ts +0 -50
  418. package/presence/index.ts +0 -4
  419. package/presence/src/presence.ts +0 -119
  420. package/presence/src/transitions/transition.collapse.ts +0 -99
  421. package/presence/src/transitions/transition.toast.ts +0 -27
  422. package/presence/src/types.ts +0 -20
  423. package/presence/src/utils.ts +0 -63
  424. package/presence/stories/presence-story.componen.ts +0 -69
  425. package/presence/stories/presence.docs.mdx +0 -40
  426. package/presence/stories/presence.stories.ts +0 -29
  427. package/progress/__test__/progress.spec.ts +0 -55
  428. package/progress/index.ts +0 -4
  429. package/progress/ng-package.json +0 -5
  430. package/progress/src/progress-indicator.directive.ts +0 -26
  431. package/progress/src/progress-root.directive.ts +0 -134
  432. package/progress/stories/progress.docs.mdx +0 -65
  433. package/progress/stories/progress.stories.ts +0 -66
  434. package/project.json +0 -39
  435. package/radio/ng-package.json +0 -5
  436. package/radio/src/radio-indicator.directive.ts +0 -17
  437. package/radio/src/radio-item.directive.ts +0 -68
  438. package/radio/src/radio-root.directive.ts +0 -207
  439. package/radio/stories/radio-group.component.ts +0 -39
  440. package/radio/stories/radio-group.styles.scss +0 -70
  441. package/radio/stories/radio.docs.mdx +0 -68
  442. package/radio/stories/radio.stories.ts +0 -155
  443. package/separator/__tests__/separator.directive.spec.ts +0 -58
  444. package/separator/ng-package.json +0 -5
  445. package/separator/src/separator.directive.ts +0 -35
  446. package/separator/stories/separator.docs.mdx +0 -37
  447. package/separator/stories/separator.stories.ts +0 -82
  448. package/slider/src/slider-input.directive.ts +0 -0
  449. package/slider/src/slider-thumb.directives.ts +0 -60
  450. package/slider/src/slider-track.directive.ts +0 -11
  451. package/slider/src/slider.directive.ts +0 -59
  452. package/slider/src/slider.types.ts +0 -4
  453. package/switch/index.ts +0 -22
  454. package/switch/ng-package.json +0 -5
  455. package/switch/src/switch-input.directive.ts +0 -24
  456. package/switch/src/switch-root.directive.ts +0 -127
  457. package/switch/src/switch-thumb.directive.ts +0 -15
  458. package/switch/stories/switch.docs.mdx +0 -83
  459. package/switch/stories/switch.stories.ts +0 -149
  460. package/tabs/__tests__/tabs-context.service.spec.ts +0 -35
  461. package/tabs/index.ts +0 -26
  462. package/tabs/ng-package.json +0 -5
  463. package/tabs/src/tabs-content.directive.ts +0 -23
  464. package/tabs/src/tabs-context.service.ts +0 -43
  465. package/tabs/src/tabs-list.directive.ts +0 -21
  466. package/tabs/src/tabs-root.directive.ts +0 -70
  467. package/tabs/src/tabs-trigger.directive.ts +0 -55
  468. package/tabs/stories/tabs.stories.ts +0 -213
  469. package/test-setup.ts +0 -1
  470. package/toggle/__tests__/toggle.directive.spec.ts +0 -87
  471. package/toggle/ng-package.json +0 -5
  472. package/toggle/src/toggle.directive.ts +0 -49
  473. package/toggle/stories/toggle.docs.mdx +0 -60
  474. package/toggle/stories/toggle.stories.ts +0 -84
  475. package/toggle-group/ng-package.json +0 -5
  476. package/toggle-group/src/toggle-group-button.directive.ts +0 -73
  477. package/toggle-group/src/toggle-group-button.token.ts +0 -8
  478. package/toggle-group/src/toggle-group-multi.directive.ts +0 -158
  479. package/toggle-group/src/toggle-group.directive.ts +0 -148
  480. package/toggle-group/src/toggle-group.token.ts +0 -11
  481. package/toggle-group/stories/toggle-group.docs.mdx +0 -87
  482. package/toggle-group/stories/toggle-group.stories.ts +0 -95
  483. package/tsconfig.doc.json +0 -11
  484. package/tsconfig.json +0 -29
  485. package/tsconfig.lib.json +0 -19
  486. package/tsconfig.lib.prod.json +0 -12
  487. package/tsconfig.spec.json +0 -11
  488. package/visually-hidden/README.md +0 -3
  489. package/visually-hidden/stories/visually-hidden.docs.mdx +0 -36
  490. /package/avatar/{index.ts → index.d.ts} +0 -0
  491. /package/checkbox/{index.ts → index.d.ts} +0 -0
  492. /package/collapsible/{index.ts → index.d.ts} +0 -0
  493. /package/{index.ts → index.d.ts} +0 -0
  494. /package/label/{index.ts → index.d.ts} +0 -0
  495. /package/separator/{index.ts → index.d.ts} +0 -0
  496. /package/toggle/{index.ts → index.d.ts} +0 -0
  497. /package/toggle-group/{index.ts → index.d.ts} +0 -0
@@ -1,134 +0,0 @@
1
- import { Directive, inject, InjectionToken, Input, numberAttribute, OnChanges, SimpleChanges } from '@angular/core';
2
-
3
- let idIterator = 0;
4
-
5
- const MIN_PERCENT = 0;
6
- const DEFAULT_MAX = 100;
7
- const PROGRESS_NAME = 'Radix Progress';
8
-
9
- const RdxProgressToken = new InjectionToken<RdxProgressRootDirective>('RdxProgressDirective');
10
-
11
- /**
12
- * Injects the current instance of RdxProgressRootDirective.
13
- * @returns The instance of RdxProgressRootDirective.
14
- */
15
- export function injectProgress(): RdxProgressRootDirective {
16
- return inject(RdxProgressToken);
17
- }
18
-
19
- export type ProgressState = 'indeterminate' | 'complete' | 'loading';
20
-
21
- export interface ProgressProps {
22
- value?: number | null | undefined;
23
- max?: number;
24
- getValueLabel?: string;
25
- }
26
-
27
- /**
28
- * Directive to manage progress bar state and attributes.
29
- *
30
- * This directive provides a way to create a progress bar with customizable value and max attributes.
31
- * It handles aria attributes for accessibility and provides different states like 'indeterminate', 'complete', and 'loading'.
32
- */
33
- @Directive({
34
- selector: 'div[rdxProgressRoot]',
35
- exportAs: 'ProgressRoot',
36
- standalone: true,
37
- providers: [{ provide: RdxProgressToken, useExisting: RdxProgressRootDirective }],
38
- host: {
39
- role: 'progressbar',
40
- '[id]': 'id',
41
- '[attr.aria-valuemax]': 'max',
42
- '[attr.aria-valuemin]': '0',
43
- '[attr.aria-valuenow]': 'value',
44
- '[attr.aria-valuetext]': 'valueLabel(value, max)',
45
- '[attr.data-state]': 'state',
46
- '[attr.data-value]': 'value',
47
- '[attr.data-max]': 'max',
48
- // set tab index to -1 so screen readers will read the aria-label
49
- // Note: there is a known issue with JAWS that does not read progressbar aria labels on FireFox
50
- tabindex: '-1'
51
- }
52
- })
53
- export class RdxProgressRootDirective implements ProgressProps, OnChanges {
54
- /**
55
- * The unique ID for the progress bar.
56
- * @default 'rdx-progress-bar-{idIterator}'
57
- */
58
- @Input() id = `rdx-progress-bar-${idIterator++}`;
59
-
60
- /**
61
- * The current value of the progress bar.
62
- * @default 0
63
- */
64
- @Input({ alias: 'rdxValue', transform: numberAttribute }) value = MIN_PERCENT;
65
-
66
- /**
67
- * The maximum value of the progress bar.
68
- * @default 100
69
- */
70
- @Input({ alias: 'rdxMax', transform: numberAttribute }) max = DEFAULT_MAX;
71
-
72
- /**
73
- * Function to generate the value label.
74
- */
75
- @Input('rdxValueLabel') valueLabel: (value: number, max: number) => string = (value, max) =>
76
- this.defaultGetValueLabel(value, max);
77
-
78
- /**
79
- * Lifecycle hook that is called when any data-bound property of a directive changes.
80
- * @param changes - The changed properties.
81
- * @ignore
82
- */
83
- ngOnChanges(changes: SimpleChanges) {
84
- if (changes['max'] && !this.isValidMaxNumber(this.max)) {
85
- console.error(this.getInvalidMaxError(`${this.max}`, PROGRESS_NAME));
86
- }
87
-
88
- if (changes['value'] && this.value !== null && !this.isValidValueNumber(this.value, this.max)) {
89
- console.error(this.getInvalidValueError(`${this.value}`, PROGRESS_NAME));
90
- }
91
- }
92
-
93
- /**
94
- * Get the state of the progress bar.
95
- * @returns 'indeterminate' | 'loading' | 'complete'
96
- * @ignore
97
- */
98
- get state(): ProgressState {
99
- return this.getProgressState(this.value, this.max);
100
- }
101
-
102
- private getProgressState(value: number | undefined | null, maxValue: number): ProgressState {
103
- return value == null ? 'indeterminate' : value === maxValue ? 'complete' : 'loading';
104
- }
105
-
106
- private defaultGetValueLabel(value: number, max: number) {
107
- return `${Math.round((value / max) * 100)}%`;
108
- }
109
-
110
- private isValidMaxNumber(max: unknown): max is number {
111
- return this.isNumber(max) && !isNaN(max) && max > 0;
112
- }
113
-
114
- private isNumber(value: unknown): value is number {
115
- return typeof value === 'number';
116
- }
117
-
118
- private isValidValueNumber(value: unknown, max: number): value is number {
119
- return this.isNumber(value) && !isNaN(value) && value <= max && value >= 0;
120
- }
121
-
122
- private getInvalidMaxError(propValue: string, componentName: string): string {
123
- return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
124
- }
125
-
126
- private getInvalidValueError(propValue: string, componentName: string): string {
127
- return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
128
- - a positive number
129
- - less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
130
- - \`null\` or \`undefined\` if the progress is indeterminate.
131
-
132
- Defaulting to \`null\`.`;
133
- }
134
- }
@@ -1,65 +0,0 @@
1
- import { ArgTypes, Canvas, Markdown, Meta } from '@storybook/blocks';
2
- import { RdxProgressRootDirective } from '../src/progress-root.directive';
3
- import * as ProgressDirectiveStories from './progress.stories';
4
-
5
- <Meta title="Primitives/Progress" />
6
-
7
- # Progress
8
-
9
- #### Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
10
-
11
- <Canvas sourceState="hidden" of={ProgressDirectiveStories.Default} />
12
-
13
- ## Features
14
-
15
- - ✅ Provides context for assistive technology to read the progress of a task.
16
-
17
- ## Usage
18
-
19
- Get started with importing the directive:
20
-
21
- ```typescript
22
- import { RdxProgressRootDirective, RdxProgressIndicatorDirective } from '@radix-ng/primitives/progress';
23
- ```
24
-
25
- ## Example
26
-
27
- ```html
28
- <div class="ProgressRoot" rdxProgressRoot [rdxValue]="progress">
29
- <div class="ProgressIndicator" rdxProgressIndicator [style.transform]="'translateX(-' + (100 - progress) +'%)'"></div>
30
- </div>
31
- ```
32
-
33
- ## API Reference
34
-
35
- ### RdxProgressRootDirective
36
-
37
- <ArgTypes of={RdxProgressRootDirective} />
38
-
39
- <Markdown>
40
- {`
41
- | Data Attribute | Value |
42
- | ----------- | --------- |
43
- | [data-state] | "complete" or "indeterminate" or "loading" |
44
- | [data-value] | The current value |
45
- | [data-max] | The max value |
46
- `}
47
- </Markdown>
48
-
49
- ### RdxProgressIndicatorDirective
50
-
51
- Used to show the progress visually. It also makes progress accessible to assistive technologies.
52
-
53
- <Markdown>
54
- {`
55
- | Data Attribute | Value |
56
- | ----------- | --------- |
57
- | [data-state] | "complete" or "indeterminate" or "loading" |
58
- | [data-value] | The current value |
59
- | [data-max] | The max value |
60
- `}
61
- </Markdown>
62
-
63
- ## Accessibility
64
-
65
- Adheres to the [`progressbar` role requirements](https://www.w3.org/WAI/ARIA/apg/patterns/meter).
@@ -1,66 +0,0 @@
1
- import { componentWrapperDecorator, Meta, moduleMetadata, StoryObj } from '@storybook/angular';
2
- import { RdxProgressIndicatorDirective } from '../src/progress-indicator.directive';
3
- import { RdxProgressRootDirective } from '../src/progress-root.directive';
4
-
5
- export default {
6
- title: 'Primitives/Progress',
7
- decorators: [
8
- moduleMetadata({
9
- imports: [RdxProgressRootDirective, RdxProgressIndicatorDirective]
10
- }),
11
- componentWrapperDecorator(
12
- (story) =>
13
- `<div class="radix-themes light light-theme"
14
- data-radius="medium"
15
- data-scaling="100%">${story}</div>`
16
- )
17
- ],
18
- argTypes: {
19
- progress: {
20
- options: ['10', '30', '70', '95'],
21
- control: { type: 'select' }
22
- }
23
- }
24
- } as Meta;
25
-
26
- type Story = StoryObj;
27
-
28
- export const Default: Story = {
29
- args: {
30
- progress: 70
31
- },
32
- render: (args) => ({
33
- props: args,
34
- template: `
35
- <style>
36
- .ProgressRoot {
37
- position: relative;
38
- overflow: hidden;
39
- background: var(--black-a9);
40
- border-radius: 99999px;
41
- width: 300px;
42
- height: 25px;
43
-
44
- /* Fix overflow clipping in Safari */
45
- /* https://gist.github.com/domske/b66047671c780a238b51c51ffde8d3a0 */
46
- transform: translateZ(0);
47
- }
48
-
49
- .ProgressIndicator {
50
- background-color: white;
51
- width: 100%;
52
- height: 100%;
53
- transition: transform 660ms cubic-bezier(0.65, 0, 0.35, 1);
54
- }
55
- </style>
56
-
57
- <div rdxProgressRoot [rdxValue]="progress" class="ProgressRoot">
58
- <div rdxProgressIndicator
59
- [style.transform]="'translateX(-' + (100 - progress) +'%)'"
60
- class="ProgressIndicator"
61
- ></div>
62
- </div>
63
-
64
- `
65
- })
66
- };
package/project.json DELETED
@@ -1,39 +0,0 @@
1
- {
2
- "name": "primitives",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/primitives",
5
- "prefix": "rdx",
6
- "projectType": "library",
7
- "tags": [],
8
- "targets": {
9
- "build": {
10
- "executor": "@nx/angular:package",
11
- "outputs": ["{workspaceRoot}/dist/{projectRoot}"],
12
- "options": {
13
- "project": "packages/primitives/ng-package.json"
14
- },
15
- "configurations": {
16
- "production": {
17
- "tsConfig": "packages/primitives/tsconfig.lib.prod.json"
18
- },
19
- "development": {
20
- "tsConfig": "packages/primitives/tsconfig.lib.json"
21
- }
22
- },
23
- "defaultConfiguration": "production"
24
- },
25
- "compodoc": {
26
- "executor": "nx:run-script",
27
- "options": {
28
- "script": "compodoc"
29
- }
30
- },
31
- "test": {
32
- "executor": "@nx/jest:jest",
33
- "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
34
- "options": {
35
- "jestConfig": "packages/primitives/jest.config.ts"
36
- }
37
- }
38
- }
39
- }
@@ -1,5 +0,0 @@
1
- {
2
- "lib": {
3
- "entryFile": "index.ts"
4
- }
5
- }
@@ -1,17 +0,0 @@
1
- import { Directive, inject } from '@angular/core';
2
- import { RdxRadioItemDirective } from './radio-item.directive';
3
- import { RDX_RADIO_GROUP, RadioGroupDirective } from './radio-tokens';
4
-
5
- @Directive({
6
- selector: '[rdxRadioIndicator]',
7
- exportAs: 'rdxRadioIndicator',
8
- standalone: true,
9
- host: {
10
- '[attr.data-state]': 'radioItem.checked ? "checked" : "unchecked"',
11
- '[attr.data-disabled]': 'radioItem.disabled ? "" : null'
12
- }
13
- })
14
- export class RdxRadioIndicatorDirective {
15
- protected readonly radioGroup: RadioGroupDirective = inject(RDX_RADIO_GROUP);
16
- protected readonly radioItem: RdxRadioItemDirective = inject(RdxRadioItemDirective);
17
- }
@@ -1,68 +0,0 @@
1
- import { FocusableOption } from '@angular/cdk/a11y';
2
- import { booleanAttribute, Directive, ElementRef, inject, InjectionToken, Input, OnInit } from '@angular/core';
3
- import { RDX_RADIO_GROUP } from './radio-tokens';
4
-
5
- export const RdxRadioItemToken = new InjectionToken<RdxRadioItemDirective>('RadioItemToken');
6
-
7
- export function injectRadioItem(): RdxRadioItemDirective {
8
- return inject(RdxRadioItemToken);
9
- }
10
-
11
- // Increasing integer for generating unique ids for radio components.
12
- let nextUniqueId = 0;
13
-
14
- @Directive({
15
- selector: '[rdxRadioItem]',
16
- exportAs: 'rdxRadioItem',
17
- standalone: true,
18
- providers: [{ provide: RdxRadioItemToken, useExisting: RdxRadioItemDirective }],
19
- host: {
20
- type: 'button',
21
- role: 'radio',
22
- '[attr.id]': 'id',
23
- '[attr.aria-checked]': 'checked',
24
- '[attr.data-disabled]': 'disabled ? "" : null',
25
- '[attr.data-state]': 'checked ? "checked" : "unchecked"',
26
- '[attr.tabindex]': 'tabIndex',
27
- '(click)': '_onClick()',
28
- '(blur)': '_onBlur()'
29
- }
30
- })
31
- export class RdxRadioItemDirective implements FocusableOption, OnInit {
32
- private readonly radioGroup = inject(RDX_RADIO_GROUP);
33
- readonly element = inject(ElementRef);
34
-
35
- @Input() id = `rdx-radio-${++nextUniqueId}`;
36
-
37
- @Input({ required: true }) value!: string;
38
-
39
- @Input({ transform: booleanAttribute }) disabled = false;
40
-
41
- get tabIndex(): number {
42
- return this.disabled ? -1 : this.radioGroup.value === this.value ? 0 : -1;
43
- }
44
-
45
- get checked(): boolean {
46
- return this.radioGroup.value === this.value;
47
- }
48
-
49
- ngOnInit() {
50
- if (this.radioGroup.defaultValue === this.value) {
51
- this.radioGroup.select(this.value);
52
- }
53
- }
54
-
55
- focus(): void {
56
- this.element.nativeElement.focus();
57
- }
58
-
59
- _onClick(): void {
60
- if (!this.disabled) {
61
- this.radioGroup.select(this.value);
62
- }
63
- }
64
-
65
- _onBlur(): void {
66
- this.radioGroup.onTouched?.();
67
- }
68
- }
@@ -1,207 +0,0 @@
1
- import { FocusKeyManager } from '@angular/cdk/a11y';
2
- import { DOWN_ARROW, ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE, TAB, UP_ARROW } from '@angular/cdk/keycodes';
3
- import {
4
- AfterContentInit,
5
- booleanAttribute,
6
- ContentChildren,
7
- Directive,
8
- EventEmitter,
9
- Input,
10
- OnDestroy,
11
- Output,
12
- QueryList
13
- } from '@angular/core';
14
- import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
15
- import { Subject, takeUntil } from 'rxjs';
16
- import { RdxRadioItemDirective } from './radio-item.directive';
17
- import { RadioGroupDirective, RadioGroupProps, RDX_RADIO_GROUP } from './radio-tokens';
18
-
19
- @Directive({
20
- selector: '[rdxRadioRoot]',
21
- exportAs: 'rdxRadioRoot',
22
- standalone: true,
23
- providers: [
24
- { provide: RDX_RADIO_GROUP, useExisting: RdxRadioGroupDirective },
25
- { provide: NG_VALUE_ACCESSOR, useExisting: RdxRadioGroupDirective, multi: true }
26
- ],
27
- host: {
28
- role: 'radiogroup',
29
- '[attr.aria-orientation]': '_orientation',
30
- '[attr.data-disabled]': 'disabled ? "" : null',
31
- '[attr.tabindex]': '-1',
32
- '[attr.dir]': 'dir',
33
- '(keydown)': '_onKeydown($event)',
34
- '(focusin)': '_onFocusin($event)'
35
- }
36
- })
37
- export class RdxRadioGroupDirective
38
- implements RadioGroupProps, RadioGroupDirective, ControlValueAccessor, AfterContentInit, OnDestroy
39
- {
40
- @ContentChildren(RdxRadioItemDirective, { descendants: true }) radioItems!: QueryList<RdxRadioItemDirective>;
41
- private focusKeyManager!: FocusKeyManager<RdxRadioItemDirective>;
42
- private destroy$ = new Subject<void>();
43
-
44
- name?: string | undefined;
45
- @Input() value?: string;
46
-
47
- @Input({ transform: booleanAttribute }) disabled = false;
48
-
49
- @Input() dir?: string;
50
-
51
- @Input() defaultValue?: string;
52
-
53
- /**
54
- * The orientation of the radio group only vertical.
55
- * Horizontal radio buttons can sometimes be challenging to scan and localize.
56
- * The horizontal arrangement of radio buttons may also lead to difficulties in determining which
57
- * label corresponds to which button: whether the label is above or below the button.
58
- * @default 'vertical'
59
- */
60
- readonly _orientation = 'vertical';
61
-
62
- /**
63
- * Event handler called when the value changes.
64
- */
65
- @Output() readonly onValueChange = new EventEmitter<string>();
66
-
67
- /**
68
- * The callback function to call when the value of the radio group changes.
69
- */
70
- private onChange: (value: string) => void = () => {
71
- /* Empty */
72
- };
73
-
74
- /**
75
- * The callback function to call when the radio group is touched.
76
- */
77
- onTouched: () => void = () => {
78
- /* Empty */
79
- };
80
-
81
- ngAfterContentInit() {
82
- this.focusKeyManager = new FocusKeyManager(this.radioItems).withWrap().withVerticalOrientation();
83
-
84
- this.radioItems.changes.pipe(takeUntil(this.destroy$)).subscribe(() => {
85
- this.updateActiveItem();
86
- });
87
-
88
- this.updateActiveItem(false);
89
- }
90
-
91
- ngOnDestroy() {
92
- this.destroy$.next();
93
- this.destroy$.complete();
94
- }
95
-
96
- /**
97
- * Select a radio item.
98
- * @param value The value of the radio item to select.
99
- */
100
- select(value: string): void {
101
- this.value = value;
102
- this.onValueChange.emit(value);
103
- this.onChange?.(value);
104
- this.updateActiveItem();
105
- this.onTouched();
106
- }
107
-
108
- /**
109
- * Update the value of the radio group.
110
- * @param value The new value of the radio group.
111
- * @internal
112
- */
113
- writeValue(value: string): void {
114
- this.value = value;
115
- if (this.radioItems) {
116
- this.updateActiveItem(false);
117
- }
118
- }
119
-
120
- /**
121
- * Register a callback function to call when the value of the radio group changes.
122
- * @param fn The callback function to call when the value of the radio group changes.
123
- * @internal
124
- */
125
- registerOnChange(fn: (value: string) => void): void {
126
- this.onChange = fn;
127
- }
128
-
129
- registerOnTouched(fn: () => void): void {
130
- this.onTouched = fn;
131
- }
132
-
133
- /**
134
- * Set the disabled state of the radio group.
135
- * @param isDisabled Whether the radio group is disabled.
136
- * @internal
137
- */
138
- setDisabledState(isDisabled: boolean): void {
139
- this.disabled = isDisabled;
140
- }
141
-
142
- /**
143
- * When focus leaves the radio group.
144
- */
145
- _onFocusin(event: FocusEvent): void {
146
- const target = event.target as HTMLElement;
147
- const radioItem = this.radioItems.find((item) => item.element.nativeElement === target);
148
- if (radioItem) {
149
- this.focusKeyManager.setActiveItem(radioItem);
150
- }
151
- }
152
-
153
- _onKeydown(event: KeyboardEvent): void {
154
- if (this.disabled) return;
155
-
156
- switch (event.keyCode) {
157
- case ENTER:
158
- case SPACE:
159
- event.preventDefault();
160
- this.selectFocusedItem();
161
- break;
162
- case DOWN_ARROW:
163
- case RIGHT_ARROW:
164
- event.preventDefault();
165
- this.focusKeyManager.setNextItemActive();
166
- this.selectFocusedItem();
167
- break;
168
- case UP_ARROW:
169
- case LEFT_ARROW:
170
- event.preventDefault();
171
- this.focusKeyManager.setPreviousItemActive();
172
- this.selectFocusedItem();
173
- break;
174
- case TAB:
175
- this.tabNavigation(event);
176
- break;
177
- default:
178
- this.focusKeyManager.onKeydown(event);
179
- }
180
- }
181
-
182
- private selectFocusedItem(): void {
183
- const focusedItem = this.focusKeyManager.activeItem;
184
- if (focusedItem) {
185
- this.select(focusedItem.value);
186
- }
187
- }
188
-
189
- private updateActiveItem(setFocus = true): void {
190
- const activeItem = this.radioItems.find((item) => item.value === this.value);
191
- if (activeItem) {
192
- this.focusKeyManager.setActiveItem(activeItem);
193
- } else if (this.radioItems.length > 0 && setFocus) {
194
- this.focusKeyManager.setFirstItemActive();
195
- }
196
- }
197
-
198
- private tabNavigation(event: KeyboardEvent): void {
199
- event.preventDefault();
200
- const checkedItem = this.radioItems.find((item) => item.checked);
201
- if (checkedItem) {
202
- checkedItem.focus();
203
- } else if (this.radioItems.first) {
204
- this.radioItems.first.focus();
205
- }
206
- }
207
- }
@@ -1,39 +0,0 @@
1
- import { Component } from '@angular/core';
2
- import { FormsModule } from '@angular/forms';
3
- import { RdxLabelDirective } from '@radix-ng/primitives/label';
4
- import { RdxRadioGroupDirective, RdxRadioIndicatorDirective, RdxRadioItemDirective } from '@radix-ng/primitives/radio';
5
-
6
- @Component({
7
- selector: 'radio-groups-forms-example',
8
- standalone: true,
9
- template: `
10
- <div class="RadioGroupRoot" [(ngModel)]="hotelRoom" rdxRadioRoot aria-label="View density">
11
- @for (room of rooms; track room) {
12
- <div class="RadioGroup">
13
- <button class="RadioGroupItem" [value]="room" [id]="room" rdxRadioItem>
14
- <div class="RadioGroupIndicator" rdxRadioIndicator></div>
15
- <input class="Input" rdxRadioIndicator type="radio" aria-hidden="true" tabindex="-1" />
16
- </button>
17
- <label class="Label" [htmlFor]="room" rdxLabel>
18
- {{ room }}
19
- </label>
20
- </div>
21
- }
22
- </div>
23
- <p>
24
- <span>Your room is: {{ hotelRoom }}</span>
25
- </p>
26
- `,
27
- styleUrl: 'radio-group.styles.scss',
28
- imports: [
29
- FormsModule,
30
- RdxLabelDirective,
31
- RdxRadioItemDirective,
32
- RdxRadioIndicatorDirective,
33
- RdxRadioGroupDirective
34
- ]
35
- })
36
- export class RadioGroupComponent {
37
- hotelRoom: string | undefined;
38
- rooms = ['Default', 'Comfortable'];
39
- }