@radix-ng/primitives 0.11.1 → 0.12.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 (450) hide show
  1. package/.compodocrc.json +12 -0
  2. package/CHANGELOG.md +189 -0
  3. package/LICENSE +21 -0
  4. package/README.md +4 -2
  5. package/accordion/__tests__/accordion-content.directive.spec.ts +8 -0
  6. package/accordion/__tests__/accordion-header.directive.spec.ts +8 -0
  7. package/accordion/__tests__/accordion-item.directive.spec.ts +8 -0
  8. package/accordion/__tests__/accordion-root.directive.spec.ts +8 -0
  9. package/accordion/__tests__/accordion-trigger.directive.spec.ts +8 -0
  10. package/accordion/ng-package.json +5 -0
  11. package/accordion/src/accordion-content.directive.ts +46 -0
  12. package/accordion/src/accordion-header.directive.ts +15 -0
  13. package/accordion/src/accordion-item.directive.ts +216 -0
  14. package/accordion/src/accordion-root.directive.ts +205 -0
  15. package/accordion/src/accordion-trigger.directive.ts +37 -0
  16. package/accordion/stories/accordion.docs.mdx +77 -0
  17. package/accordion/stories/accordion.stories.ts +340 -0
  18. package/alert-dialog/{index.d.ts → index.ts} +1 -0
  19. package/alert-dialog/ng-package.json +5 -0
  20. package/alert-dialog/src/alert-dialog-cancel.directive.ts +17 -0
  21. package/alert-dialog/src/alert-dialog-content.directive.ts +24 -0
  22. package/alert-dialog/src/alert-dialog-root.directive.ts +15 -0
  23. package/alert-dialog/src/alert-dialog-title.directive.ts +7 -0
  24. package/alert-dialog/src/alert-dialog-trigger.directive.ts +17 -0
  25. package/alert-dialog/src/alert-dialog.service.ts +51 -0
  26. package/alert-dialog/stories/alert-dialog.stories.ts +139 -0
  27. package/avatar/__tests__/avatar-fallback.directive.spec.ts +31 -0
  28. package/avatar/__tests__/avatar-image.directive.spec.ts +36 -0
  29. package/avatar/ng-package.json +5 -0
  30. package/avatar/src/avatar-fallback.directive.ts +62 -0
  31. package/avatar/src/avatar-image.directive.ts +55 -0
  32. package/avatar/src/avatar-root.directive.ts +35 -0
  33. package/avatar/src/avatar.config.ts +29 -0
  34. package/avatar/stories/avatar.docs.mdx +37 -0
  35. package/avatar/stories/avatar.stories.ts +87 -0
  36. package/button/__tests__/.gitkeep +0 -0
  37. package/button/src/button-abstract.directive.ts +46 -0
  38. package/checkbox/ng-package.json +5 -0
  39. package/checkbox/src/checkbox-button.directive.ts +26 -0
  40. package/checkbox/src/checkbox-indicator.directive.ts +16 -0
  41. package/checkbox/src/checkbox-input.directive.ts +36 -0
  42. package/checkbox/src/checkbox.directive.ts +146 -0
  43. package/checkbox/src/checkbox.token.ts +8 -0
  44. package/checkbox/stories/checkbox-group.component.ts +87 -0
  45. package/checkbox/stories/checkbox-group.styles.scss +49 -0
  46. package/checkbox/stories/checkbox-indeterminate.component.ts +52 -0
  47. package/checkbox/stories/checkbox.docs.mdx +58 -0
  48. package/checkbox/stories/checkbox.stories.ts +105 -0
  49. package/collapsible/__tests__/collapsible-content.directive.spec.ts +30 -0
  50. package/collapsible/__tests__/collapsible-root.directive.spec.ts +27 -0
  51. package/collapsible/__tests__/collapsible-trigger.directive.spec.ts +30 -0
  52. package/collapsible/ng-package.json +5 -0
  53. package/collapsible/src/collapsible-content.directive.ts +34 -0
  54. package/collapsible/src/collapsible-content.token.ts +6 -0
  55. package/collapsible/src/collapsible-root.directive.ts +120 -0
  56. package/collapsible/src/collapsible-trigger.directive.ts +44 -0
  57. package/collapsible/stories/collapsible-animation.component.ts +116 -0
  58. package/collapsible/stories/collapsible-external-triggering.component.ts +86 -0
  59. package/collapsible/stories/collapsible.docs.mdx +53 -0
  60. package/collapsible/stories/collapsible.stories.ts +151 -0
  61. package/context-menu/README.md +1 -0
  62. package/context-menu/index.ts +10 -0
  63. package/context-menu/ng-package.json +5 -0
  64. package/context-menu/src/context-menu-content.directive.ts +47 -0
  65. package/context-menu/src/context-menu-item-checkbox.directive.ts +30 -0
  66. package/context-menu/src/context-menu-item-indicator.directive.ts +14 -0
  67. package/context-menu/src/context-menu-item-radio-group.directive.ts +31 -0
  68. package/context-menu/src/context-menu-item-radio.directive.ts +69 -0
  69. package/context-menu/src/context-menu-item-selectable.ts +18 -0
  70. package/context-menu/src/context-menu-item.directive.ts +65 -0
  71. package/context-menu/src/context-menu-label.directive.ts +7 -0
  72. package/context-menu/src/context-menu-separator.directive.ts +13 -0
  73. package/context-menu/src/context-menu-trigger.directive.ts +82 -0
  74. package/context-menu/stories/context-menu.docs.mdx +23 -0
  75. package/context-menu/stories/context-menu.stories.ts +253 -0
  76. package/core/index.ts +3 -0
  77. package/core/src/accessor/provide-value-accessor.ts +20 -0
  78. package/core/src/auto-focus.directive.ts +81 -0
  79. package/core/src/inject-ng-control.ts +28 -0
  80. package/core/src/mount.ts +27 -0
  81. package/dialog/__tests__/dialog-content.directive.spec.ts +77 -0
  82. package/dialog/__tests__/dialog-trigger.directive.spec.ts +85 -0
  83. package/dialog/index.ts +31 -0
  84. package/dialog/ng-package.json +5 -0
  85. package/dialog/src/dialog-close.directive.ts +18 -0
  86. package/dialog/src/dialog-content.directive.ts +45 -0
  87. package/dialog/src/dialog-description.directive.ts +7 -0
  88. package/dialog/src/dialog-dismiss.directive.ts +18 -0
  89. package/dialog/src/dialog-ref.ts +70 -0
  90. package/dialog/src/dialog-title.directive.ts +7 -0
  91. package/dialog/src/dialog-trigger.directive.ts +52 -0
  92. package/dialog/src/dialog.config.ts +55 -0
  93. package/dialog/src/dialog.injectors.ts +12 -0
  94. package/dialog/src/dialog.providers.ts +27 -0
  95. package/dialog/src/dialog.service.ts +94 -0
  96. package/dialog/stories/dialog.docs.mdx +32 -0
  97. package/dialog/stories/dialog.stories.ts +233 -0
  98. package/dropdown-menu/ng-package.json +5 -0
  99. package/dropdown-menu/src/dropdown-menu-content.directive.ts +47 -0
  100. package/dropdown-menu/src/dropdown-menu-item-checkbox.directive.ts +30 -0
  101. package/dropdown-menu/src/dropdown-menu-item-indicator.directive.ts +14 -0
  102. package/dropdown-menu/src/dropdown-menu-item-radio-group.directive.ts +31 -0
  103. package/dropdown-menu/src/dropdown-menu-item-radio.directive.ts +72 -0
  104. package/dropdown-menu/src/dropdown-menu-item-selectable.ts +18 -0
  105. package/dropdown-menu/src/dropdown-menu-item.directive.ts +66 -0
  106. package/dropdown-menu/src/dropdown-menu-label.directive.ts +7 -0
  107. package/dropdown-menu/src/dropdown-menu-separator.directive.ts +13 -0
  108. package/dropdown-menu/src/dropdown-menu-trigger.directive.ts +185 -0
  109. package/dropdown-menu/stories/dropdown-menu-item-checkbox.component.ts +104 -0
  110. package/dropdown-menu/stories/dropdown-menu-item-checkbox.styles.scss +106 -0
  111. package/dropdown-menu/stories/dropdown-menu-item-radio.component.ts +95 -0
  112. package/dropdown-menu/stories/dropdown-menu-item-radio.styles.scss +106 -0
  113. package/dropdown-menu/stories/dropdown.docs.mdx +27 -0
  114. package/dropdown-menu/stories/dropdown.stories.ts +212 -0
  115. package/form-field/index.ts +1 -0
  116. package/form-field/src/.gitkeep +0 -0
  117. package/jest.config.ts +21 -0
  118. package/label/__tests__/label-root.directive.spec.ts +99 -0
  119. package/label/ng-package.json +5 -0
  120. package/label/src/label.directive.ts +58 -0
  121. package/label/stories/label.docs.mdx +40 -0
  122. package/label/stories/label.stories.ts +76 -0
  123. package/menu/index.ts +29 -0
  124. package/menu/ng-package.json +5 -0
  125. package/menu/src/menu-content.directive.ts +9 -0
  126. package/menu/src/menu-directive.ts +10 -0
  127. package/menu/src/menu-group.directive.ts +12 -0
  128. package/menu/src/menu-item.directive.ts +44 -0
  129. package/menu/src/menu-label.directive.ts +7 -0
  130. package/menu/src/menu-separator.directive.ts +13 -0
  131. package/menubar/index.ts +38 -0
  132. package/menubar/ng-package.json +5 -0
  133. package/menubar/src/menubar-content.directive.ts +9 -0
  134. package/menubar/src/menubar-item-checkbox.directive.ts +32 -0
  135. package/menubar/src/menubar-item-indicator.directive.ts +10 -0
  136. package/menubar/src/menubar-item-radio.directive.ts +33 -0
  137. package/menubar/src/menubar-item.directive.ts +12 -0
  138. package/menubar/src/menubar-radio-group.directive.ts +9 -0
  139. package/menubar/src/menubar-root.directive.ts +15 -0
  140. package/menubar/src/menubar-separator.directive.ts +9 -0
  141. package/menubar/src/menubar-trigger.directive.ts +40 -0
  142. package/menubar/stories/menubar.stories.ts +229 -0
  143. package/ng-package.json +8 -0
  144. package/package.json +4 -118
  145. package/portal/stories/portal.docs.mdx +85 -0
  146. package/presence/__test__/presence-test.component.ts +51 -0
  147. package/presence/__test__/presence.spec.ts +50 -0
  148. package/presence/index.ts +4 -0
  149. package/presence/src/presence.ts +119 -0
  150. package/presence/src/transitions/transition.collapse.ts +99 -0
  151. package/presence/src/transitions/transition.toast.ts +27 -0
  152. package/presence/src/types.ts +20 -0
  153. package/presence/src/utils.ts +63 -0
  154. package/presence/stories/presence-story.componen.ts +69 -0
  155. package/presence/stories/presence.docs.mdx +40 -0
  156. package/presence/stories/presence.stories.ts +29 -0
  157. package/progress/__test__/progress.spec.ts +55 -0
  158. package/progress/{index.d.ts → index.ts} +1 -0
  159. package/progress/ng-package.json +5 -0
  160. package/progress/src/progress-indicator.directive.ts +26 -0
  161. package/progress/src/progress-root.directive.ts +134 -0
  162. package/progress/stories/progress.docs.mdx +65 -0
  163. package/progress/stories/progress.stories.ts +66 -0
  164. package/project.json +39 -0
  165. package/radio/{index.d.ts → index.ts} +1 -0
  166. package/radio/ng-package.json +5 -0
  167. package/radio/src/radio-indicator.directive.ts +17 -0
  168. package/radio/src/radio-item.directive.ts +68 -0
  169. package/radio/src/radio-root.directive.ts +207 -0
  170. package/radio/src/{radio-tokens.d.ts → radio-tokens.ts} +5 -1
  171. package/radio/stories/radio-group.component.ts +39 -0
  172. package/radio/stories/radio-group.styles.scss +70 -0
  173. package/radio/stories/radio.docs.mdx +68 -0
  174. package/radio/stories/radio.stories.ts +155 -0
  175. package/separator/__tests__/separator.directive.spec.ts +58 -0
  176. package/separator/ng-package.json +5 -0
  177. package/separator/src/separator.directive.ts +35 -0
  178. package/separator/stories/separator.docs.mdx +37 -0
  179. package/separator/stories/separator.stories.ts +82 -0
  180. package/slider/src/slider-input.directive.ts +0 -0
  181. package/slider/src/slider-thumb.directives.ts +60 -0
  182. package/slider/src/slider-track.directive.ts +11 -0
  183. package/slider/src/slider.directive.ts +59 -0
  184. package/slider/src/slider.types.ts +4 -0
  185. package/switch/index.ts +22 -0
  186. package/switch/ng-package.json +5 -0
  187. package/switch/src/switch-input.directive.ts +24 -0
  188. package/switch/src/switch-root.directive.ts +127 -0
  189. package/switch/src/switch-thumb.directive.ts +15 -0
  190. package/switch/stories/switch.docs.mdx +83 -0
  191. package/switch/stories/switch.stories.ts +149 -0
  192. package/tabs/__tests__/tabs-context.service.spec.ts +35 -0
  193. package/tabs/index.ts +26 -0
  194. package/tabs/ng-package.json +5 -0
  195. package/tabs/src/tabs-content.directive.ts +23 -0
  196. package/tabs/src/tabs-context.service.ts +43 -0
  197. package/tabs/src/tabs-list.directive.ts +21 -0
  198. package/tabs/src/tabs-root.directive.ts +70 -0
  199. package/tabs/src/tabs-trigger.directive.ts +55 -0
  200. package/tabs/stories/tabs.stories.ts +213 -0
  201. package/test-setup.ts +1 -0
  202. package/toggle/__tests__/toggle.directive.spec.ts +87 -0
  203. package/toggle/ng-package.json +5 -0
  204. package/toggle/src/toggle.directive.ts +49 -0
  205. package/toggle/stories/toggle.docs.mdx +60 -0
  206. package/toggle/stories/toggle.stories.ts +84 -0
  207. package/toggle-group/ng-package.json +5 -0
  208. package/toggle-group/src/toggle-group-button.directive.ts +73 -0
  209. package/toggle-group/src/toggle-group-button.token.ts +8 -0
  210. package/toggle-group/src/toggle-group-multi.directive.ts +158 -0
  211. package/toggle-group/src/toggle-group.directive.ts +148 -0
  212. package/toggle-group/src/toggle-group.token.ts +11 -0
  213. package/toggle-group/stories/toggle-group.docs.mdx +87 -0
  214. package/toggle-group/stories/toggle-group.stories.ts +95 -0
  215. package/tsconfig.doc.json +11 -0
  216. package/tsconfig.json +29 -0
  217. package/tsconfig.lib.json +19 -0
  218. package/tsconfig.lib.prod.json +12 -0
  219. package/tsconfig.spec.json +11 -0
  220. package/visually-hidden/README.md +3 -0
  221. package/visually-hidden/stories/visually-hidden.docs.mdx +36 -0
  222. package/accordion/src/accordion-content.directive.d.ts +0 -11
  223. package/accordion/src/accordion-header.directive.d.ts +0 -7
  224. package/accordion/src/accordion-item.directive.d.ts +0 -64
  225. package/accordion/src/accordion-root.directive.d.ts +0 -78
  226. package/accordion/src/accordion-trigger.directive.d.ts +0 -15
  227. package/alert-dialog/src/alert-dialog-cancel.directive.d.ts +0 -7
  228. package/alert-dialog/src/alert-dialog-content.directive.d.ts +0 -9
  229. package/alert-dialog/src/alert-dialog-root.directive.d.ts +0 -9
  230. package/alert-dialog/src/alert-dialog-title.directive.d.ts +0 -5
  231. package/alert-dialog/src/alert-dialog-trigger.directive.d.ts +0 -7
  232. package/alert-dialog/src/alert-dialog.service.d.ts +0 -14
  233. package/avatar/src/avatar-fallback.directive.d.ts +0 -27
  234. package/avatar/src/avatar-image.directive.d.ts +0 -16
  235. package/avatar/src/avatar-root.directive.d.ts +0 -21
  236. package/avatar/src/avatar.config.d.ts +0 -13
  237. package/checkbox/src/checkbox-button.directive.d.ts +0 -8
  238. package/checkbox/src/checkbox-indicator.directive.d.ts +0 -6
  239. package/checkbox/src/checkbox-input.directive.d.ts +0 -9
  240. package/checkbox/src/checkbox.directive.d.ts +0 -75
  241. package/checkbox/src/checkbox.token.d.ts +0 -4
  242. package/collapsible/src/collapsible-content.directive.d.ts +0 -17
  243. package/collapsible/src/collapsible-content.token.d.ts +0 -3
  244. package/collapsible/src/collapsible-root.directive.d.ts +0 -55
  245. package/collapsible/src/collapsible-trigger.directive.d.ts +0 -26
  246. package/compodoc/documentation.json +0 -11759
  247. package/dropdown-menu/src/dropdown-menu-content.directive.d.ts +0 -15
  248. package/dropdown-menu/src/dropdown-menu-item-checkbox.directive.d.ts +0 -9
  249. package/dropdown-menu/src/dropdown-menu-item-indicator.directive.d.ts +0 -7
  250. package/dropdown-menu/src/dropdown-menu-item-radio-group.directive.d.ts +0 -12
  251. package/dropdown-menu/src/dropdown-menu-item-radio.directive.d.ts +0 -19
  252. package/dropdown-menu/src/dropdown-menu-item-selectable.d.ts +0 -12
  253. package/dropdown-menu/src/dropdown-menu-item.directive.d.ts +0 -17
  254. package/dropdown-menu/src/dropdown-menu-label.directive.d.ts +0 -5
  255. package/dropdown-menu/src/dropdown-menu-separator.directive.d.ts +0 -6
  256. package/dropdown-menu/src/dropdown-menu-trigger.directive.d.ts +0 -43
  257. package/esm2022/accordion/index.mjs +0 -6
  258. package/esm2022/accordion/radix-ng-primitives-accordion.mjs +0 -5
  259. package/esm2022/accordion/src/accordion-content.directive.mjs +0 -42
  260. package/esm2022/accordion/src/accordion-header.directive.mjs +0 -23
  261. package/esm2022/accordion/src/accordion-item.directive.mjs +0 -175
  262. package/esm2022/accordion/src/accordion-root.directive.mjs +0 -160
  263. package/esm2022/accordion/src/accordion-trigger.directive.mjs +0 -42
  264. package/esm2022/alert-dialog/index.mjs +0 -7
  265. package/esm2022/alert-dialog/radix-ng-primitives-alert-dialog.mjs +0 -5
  266. package/esm2022/alert-dialog/src/alert-dialog-cancel.directive.mjs +0 -24
  267. package/esm2022/alert-dialog/src/alert-dialog-content.directive.mjs +0 -34
  268. package/esm2022/alert-dialog/src/alert-dialog-root.directive.mjs +0 -25
  269. package/esm2022/alert-dialog/src/alert-dialog-title.directive.mjs +0 -14
  270. package/esm2022/alert-dialog/src/alert-dialog-trigger.directive.mjs +0 -24
  271. package/esm2022/alert-dialog/src/alert-dialog.service.mjs +0 -47
  272. package/esm2022/avatar/index.mjs +0 -5
  273. package/esm2022/avatar/radix-ng-primitives-avatar.mjs +0 -5
  274. package/esm2022/avatar/src/avatar-fallback.directive.mjs +0 -54
  275. package/esm2022/avatar/src/avatar-image.directive.mjs +0 -48
  276. package/esm2022/avatar/src/avatar-root.directive.mjs +0 -38
  277. package/esm2022/avatar/src/avatar.config.mjs +0 -17
  278. package/esm2022/checkbox/index.mjs +0 -6
  279. package/esm2022/checkbox/radix-ng-primitives-checkbox.mjs +0 -5
  280. package/esm2022/checkbox/src/checkbox-button.directive.mjs +0 -33
  281. package/esm2022/checkbox/src/checkbox-indicator.directive.mjs +0 -24
  282. package/esm2022/checkbox/src/checkbox-input.directive.mjs +0 -41
  283. package/esm2022/checkbox/src/checkbox.directive.mjs +0 -141
  284. package/esm2022/checkbox/src/checkbox.token.mjs +0 -6
  285. package/esm2022/collapsible/index.mjs +0 -4
  286. package/esm2022/collapsible/radix-ng-primitives-collapsible.mjs +0 -5
  287. package/esm2022/collapsible/src/collapsible-content.directive.mjs +0 -45
  288. package/esm2022/collapsible/src/collapsible-content.token.mjs +0 -3
  289. package/esm2022/collapsible/src/collapsible-root.directive.mjs +0 -118
  290. package/esm2022/collapsible/src/collapsible-trigger.directive.mjs +0 -49
  291. package/esm2022/dialog/index.mjs +0 -2
  292. package/esm2022/dialog/radix-ng-primitives-dialog.mjs +0 -5
  293. package/esm2022/dropdown-menu/index.mjs +0 -11
  294. package/esm2022/dropdown-menu/radix-ng-primitives-dropdown-menu.mjs +0 -5
  295. package/esm2022/dropdown-menu/src/dropdown-menu-content.directive.mjs +0 -56
  296. package/esm2022/dropdown-menu/src/dropdown-menu-item-checkbox.directive.mjs +0 -36
  297. package/esm2022/dropdown-menu/src/dropdown-menu-item-indicator.directive.mjs +0 -22
  298. package/esm2022/dropdown-menu/src/dropdown-menu-item-radio-group.directive.mjs +0 -37
  299. package/esm2022/dropdown-menu/src/dropdown-menu-item-radio.directive.mjs +0 -64
  300. package/esm2022/dropdown-menu/src/dropdown-menu-item-selectable.mjs +0 -31
  301. package/esm2022/dropdown-menu/src/dropdown-menu-item.directive.mjs +0 -71
  302. package/esm2022/dropdown-menu/src/dropdown-menu-label.directive.mjs +0 -14
  303. package/esm2022/dropdown-menu/src/dropdown-menu-separator.directive.mjs +0 -21
  304. package/esm2022/dropdown-menu/src/dropdown-menu-trigger.directive.mjs +0 -176
  305. package/esm2022/index.mjs +0 -2
  306. package/esm2022/label/index.mjs +0 -2
  307. package/esm2022/label/radix-ng-primitives-label.mjs +0 -5
  308. package/esm2022/label/src/label.directive.mjs +0 -59
  309. package/esm2022/menu/index.mjs +0 -45
  310. package/esm2022/menu/radix-ng-primitives-menu.mjs +0 -5
  311. package/esm2022/menu/src/menu-content.directive.mjs +0 -17
  312. package/esm2022/menu/src/menu-directive.mjs +0 -18
  313. package/esm2022/menu/src/menu-group.directive.mjs +0 -20
  314. package/esm2022/menu/src/menu-item.directive.mjs +0 -46
  315. package/esm2022/menu/src/menu-label.directive.mjs +0 -14
  316. package/esm2022/menu/src/menu-separator.directive.mjs +0 -21
  317. package/esm2022/menubar/index.mjs +0 -60
  318. package/esm2022/menubar/radix-ng-primitives-menubar.mjs +0 -5
  319. package/esm2022/menubar/src/menubar-content.directive.mjs +0 -17
  320. package/esm2022/menubar/src/menubar-item-checkbox.directive.mjs +0 -34
  321. package/esm2022/menubar/src/menubar-item-indicator.directive.mjs +0 -17
  322. package/esm2022/menubar/src/menubar-item-radio.directive.mjs +0 -35
  323. package/esm2022/menubar/src/menubar-item.directive.mjs +0 -20
  324. package/esm2022/menubar/src/menubar-radio-group.directive.mjs +0 -17
  325. package/esm2022/menubar/src/menubar-root.directive.mjs +0 -24
  326. package/esm2022/menubar/src/menubar-separator.directive.mjs +0 -17
  327. package/esm2022/menubar/src/menubar-trigger.directive.mjs +0 -45
  328. package/esm2022/progress/index.mjs +0 -3
  329. package/esm2022/progress/radix-ng-primitives-progress.mjs +0 -5
  330. package/esm2022/progress/src/progress-indicator.directive.mjs +0 -34
  331. package/esm2022/progress/src/progress-root.directive.mjs +0 -127
  332. package/esm2022/radio/index.mjs +0 -4
  333. package/esm2022/radio/radix-ng-primitives-radio.mjs +0 -5
  334. package/esm2022/radio/src/radio-indicator.directive.mjs +0 -25
  335. package/esm2022/radio/src/radio-item.directive.mjs +0 -70
  336. package/esm2022/radio/src/radio-root.directive.mjs +0 -194
  337. package/esm2022/radio/src/radio-tokens.mjs +0 -3
  338. package/esm2022/radix-ng-primitives.mjs +0 -5
  339. package/esm2022/separator/index.mjs +0 -2
  340. package/esm2022/separator/radix-ng-primitives-separator.mjs +0 -5
  341. package/esm2022/separator/src/separator.directive.mjs +0 -31
  342. package/esm2022/switch/index.mjs +0 -30
  343. package/esm2022/switch/radix-ng-primitives-switch.mjs +0 -5
  344. package/esm2022/switch/src/switch-input.directive.mjs +0 -32
  345. package/esm2022/switch/src/switch-root.directive.mjs +0 -95
  346. package/esm2022/switch/src/switch-thumb.directive.mjs +0 -23
  347. package/esm2022/tabs/index.mjs +0 -38
  348. package/esm2022/tabs/radix-ng-primitives-tabs.mjs +0 -5
  349. package/esm2022/tabs/src/tabs-content.directive.mjs +0 -29
  350. package/esm2022/tabs/src/tabs-context.service.mjs +0 -43
  351. package/esm2022/tabs/src/tabs-list.directive.mjs +0 -23
  352. package/esm2022/tabs/src/tabs-root.directive.mjs +0 -54
  353. package/esm2022/tabs/src/tabs-trigger.directive.mjs +0 -52
  354. package/esm2022/toggle/index.mjs +0 -2
  355. package/esm2022/toggle/radix-ng-primitives-toggle.mjs +0 -5
  356. package/esm2022/toggle/src/toggle.directive.mjs +0 -39
  357. package/esm2022/toggle-group/index.mjs +0 -6
  358. package/esm2022/toggle-group/radix-ng-primitives-toggle-group.mjs +0 -5
  359. package/esm2022/toggle-group/src/toggle-group-button.directive.mjs +0 -75
  360. package/esm2022/toggle-group/src/toggle-group-button.token.mjs +0 -6
  361. package/esm2022/toggle-group/src/toggle-group-multi.directive.mjs +0 -143
  362. package/esm2022/toggle-group/src/toggle-group.directive.mjs +0 -134
  363. package/esm2022/toggle-group/src/toggle-group.token.mjs +0 -6
  364. package/fesm2022/radix-ng-primitives-accordion.mjs +0 -431
  365. package/fesm2022/radix-ng-primitives-accordion.mjs.map +0 -1
  366. package/fesm2022/radix-ng-primitives-alert-dialog.mjs +0 -161
  367. package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +0 -1
  368. package/fesm2022/radix-ng-primitives-avatar.mjs +0 -156
  369. package/fesm2022/radix-ng-primitives-avatar.mjs.map +0 -1
  370. package/fesm2022/radix-ng-primitives-checkbox.mjs +0 -241
  371. package/fesm2022/radix-ng-primitives-checkbox.mjs.map +0 -1
  372. package/fesm2022/radix-ng-primitives-collapsible.mjs +0 -213
  373. package/fesm2022/radix-ng-primitives-collapsible.mjs.map +0 -1
  374. package/fesm2022/radix-ng-primitives-dialog.mjs +0 -4
  375. package/fesm2022/radix-ng-primitives-dialog.mjs.map +0 -1
  376. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +0 -502
  377. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs.map +0 -1
  378. package/fesm2022/radix-ng-primitives-label.mjs +0 -66
  379. package/fesm2022/radix-ng-primitives-label.mjs.map +0 -1
  380. package/fesm2022/radix-ng-primitives-menu.mjs +0 -158
  381. package/fesm2022/radix-ng-primitives-menu.mjs.map +0 -1
  382. package/fesm2022/radix-ng-primitives-menubar.mjs +0 -245
  383. package/fesm2022/radix-ng-primitives-menubar.mjs.map +0 -1
  384. package/fesm2022/radix-ng-primitives-progress.mjs +0 -165
  385. package/fesm2022/radix-ng-primitives-progress.mjs.map +0 -1
  386. package/fesm2022/radix-ng-primitives-radio.mjs +0 -289
  387. package/fesm2022/radix-ng-primitives-radio.mjs.map +0 -1
  388. package/fesm2022/radix-ng-primitives-separator.mjs +0 -38
  389. package/fesm2022/radix-ng-primitives-separator.mjs.map +0 -1
  390. package/fesm2022/radix-ng-primitives-switch.mjs +0 -173
  391. package/fesm2022/radix-ng-primitives-switch.mjs.map +0 -1
  392. package/fesm2022/radix-ng-primitives-tabs.mjs +0 -222
  393. package/fesm2022/radix-ng-primitives-tabs.mjs.map +0 -1
  394. package/fesm2022/radix-ng-primitives-toggle-group.mjs +0 -358
  395. package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +0 -1
  396. package/fesm2022/radix-ng-primitives-toggle.mjs +0 -46
  397. package/fesm2022/radix-ng-primitives-toggle.mjs.map +0 -1
  398. package/fesm2022/radix-ng-primitives.mjs +0 -4
  399. package/fesm2022/radix-ng-primitives.mjs.map +0 -1
  400. package/index.d.ts +0 -1
  401. package/label/src/label.directive.d.ts +0 -29
  402. package/menu/index.d.ts +0 -18
  403. package/menu/src/menu-content.directive.d.ts +0 -6
  404. package/menu/src/menu-directive.d.ts +0 -6
  405. package/menu/src/menu-group.directive.d.ts +0 -6
  406. package/menu/src/menu-item.directive.d.ts +0 -12
  407. package/menu/src/menu-label.directive.d.ts +0 -5
  408. package/menu/src/menu-separator.directive.d.ts +0 -6
  409. package/menubar/index.d.ts +0 -24
  410. package/menubar/src/menubar-content.directive.d.ts +0 -6
  411. package/menubar/src/menubar-item-checkbox.directive.d.ts +0 -14
  412. package/menubar/src/menubar-item-indicator.directive.d.ts +0 -5
  413. package/menubar/src/menubar-item-radio.directive.d.ts +0 -14
  414. package/menubar/src/menubar-item.directive.d.ts +0 -8
  415. package/menubar/src/menubar-radio-group.directive.d.ts +0 -6
  416. package/menubar/src/menubar-root.directive.d.ts +0 -7
  417. package/menubar/src/menubar-separator.directive.d.ts +0 -6
  418. package/menubar/src/menubar-trigger.directive.d.ts +0 -11
  419. package/progress/src/progress-indicator.directive.d.ts +0 -16
  420. package/progress/src/progress-root.directive.d.ts +0 -63
  421. package/radio/src/radio-indicator.directive.d.ts +0 -9
  422. package/radio/src/radio-item.directive.d.ts +0 -21
  423. package/radio/src/radio-root.directive.d.ts +0 -72
  424. package/separator/src/separator.directive.d.ts +0 -22
  425. package/switch/index.d.ts +0 -13
  426. package/switch/src/switch-input.directive.d.ts +0 -6
  427. package/switch/src/switch-root.directive.d.ts +0 -51
  428. package/switch/src/switch-thumb.directive.d.ts +0 -6
  429. package/tabs/index.d.ts +0 -15
  430. package/tabs/src/tabs-content.directive.d.ts +0 -8
  431. package/tabs/src/tabs-context.service.d.ts +0 -22
  432. package/tabs/src/tabs-list.directive.d.ts +0 -6
  433. package/tabs/src/tabs-root.directive.d.ts +0 -37
  434. package/tabs/src/tabs-trigger.directive.d.ts +0 -19
  435. package/toggle/src/toggle.directive.d.ts +0 -30
  436. package/toggle-group/src/toggle-group-button.directive.d.ts +0 -39
  437. package/toggle-group/src/toggle-group-button.token.d.ts +0 -4
  438. package/toggle-group/src/toggle-group-multi.directive.d.ts +0 -93
  439. package/toggle-group/src/toggle-group.directive.d.ts +0 -84
  440. package/toggle-group/src/toggle-group.token.d.ts +0 -5
  441. /package/accordion/{index.d.ts → index.ts} +0 -0
  442. /package/avatar/{index.d.ts → index.ts} +0 -0
  443. /package/checkbox/{index.d.ts → index.ts} +0 -0
  444. /package/collapsible/{index.d.ts → index.ts} +0 -0
  445. /package/dropdown-menu/{index.d.ts → index.ts} +0 -0
  446. /package/{dialog/index.d.ts → index.ts} +0 -0
  447. /package/label/{index.d.ts → index.ts} +0 -0
  448. /package/separator/{index.d.ts → index.ts} +0 -0
  449. /package/toggle/{index.d.ts → index.ts} +0 -0
  450. /package/toggle-group/{index.d.ts → index.ts} +0 -0
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "../../node_modules/@compodoc/compodoc/src/config/schema.json",
3
+ "tsconfig": "tsconfig.doc.json",
4
+ "output": "../../dist/primitives/compodoc",
5
+ "exportFormat": "json",
6
+ "hideGenerator": true,
7
+ "disableCoverage": true,
8
+ "disablePrivate": true,
9
+ "disableInternal": true,
10
+ "disableLifeCycleHooks": true,
11
+ "disableDependencies": true
12
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,189 @@
1
+ ## 0.12.1 (2024-09-19)
2
+
3
+
4
+ ### 🩹 Fixes
5
+
6
+ - publish script ([1ecaf0c](https://github.com/radix-ng/primitives/commit/1ecaf0c))
7
+
8
+ ## 0.12.0 (2024-09-19)
9
+
10
+
11
+ ### 🚀 Features
12
+
13
+ - **dialog:** added Dialog primitive ([#101](https://github.com/radix-ng/primitives/pull/101))
14
+
15
+ - **radio:** added prefix rdx ([e5ebbc6](https://github.com/radix-ng/primitives/commit/e5ebbc6))
16
+
17
+ - **ci:** added eslint support ([#103](https://github.com/radix-ng/primitives/pull/103))
18
+
19
+ - **context-menu:** added context menu ([#2865](https://github.com/radix-ng/primitives/pull/2865), [#104](https://github.com/radix-ng/primitives/pull/104))
20
+
21
+
22
+ ### 🩹 Fixes
23
+
24
+ - **avatar:** supported SSR ([c50ce18](https://github.com/radix-ng/primitives/commit/c50ce18))
25
+
26
+ - **dropdown-menu:** navigation ([#106](https://github.com/radix-ng/primitives/pull/106))
27
+
28
+ ## 0.11.1 (2024-09-10)
29
+
30
+
31
+ ### 🩹 Fixes
32
+
33
+ - shadcn/ui accordion example ([ee300bb](https://github.com/radix-ng/primitives/commit/ee300bb))
34
+
35
+ - animation in accordion-content.directive ([#94](https://github.com/radix-ng/primitives/pull/94))
36
+
37
+ ## 0.11.0 (2024-09-06)
38
+
39
+
40
+ ### 🚀 Features
41
+
42
+ - radix documentation - Astro and MDX ([#69](https://github.com/radix-ng/primitives/pull/69))
43
+
44
+ - accordion (#DS-2773) ([#92](https://github.com/radix-ng/primitives/pull/92))
45
+
46
+ - **collapsible:** rename onOpenChange and added content attributes ([24baf80](https://github.com/radix-ng/primitives/commit/24baf80))
47
+
48
+
49
+ ### 🩹 Fixes
50
+
51
+ - **radio-group:** added focusKeyManager ([#95](https://github.com/radix-ng/primitives/pull/95))
52
+
53
+ ## 0.10.0 (2024-08-21)
54
+
55
+
56
+ ### 🚀 Features
57
+
58
+ - **primitives:** added rdx suffix for separator directive ([be5f9a5](https://github.com/radix-ng/primitives/commit/be5f9a5))
59
+
60
+
61
+ ### 🩹 Fixes
62
+
63
+ - extend in trigger and menu + onEscapeKeyDown ([#86](https://github.com/radix-ng/primitives/pull/86))
64
+
65
+ ## 0.9.1 (2024-08-15)
66
+
67
+
68
+ ### 🩹 Fixes
69
+
70
+ - use extend for CdkMenuItem ([#85](https://github.com/radix-ng/primitives/pull/85))
71
+
72
+ ## 0.9.0 (2024-08-13)
73
+
74
+
75
+ ### 🚀 Features
76
+
77
+ - added stylelint support ([#64](https://github.com/radix-ng/primitives/pull/64))
78
+
79
+ - added prettier support for ts files ([#80](https://github.com/radix-ng/primitives/pull/80))
80
+
81
+ - added prettier support for mdx files ([#81](https://github.com/radix-ng/primitives/pull/81))
82
+
83
+ - **primitives:** dropdown menu, added parameters – side, align and offsets ([#65](https://github.com/radix-ng/primitives/pull/65))
84
+
85
+ - **primitives:** avatar - added prefix ([908bce1](https://github.com/radix-ng/primitives/commit/908bce1))
86
+
87
+ - **primitives:** updated prefix and documentation ([a2e5d34](https://github.com/radix-ng/primitives/commit/a2e5d34))
88
+
89
+ - **primitives:** dropdown menu ([#79](https://github.com/radix-ng/primitives/pull/79))
90
+
91
+ ## 0.8.2 (2024-07-20)
92
+
93
+
94
+ ### 🚀 Features
95
+
96
+ - **primitives:** upd Checkbox added input primitive and upd docs for imdeterminate ([e7d1279](https://github.com/radix-ng/primitives/commit/e7d1279))
97
+
98
+ - **shadcn:** updated checkbox indeterminate state ([497659d](https://github.com/radix-ng/primitives/commit/497659d))
99
+
100
+ ## 0.8.1 (2024-07-10)
101
+
102
+ This was a version bump only for primitives to align it with other projects, there were no code changes.
103
+
104
+ ## 0.7.2 (2024-07-06)
105
+
106
+
107
+ ### 🚀 Features
108
+
109
+ - added Menubar base primitive ([0db991f](https://github.com/radix-ng/primitives/commit/0db991f))
110
+
111
+ - added Menu base primitive ([c7e395e](https://github.com/radix-ng/primitives/commit/c7e395e))
112
+
113
+ - **menubar:** added MenuBar ([#44](https://github.com/radix-ng/primitives/pull/44))
114
+
115
+ ## 0.7.1 (2024-06-30)
116
+
117
+ This was a version bump only for primitives to align it with other projects, there were no code changes.
118
+
119
+ ## 0.7.0 (2024-06-29)
120
+
121
+
122
+ ### 🚀 Features
123
+
124
+ - **tabs:** added Tabs ([#38](https://github.com/radix-ng/primitives/pull/38))
125
+
126
+ ## 0.6.0 (2024-06-20)
127
+
128
+
129
+ ### 🚀 Features
130
+
131
+ - based for Textarea ([fcd14e1](https://github.com/radix-ng/primitives/commit/fcd14e1))
132
+
133
+ - added beta presence ([55b4a75](https://github.com/radix-ng/primitives/commit/55b4a75))
134
+
135
+ - **alert-dialog:** poc code ([f314588](https://github.com/radix-ng/primitives/commit/f314588))
136
+
137
+ ## 0.5.0 (2024-04-26)
138
+
139
+
140
+ ### 🚀 Features
141
+
142
+ - added Accordion primitive ([2e95121](https://github.com/radix-ng/primitives/commit/2e95121))
143
+
144
+ - **toggle-group:** added Toggle Group primitive ([88a38d3](https://github.com/radix-ng/primitives/commit/88a38d3))
145
+
146
+
147
+ ### 🩹 Fixes
148
+
149
+ - **label:** added setter for UniqueId ([774c82f](https://github.com/radix-ng/primitives/commit/774c82f))
150
+
151
+ ## 0.4.0 (2024-04-22)
152
+
153
+
154
+ ### 🚀 Features
155
+
156
+ - **toggle:** added Toggle primitive ([f9a98dc](https://github.com/radix-ng/primitives/commit/f9a98dc))
157
+
158
+ ## 0.3.0 (2024-04-20)
159
+
160
+
161
+ ### 🚀 Features
162
+
163
+ - added overlay and tooltip ([e993fb3](https://github.com/radix-ng/primitives/commit/e993fb3))
164
+
165
+ - **avatar:** added primitive ([f76e8e9](https://github.com/radix-ng/primitives/commit/f76e8e9))
166
+
167
+ ## 0.2.0 (2024-04-16)
168
+
169
+ ### 🚀 Features
170
+
171
+ - **radio:** added Radio Group ([f0b0eed](https://github.com/radix-ng/primitives/commit/f0b0eed))
172
+
173
+ ### 🩹 Fixes
174
+
175
+ - **checkbox:** updated story and styles ([7999532](https://github.com/radix-ng/primitives/commit/7999532))
176
+
177
+ - **styles:** radix variables ([532a6d1](https://github.com/radix-ng/primitives/commit/532a6d1))
178
+
179
+ ## 0.1.1 (2024-04-14)
180
+
181
+ ### 🩹 Fixes
182
+
183
+ - nx release publish target ([a27032f](https://github.com/radix-ng/primitives/commit/a27032f))
184
+
185
+ ## 0.1.0 (2024-04-14)
186
+
187
+ ### 🚀 Features
188
+
189
+ - **progress:** added progress meter ([17f3ffb](https://github.com/radix-ng/primitives/commit/17f3ffb))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 radix-ng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Primitives
2
2
 
3
- > Radix-NG is an unofficial Angular port of [Radix UI](https://www.radix-ui.com/), thus we share the same principal and vision when building primitives.
3
+ > Radix-NG is an unofficial Angular port of [Radix UI](https://www.radix-ui.com/),
4
+ > thus we share the same principal and vision when building primitives.
4
5
 
5
- Radix Primitives is a low-level UI component library with a focus on accessibility, customization and developer experience. You can use these components either as the base layer of your design system, or adopt them incrementally.
6
+ Radix Primitives is a low-level UI component library with a focus on accessibility, customization and developer experience.
7
+ You can use these components either as the base layer of your design system, or adopt them incrementally.
@@ -0,0 +1,8 @@
1
+ import { RdxAccordionContentDirective } from '../src/accordion-content.directive';
2
+
3
+ xdescribe('RdxAccordionContentDirective', () => {
4
+ it('should create an instance', () => {
5
+ const directive = new RdxAccordionContentDirective();
6
+ expect(directive).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,8 @@
1
+ import { RdxAccordionHeaderDirective } from '../src/accordion-header.directive';
2
+
3
+ xdescribe('RdxAccordionHeaderDirective', () => {
4
+ it('should create an instance', () => {
5
+ const directive = new RdxAccordionHeaderDirective();
6
+ expect(directive).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,8 @@
1
+ import { RdxAccordionItemDirective } from '../src/accordion-item.directive';
2
+
3
+ xdescribe('RdxAccordionItemDirective', () => {
4
+ it('should create an instance', () => {
5
+ const directive = new RdxAccordionItemDirective();
6
+ expect(directive).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,8 @@
1
+ import { RdxAccordionRootDirective } from '../src/accordion-root.directive';
2
+
3
+ xdescribe('RdxAccordionRootDirective', () => {
4
+ it('should create an instance', () => {
5
+ const directive = new RdxAccordionRootDirective();
6
+ expect(directive).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,8 @@
1
+ import { RdxAccordionTriggerDirective } from '../src/accordion-trigger.directive';
2
+
3
+ xdescribe('RdxAccordionTriggerDirective', () => {
4
+ it('should create an instance', () => {
5
+ const directive = new RdxAccordionTriggerDirective();
6
+ expect(directive).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "lib": {
3
+ "entryFile": "index.ts"
4
+ }
5
+ }
@@ -0,0 +1,46 @@
1
+ import { Directive, ElementRef, inject } from '@angular/core';
2
+ import { RdxAccordionItemDirective } from './accordion-item.directive';
3
+
4
+ @Directive({
5
+ selector: '[rdxAccordionContent]',
6
+ standalone: true,
7
+ exportAs: 'rdxAccordionContent',
8
+ host: {
9
+ '[attr.role]': '"region"',
10
+ '[style.display]': 'hidden ? "none" : ""',
11
+ '[attr.data-state]': 'item.dataState',
12
+ '[attr.data-disabled]': 'item.disabled',
13
+ '[attr.data-orientation]': 'item.orientation',
14
+ '(animationend)': 'onAnimationEnd()'
15
+ }
16
+ })
17
+ export class RdxAccordionContentDirective {
18
+ protected readonly item = inject(RdxAccordionItemDirective);
19
+ protected readonly nativeElement = inject(ElementRef).nativeElement;
20
+
21
+ protected hidden = false;
22
+
23
+ protected onAnimationEnd() {
24
+ this.hidden = !this.item.expanded;
25
+
26
+ const { height, width } = this.nativeElement.getBoundingClientRect();
27
+
28
+ this.nativeElement.style.setProperty('--radix-collapsible-content-height', `${height}px`);
29
+ this.nativeElement.style.setProperty('--radix-collapsible-content-width', `${width}px`);
30
+
31
+ this.nativeElement.style.setProperty(
32
+ '--radix-accordion-content-height',
33
+ 'var(--radix-collapsible-content-height)'
34
+ );
35
+ this.nativeElement.style.setProperty(
36
+ '--radix-accordion-content-width',
37
+ 'var(--radix-collapsible-content-width)'
38
+ );
39
+ }
40
+
41
+ onToggle() {
42
+ if (!this.item.expanded) {
43
+ this.hidden = false;
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,15 @@
1
+ import { Directive, inject } from '@angular/core';
2
+ import { RdxAccordionItemDirective } from './accordion-item.directive';
3
+
4
+ @Directive({
5
+ selector: '[rdxAccordionHeader]',
6
+ standalone: true,
7
+ host: {
8
+ '[attr.data-state]': 'item.dataState',
9
+ '[attr.data-disabled]': 'item.disabled',
10
+ '[attr.data-orientation]': 'item.orientation'
11
+ }
12
+ })
13
+ export class RdxAccordionHeaderDirective {
14
+ protected readonly item = inject(RdxAccordionItemDirective);
15
+ }
@@ -0,0 +1,216 @@
1
+ import { FocusableOption } from '@angular/cdk/a11y';
2
+ import { UniqueSelectionDispatcher } from '@angular/cdk/collections';
3
+ import {
4
+ booleanAttribute,
5
+ ChangeDetectorRef,
6
+ ContentChild,
7
+ Directive,
8
+ EventEmitter,
9
+ forwardRef,
10
+ inject,
11
+ Input,
12
+ OnDestroy,
13
+ Output
14
+ } from '@angular/core';
15
+ import { Subscription } from 'rxjs';
16
+ import { RdxAccordionContentDirective } from './accordion-content.directive';
17
+ import { RdxAccordionOrientation, RdxAccordionRootToken } from './accordion-root.directive';
18
+ import { RdxAccordionTriggerDirective } from './accordion-trigger.directive';
19
+
20
+ export type RdxAccordionItemState = 'open' | 'closed';
21
+
22
+ let nextId = 0;
23
+
24
+ @Directive({
25
+ selector: '[rdxAccordionItem]',
26
+ standalone: true,
27
+ exportAs: 'rdxAccordionItem',
28
+ host: {
29
+ '[attr.data-state]': 'dataState',
30
+ '[attr.data-disabled]': 'disabled',
31
+ '[attr.data-orientation]': 'orientation'
32
+ },
33
+ providers: [
34
+ { provide: RdxAccordionRootToken, useValue: undefined }]
35
+ })
36
+ export class RdxAccordionItemDirective implements FocusableOption, OnDestroy {
37
+ /**
38
+ * @ignore
39
+ */
40
+ protected readonly accordion = inject(RdxAccordionRootToken, { skipSelf: true });
41
+ /**
42
+ * @ignore
43
+ */
44
+ protected readonly changeDetectorRef = inject(ChangeDetectorRef);
45
+ /**
46
+ * @ignore
47
+ */
48
+ protected readonly expansionDispatcher = inject(UniqueSelectionDispatcher);
49
+
50
+ /**
51
+ * @ignore
52
+ */
53
+ @ContentChild(RdxAccordionTriggerDirective, { descendants: true }) trigger: RdxAccordionTriggerDirective;
54
+
55
+ /**
56
+ * @ignore
57
+ */
58
+ @ContentChild(forwardRef(() => RdxAccordionContentDirective), { descendants: true })
59
+ content: RdxAccordionContentDirective;
60
+
61
+ get dataState(): RdxAccordionItemState {
62
+ return this.expanded ? 'open' : 'closed';
63
+ }
64
+
65
+ /**
66
+ * The unique AccordionItem id.
67
+ * @ignore
68
+ */
69
+ readonly id: string = `rdx-accordion-item-${nextId++}`;
70
+
71
+ get orientation(): RdxAccordionOrientation {
72
+ return this.accordion.orientation;
73
+ }
74
+
75
+ /** Whether the AccordionItem is expanded. */
76
+ @Input({ transform: booleanAttribute })
77
+ set expanded(expanded: boolean) {
78
+ // Only emit events and update the internal value if the value changes.
79
+ if (this._expanded !== expanded) {
80
+ this._expanded = expanded;
81
+ this.expandedChange.emit(expanded);
82
+
83
+ if (expanded) {
84
+ this.opened.emit();
85
+ /**
86
+ * In the unique selection dispatcher, the id parameter is the id of the CdkAccordionItem,
87
+ * the name value is the id of the accordion.
88
+ */
89
+ const accordionId = this.accordion ? this.accordion.id : this.value;
90
+ this.expansionDispatcher.notify(this.value, accordionId);
91
+ } else {
92
+ this.closed.emit();
93
+ }
94
+
95
+ // Ensures that the animation will run when the value is set outside of an `@Input`.
96
+ // This includes cases like the open, close and toggle methods.
97
+ this.changeDetectorRef.markForCheck();
98
+ }
99
+ }
100
+
101
+ get expanded(): boolean {
102
+ return this._expanded;
103
+ }
104
+
105
+ private _expanded = false;
106
+
107
+ @Input()
108
+ set value(value: string) {
109
+ this._value = value;
110
+ }
111
+
112
+ get value(): string {
113
+ return this._value || this.id;
114
+ }
115
+
116
+ private _value?: string;
117
+
118
+ /** Whether the AccordionItem is disabled. */
119
+ @Input({ transform: booleanAttribute })
120
+ set disabled(value: boolean) {
121
+ this._disabled = value;
122
+ }
123
+
124
+ get disabled(): boolean {
125
+ return this.accordion.disabled ?? this._disabled;
126
+ }
127
+
128
+ private _disabled = false;
129
+
130
+ /** Event emitted every time the AccordionItem is closed. */
131
+ @Output() readonly closed: EventEmitter<void> = new EventEmitter<void>();
132
+ /** Event emitted every time the AccordionItem is opened. */
133
+ @Output() readonly opened: EventEmitter<void> = new EventEmitter<void>();
134
+
135
+ /**
136
+ * Event emitted when the AccordionItem is destroyed.
137
+ * @ignore
138
+ */
139
+ readonly destroyed: EventEmitter<void> = new EventEmitter<void>();
140
+
141
+ /**
142
+ * Emits whenever the expanded state of the accordion changes.
143
+ * Primarily used to facilitate two-way binding.
144
+ * @docs-private
145
+ */
146
+ @Output() readonly expandedChange: EventEmitter<boolean> = new EventEmitter<boolean>();
147
+
148
+ /** Unregister function for expansionDispatcher. */
149
+ private removeUniqueSelectionListener: () => void;
150
+
151
+ /** Subscription to openAll/closeAll events. */
152
+ private openCloseAllSubscription = Subscription.EMPTY;
153
+
154
+ constructor() {
155
+ this.removeUniqueSelectionListener = this.expansionDispatcher.listen((id: string, accordionId: string) => {
156
+ if (this.accordion.isMultiple) {
157
+ if (this.accordion.id === accordionId && id.includes(this.value)) {
158
+ this.expanded = true;
159
+ }
160
+ } else {
161
+ this.expanded = this.accordion.id === accordionId && id.includes(this.value);
162
+ }
163
+ });
164
+
165
+ // When an accordion item is hosted in an accordion, subscribe to open/close events.
166
+ if (this.accordion) {
167
+ this.openCloseAllSubscription = this.subscribeToOpenCloseAllActions();
168
+ }
169
+ }
170
+
171
+ /** Emits an event for the accordion item being destroyed. */
172
+ ngOnDestroy() {
173
+ this.opened.complete();
174
+ this.closed.complete();
175
+ this.destroyed.emit();
176
+ this.destroyed.complete();
177
+ this.removeUniqueSelectionListener();
178
+ this.openCloseAllSubscription.unsubscribe();
179
+ }
180
+
181
+ focus(): void {
182
+ this.trigger.focus();
183
+ }
184
+
185
+ /** Toggles the expanded state of the accordion item. */
186
+ toggle(): void {
187
+ if (!this.disabled) {
188
+ this.content.onToggle();
189
+
190
+ this.expanded = !this.expanded;
191
+ }
192
+ }
193
+
194
+ /** Sets the expanded state of the accordion item to false. */
195
+ close(): void {
196
+ if (!this.disabled) {
197
+ this.expanded = false;
198
+ }
199
+ }
200
+
201
+ /** Sets the expanded state of the accordion item to true. */
202
+ open(): void {
203
+ if (!this.disabled) {
204
+ this.expanded = true;
205
+ }
206
+ }
207
+
208
+ private subscribeToOpenCloseAllActions(): Subscription {
209
+ return this.accordion.openCloseAllActions.subscribe((expanded) => {
210
+ // Only change expanded state if item is enabled
211
+ if (!this.disabled) {
212
+ this.expanded = expanded;
213
+ }
214
+ });
215
+ }
216
+ }