@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.
- package/.compodocrc.json +12 -0
- package/CHANGELOG.md +189 -0
- package/LICENSE +21 -0
- package/README.md +4 -2
- package/accordion/__tests__/accordion-content.directive.spec.ts +8 -0
- package/accordion/__tests__/accordion-header.directive.spec.ts +8 -0
- package/accordion/__tests__/accordion-item.directive.spec.ts +8 -0
- package/accordion/__tests__/accordion-root.directive.spec.ts +8 -0
- package/accordion/__tests__/accordion-trigger.directive.spec.ts +8 -0
- package/accordion/ng-package.json +5 -0
- package/accordion/src/accordion-content.directive.ts +46 -0
- package/accordion/src/accordion-header.directive.ts +15 -0
- package/accordion/src/accordion-item.directive.ts +216 -0
- package/accordion/src/accordion-root.directive.ts +205 -0
- package/accordion/src/accordion-trigger.directive.ts +37 -0
- package/accordion/stories/accordion.docs.mdx +77 -0
- package/accordion/stories/accordion.stories.ts +340 -0
- package/alert-dialog/{index.d.ts → index.ts} +1 -0
- package/alert-dialog/ng-package.json +5 -0
- package/alert-dialog/src/alert-dialog-cancel.directive.ts +17 -0
- package/alert-dialog/src/alert-dialog-content.directive.ts +24 -0
- package/alert-dialog/src/alert-dialog-root.directive.ts +15 -0
- package/alert-dialog/src/alert-dialog-title.directive.ts +7 -0
- package/alert-dialog/src/alert-dialog-trigger.directive.ts +17 -0
- package/alert-dialog/src/alert-dialog.service.ts +51 -0
- package/alert-dialog/stories/alert-dialog.stories.ts +139 -0
- package/avatar/__tests__/avatar-fallback.directive.spec.ts +31 -0
- package/avatar/__tests__/avatar-image.directive.spec.ts +36 -0
- package/avatar/ng-package.json +5 -0
- package/avatar/src/avatar-fallback.directive.ts +62 -0
- package/avatar/src/avatar-image.directive.ts +55 -0
- package/avatar/src/avatar-root.directive.ts +35 -0
- package/avatar/src/avatar.config.ts +29 -0
- package/avatar/stories/avatar.docs.mdx +37 -0
- package/avatar/stories/avatar.stories.ts +87 -0
- package/button/__tests__/.gitkeep +0 -0
- package/button/src/button-abstract.directive.ts +46 -0
- package/checkbox/ng-package.json +5 -0
- package/checkbox/src/checkbox-button.directive.ts +26 -0
- package/checkbox/src/checkbox-indicator.directive.ts +16 -0
- package/checkbox/src/checkbox-input.directive.ts +36 -0
- package/checkbox/src/checkbox.directive.ts +146 -0
- package/checkbox/src/checkbox.token.ts +8 -0
- package/checkbox/stories/checkbox-group.component.ts +87 -0
- package/checkbox/stories/checkbox-group.styles.scss +49 -0
- package/checkbox/stories/checkbox-indeterminate.component.ts +52 -0
- package/checkbox/stories/checkbox.docs.mdx +58 -0
- package/checkbox/stories/checkbox.stories.ts +105 -0
- package/collapsible/__tests__/collapsible-content.directive.spec.ts +30 -0
- package/collapsible/__tests__/collapsible-root.directive.spec.ts +27 -0
- package/collapsible/__tests__/collapsible-trigger.directive.spec.ts +30 -0
- package/collapsible/ng-package.json +5 -0
- package/collapsible/src/collapsible-content.directive.ts +34 -0
- package/collapsible/src/collapsible-content.token.ts +6 -0
- package/collapsible/src/collapsible-root.directive.ts +120 -0
- package/collapsible/src/collapsible-trigger.directive.ts +44 -0
- package/collapsible/stories/collapsible-animation.component.ts +116 -0
- package/collapsible/stories/collapsible-external-triggering.component.ts +86 -0
- package/collapsible/stories/collapsible.docs.mdx +53 -0
- package/collapsible/stories/collapsible.stories.ts +151 -0
- package/context-menu/README.md +1 -0
- package/context-menu/index.ts +10 -0
- package/context-menu/ng-package.json +5 -0
- package/context-menu/src/context-menu-content.directive.ts +47 -0
- package/context-menu/src/context-menu-item-checkbox.directive.ts +30 -0
- package/context-menu/src/context-menu-item-indicator.directive.ts +14 -0
- package/context-menu/src/context-menu-item-radio-group.directive.ts +31 -0
- package/context-menu/src/context-menu-item-radio.directive.ts +69 -0
- package/context-menu/src/context-menu-item-selectable.ts +18 -0
- package/context-menu/src/context-menu-item.directive.ts +65 -0
- package/context-menu/src/context-menu-label.directive.ts +7 -0
- package/context-menu/src/context-menu-separator.directive.ts +13 -0
- package/context-menu/src/context-menu-trigger.directive.ts +82 -0
- package/context-menu/stories/context-menu.docs.mdx +23 -0
- package/context-menu/stories/context-menu.stories.ts +253 -0
- package/core/index.ts +3 -0
- package/core/src/accessor/provide-value-accessor.ts +20 -0
- package/core/src/auto-focus.directive.ts +81 -0
- package/core/src/inject-ng-control.ts +28 -0
- package/core/src/mount.ts +27 -0
- package/dialog/__tests__/dialog-content.directive.spec.ts +77 -0
- package/dialog/__tests__/dialog-trigger.directive.spec.ts +85 -0
- package/dialog/index.ts +31 -0
- package/dialog/ng-package.json +5 -0
- package/dialog/src/dialog-close.directive.ts +18 -0
- package/dialog/src/dialog-content.directive.ts +45 -0
- package/dialog/src/dialog-description.directive.ts +7 -0
- package/dialog/src/dialog-dismiss.directive.ts +18 -0
- package/dialog/src/dialog-ref.ts +70 -0
- package/dialog/src/dialog-title.directive.ts +7 -0
- package/dialog/src/dialog-trigger.directive.ts +52 -0
- package/dialog/src/dialog.config.ts +55 -0
- package/dialog/src/dialog.injectors.ts +12 -0
- package/dialog/src/dialog.providers.ts +27 -0
- package/dialog/src/dialog.service.ts +94 -0
- package/dialog/stories/dialog.docs.mdx +32 -0
- package/dialog/stories/dialog.stories.ts +233 -0
- package/dropdown-menu/ng-package.json +5 -0
- package/dropdown-menu/src/dropdown-menu-content.directive.ts +47 -0
- package/dropdown-menu/src/dropdown-menu-item-checkbox.directive.ts +30 -0
- package/dropdown-menu/src/dropdown-menu-item-indicator.directive.ts +14 -0
- package/dropdown-menu/src/dropdown-menu-item-radio-group.directive.ts +31 -0
- package/dropdown-menu/src/dropdown-menu-item-radio.directive.ts +72 -0
- package/dropdown-menu/src/dropdown-menu-item-selectable.ts +18 -0
- package/dropdown-menu/src/dropdown-menu-item.directive.ts +66 -0
- package/dropdown-menu/src/dropdown-menu-label.directive.ts +7 -0
- package/dropdown-menu/src/dropdown-menu-separator.directive.ts +13 -0
- package/dropdown-menu/src/dropdown-menu-trigger.directive.ts +185 -0
- package/dropdown-menu/stories/dropdown-menu-item-checkbox.component.ts +104 -0
- package/dropdown-menu/stories/dropdown-menu-item-checkbox.styles.scss +106 -0
- package/dropdown-menu/stories/dropdown-menu-item-radio.component.ts +95 -0
- package/dropdown-menu/stories/dropdown-menu-item-radio.styles.scss +106 -0
- package/dropdown-menu/stories/dropdown.docs.mdx +27 -0
- package/dropdown-menu/stories/dropdown.stories.ts +212 -0
- package/form-field/index.ts +1 -0
- package/form-field/src/.gitkeep +0 -0
- package/jest.config.ts +21 -0
- package/label/__tests__/label-root.directive.spec.ts +99 -0
- package/label/ng-package.json +5 -0
- package/label/src/label.directive.ts +58 -0
- package/label/stories/label.docs.mdx +40 -0
- package/label/stories/label.stories.ts +76 -0
- package/menu/index.ts +29 -0
- package/menu/ng-package.json +5 -0
- package/menu/src/menu-content.directive.ts +9 -0
- package/menu/src/menu-directive.ts +10 -0
- package/menu/src/menu-group.directive.ts +12 -0
- package/menu/src/menu-item.directive.ts +44 -0
- package/menu/src/menu-label.directive.ts +7 -0
- package/menu/src/menu-separator.directive.ts +13 -0
- package/menubar/index.ts +38 -0
- package/menubar/ng-package.json +5 -0
- package/menubar/src/menubar-content.directive.ts +9 -0
- package/menubar/src/menubar-item-checkbox.directive.ts +32 -0
- package/menubar/src/menubar-item-indicator.directive.ts +10 -0
- package/menubar/src/menubar-item-radio.directive.ts +33 -0
- package/menubar/src/menubar-item.directive.ts +12 -0
- package/menubar/src/menubar-radio-group.directive.ts +9 -0
- package/menubar/src/menubar-root.directive.ts +15 -0
- package/menubar/src/menubar-separator.directive.ts +9 -0
- package/menubar/src/menubar-trigger.directive.ts +40 -0
- package/menubar/stories/menubar.stories.ts +229 -0
- package/ng-package.json +8 -0
- package/package.json +4 -118
- package/portal/stories/portal.docs.mdx +85 -0
- package/presence/__test__/presence-test.component.ts +51 -0
- package/presence/__test__/presence.spec.ts +50 -0
- package/presence/index.ts +4 -0
- package/presence/src/presence.ts +119 -0
- package/presence/src/transitions/transition.collapse.ts +99 -0
- package/presence/src/transitions/transition.toast.ts +27 -0
- package/presence/src/types.ts +20 -0
- package/presence/src/utils.ts +63 -0
- package/presence/stories/presence-story.componen.ts +69 -0
- package/presence/stories/presence.docs.mdx +40 -0
- package/presence/stories/presence.stories.ts +29 -0
- package/progress/__test__/progress.spec.ts +55 -0
- package/progress/{index.d.ts → index.ts} +1 -0
- package/progress/ng-package.json +5 -0
- package/progress/src/progress-indicator.directive.ts +26 -0
- package/progress/src/progress-root.directive.ts +134 -0
- package/progress/stories/progress.docs.mdx +65 -0
- package/progress/stories/progress.stories.ts +66 -0
- package/project.json +39 -0
- package/radio/{index.d.ts → index.ts} +1 -0
- package/radio/ng-package.json +5 -0
- package/radio/src/radio-indicator.directive.ts +17 -0
- package/radio/src/radio-item.directive.ts +68 -0
- package/radio/src/radio-root.directive.ts +207 -0
- package/radio/src/{radio-tokens.d.ts → radio-tokens.ts} +5 -1
- package/radio/stories/radio-group.component.ts +39 -0
- package/radio/stories/radio-group.styles.scss +70 -0
- package/radio/stories/radio.docs.mdx +68 -0
- package/radio/stories/radio.stories.ts +155 -0
- package/separator/__tests__/separator.directive.spec.ts +58 -0
- package/separator/ng-package.json +5 -0
- package/separator/src/separator.directive.ts +35 -0
- package/separator/stories/separator.docs.mdx +37 -0
- package/separator/stories/separator.stories.ts +82 -0
- package/slider/src/slider-input.directive.ts +0 -0
- package/slider/src/slider-thumb.directives.ts +60 -0
- package/slider/src/slider-track.directive.ts +11 -0
- package/slider/src/slider.directive.ts +59 -0
- package/slider/src/slider.types.ts +4 -0
- package/switch/index.ts +22 -0
- package/switch/ng-package.json +5 -0
- package/switch/src/switch-input.directive.ts +24 -0
- package/switch/src/switch-root.directive.ts +127 -0
- package/switch/src/switch-thumb.directive.ts +15 -0
- package/switch/stories/switch.docs.mdx +83 -0
- package/switch/stories/switch.stories.ts +149 -0
- package/tabs/__tests__/tabs-context.service.spec.ts +35 -0
- package/tabs/index.ts +26 -0
- package/tabs/ng-package.json +5 -0
- package/tabs/src/tabs-content.directive.ts +23 -0
- package/tabs/src/tabs-context.service.ts +43 -0
- package/tabs/src/tabs-list.directive.ts +21 -0
- package/tabs/src/tabs-root.directive.ts +70 -0
- package/tabs/src/tabs-trigger.directive.ts +55 -0
- package/tabs/stories/tabs.stories.ts +213 -0
- package/test-setup.ts +1 -0
- package/toggle/__tests__/toggle.directive.spec.ts +87 -0
- package/toggle/ng-package.json +5 -0
- package/toggle/src/toggle.directive.ts +49 -0
- package/toggle/stories/toggle.docs.mdx +60 -0
- package/toggle/stories/toggle.stories.ts +84 -0
- package/toggle-group/ng-package.json +5 -0
- package/toggle-group/src/toggle-group-button.directive.ts +73 -0
- package/toggle-group/src/toggle-group-button.token.ts +8 -0
- package/toggle-group/src/toggle-group-multi.directive.ts +158 -0
- package/toggle-group/src/toggle-group.directive.ts +148 -0
- package/toggle-group/src/toggle-group.token.ts +11 -0
- package/toggle-group/stories/toggle-group.docs.mdx +87 -0
- package/toggle-group/stories/toggle-group.stories.ts +95 -0
- package/tsconfig.doc.json +11 -0
- package/tsconfig.json +29 -0
- package/tsconfig.lib.json +19 -0
- package/tsconfig.lib.prod.json +12 -0
- package/tsconfig.spec.json +11 -0
- package/visually-hidden/README.md +3 -0
- package/visually-hidden/stories/visually-hidden.docs.mdx +36 -0
- package/accordion/src/accordion-content.directive.d.ts +0 -11
- package/accordion/src/accordion-header.directive.d.ts +0 -7
- package/accordion/src/accordion-item.directive.d.ts +0 -64
- package/accordion/src/accordion-root.directive.d.ts +0 -78
- package/accordion/src/accordion-trigger.directive.d.ts +0 -15
- package/alert-dialog/src/alert-dialog-cancel.directive.d.ts +0 -7
- package/alert-dialog/src/alert-dialog-content.directive.d.ts +0 -9
- package/alert-dialog/src/alert-dialog-root.directive.d.ts +0 -9
- package/alert-dialog/src/alert-dialog-title.directive.d.ts +0 -5
- package/alert-dialog/src/alert-dialog-trigger.directive.d.ts +0 -7
- package/alert-dialog/src/alert-dialog.service.d.ts +0 -14
- package/avatar/src/avatar-fallback.directive.d.ts +0 -27
- package/avatar/src/avatar-image.directive.d.ts +0 -16
- package/avatar/src/avatar-root.directive.d.ts +0 -21
- package/avatar/src/avatar.config.d.ts +0 -13
- package/checkbox/src/checkbox-button.directive.d.ts +0 -8
- package/checkbox/src/checkbox-indicator.directive.d.ts +0 -6
- package/checkbox/src/checkbox-input.directive.d.ts +0 -9
- package/checkbox/src/checkbox.directive.d.ts +0 -75
- package/checkbox/src/checkbox.token.d.ts +0 -4
- package/collapsible/src/collapsible-content.directive.d.ts +0 -17
- package/collapsible/src/collapsible-content.token.d.ts +0 -3
- package/collapsible/src/collapsible-root.directive.d.ts +0 -55
- package/collapsible/src/collapsible-trigger.directive.d.ts +0 -26
- package/compodoc/documentation.json +0 -11759
- package/dropdown-menu/src/dropdown-menu-content.directive.d.ts +0 -15
- package/dropdown-menu/src/dropdown-menu-item-checkbox.directive.d.ts +0 -9
- package/dropdown-menu/src/dropdown-menu-item-indicator.directive.d.ts +0 -7
- package/dropdown-menu/src/dropdown-menu-item-radio-group.directive.d.ts +0 -12
- package/dropdown-menu/src/dropdown-menu-item-radio.directive.d.ts +0 -19
- package/dropdown-menu/src/dropdown-menu-item-selectable.d.ts +0 -12
- package/dropdown-menu/src/dropdown-menu-item.directive.d.ts +0 -17
- package/dropdown-menu/src/dropdown-menu-label.directive.d.ts +0 -5
- package/dropdown-menu/src/dropdown-menu-separator.directive.d.ts +0 -6
- package/dropdown-menu/src/dropdown-menu-trigger.directive.d.ts +0 -43
- package/esm2022/accordion/index.mjs +0 -6
- package/esm2022/accordion/radix-ng-primitives-accordion.mjs +0 -5
- package/esm2022/accordion/src/accordion-content.directive.mjs +0 -42
- package/esm2022/accordion/src/accordion-header.directive.mjs +0 -23
- package/esm2022/accordion/src/accordion-item.directive.mjs +0 -175
- package/esm2022/accordion/src/accordion-root.directive.mjs +0 -160
- package/esm2022/accordion/src/accordion-trigger.directive.mjs +0 -42
- package/esm2022/alert-dialog/index.mjs +0 -7
- package/esm2022/alert-dialog/radix-ng-primitives-alert-dialog.mjs +0 -5
- package/esm2022/alert-dialog/src/alert-dialog-cancel.directive.mjs +0 -24
- package/esm2022/alert-dialog/src/alert-dialog-content.directive.mjs +0 -34
- package/esm2022/alert-dialog/src/alert-dialog-root.directive.mjs +0 -25
- package/esm2022/alert-dialog/src/alert-dialog-title.directive.mjs +0 -14
- package/esm2022/alert-dialog/src/alert-dialog-trigger.directive.mjs +0 -24
- package/esm2022/alert-dialog/src/alert-dialog.service.mjs +0 -47
- package/esm2022/avatar/index.mjs +0 -5
- package/esm2022/avatar/radix-ng-primitives-avatar.mjs +0 -5
- package/esm2022/avatar/src/avatar-fallback.directive.mjs +0 -54
- package/esm2022/avatar/src/avatar-image.directive.mjs +0 -48
- package/esm2022/avatar/src/avatar-root.directive.mjs +0 -38
- package/esm2022/avatar/src/avatar.config.mjs +0 -17
- package/esm2022/checkbox/index.mjs +0 -6
- package/esm2022/checkbox/radix-ng-primitives-checkbox.mjs +0 -5
- package/esm2022/checkbox/src/checkbox-button.directive.mjs +0 -33
- package/esm2022/checkbox/src/checkbox-indicator.directive.mjs +0 -24
- package/esm2022/checkbox/src/checkbox-input.directive.mjs +0 -41
- package/esm2022/checkbox/src/checkbox.directive.mjs +0 -141
- package/esm2022/checkbox/src/checkbox.token.mjs +0 -6
- package/esm2022/collapsible/index.mjs +0 -4
- package/esm2022/collapsible/radix-ng-primitives-collapsible.mjs +0 -5
- package/esm2022/collapsible/src/collapsible-content.directive.mjs +0 -45
- package/esm2022/collapsible/src/collapsible-content.token.mjs +0 -3
- package/esm2022/collapsible/src/collapsible-root.directive.mjs +0 -118
- package/esm2022/collapsible/src/collapsible-trigger.directive.mjs +0 -49
- package/esm2022/dialog/index.mjs +0 -2
- package/esm2022/dialog/radix-ng-primitives-dialog.mjs +0 -5
- package/esm2022/dropdown-menu/index.mjs +0 -11
- package/esm2022/dropdown-menu/radix-ng-primitives-dropdown-menu.mjs +0 -5
- package/esm2022/dropdown-menu/src/dropdown-menu-content.directive.mjs +0 -56
- package/esm2022/dropdown-menu/src/dropdown-menu-item-checkbox.directive.mjs +0 -36
- package/esm2022/dropdown-menu/src/dropdown-menu-item-indicator.directive.mjs +0 -22
- package/esm2022/dropdown-menu/src/dropdown-menu-item-radio-group.directive.mjs +0 -37
- package/esm2022/dropdown-menu/src/dropdown-menu-item-radio.directive.mjs +0 -64
- package/esm2022/dropdown-menu/src/dropdown-menu-item-selectable.mjs +0 -31
- package/esm2022/dropdown-menu/src/dropdown-menu-item.directive.mjs +0 -71
- package/esm2022/dropdown-menu/src/dropdown-menu-label.directive.mjs +0 -14
- package/esm2022/dropdown-menu/src/dropdown-menu-separator.directive.mjs +0 -21
- package/esm2022/dropdown-menu/src/dropdown-menu-trigger.directive.mjs +0 -176
- package/esm2022/index.mjs +0 -2
- package/esm2022/label/index.mjs +0 -2
- package/esm2022/label/radix-ng-primitives-label.mjs +0 -5
- package/esm2022/label/src/label.directive.mjs +0 -59
- package/esm2022/menu/index.mjs +0 -45
- package/esm2022/menu/radix-ng-primitives-menu.mjs +0 -5
- package/esm2022/menu/src/menu-content.directive.mjs +0 -17
- package/esm2022/menu/src/menu-directive.mjs +0 -18
- package/esm2022/menu/src/menu-group.directive.mjs +0 -20
- package/esm2022/menu/src/menu-item.directive.mjs +0 -46
- package/esm2022/menu/src/menu-label.directive.mjs +0 -14
- package/esm2022/menu/src/menu-separator.directive.mjs +0 -21
- package/esm2022/menubar/index.mjs +0 -60
- package/esm2022/menubar/radix-ng-primitives-menubar.mjs +0 -5
- package/esm2022/menubar/src/menubar-content.directive.mjs +0 -17
- package/esm2022/menubar/src/menubar-item-checkbox.directive.mjs +0 -34
- package/esm2022/menubar/src/menubar-item-indicator.directive.mjs +0 -17
- package/esm2022/menubar/src/menubar-item-radio.directive.mjs +0 -35
- package/esm2022/menubar/src/menubar-item.directive.mjs +0 -20
- package/esm2022/menubar/src/menubar-radio-group.directive.mjs +0 -17
- package/esm2022/menubar/src/menubar-root.directive.mjs +0 -24
- package/esm2022/menubar/src/menubar-separator.directive.mjs +0 -17
- package/esm2022/menubar/src/menubar-trigger.directive.mjs +0 -45
- package/esm2022/progress/index.mjs +0 -3
- package/esm2022/progress/radix-ng-primitives-progress.mjs +0 -5
- package/esm2022/progress/src/progress-indicator.directive.mjs +0 -34
- package/esm2022/progress/src/progress-root.directive.mjs +0 -127
- package/esm2022/radio/index.mjs +0 -4
- package/esm2022/radio/radix-ng-primitives-radio.mjs +0 -5
- package/esm2022/radio/src/radio-indicator.directive.mjs +0 -25
- package/esm2022/radio/src/radio-item.directive.mjs +0 -70
- package/esm2022/radio/src/radio-root.directive.mjs +0 -194
- package/esm2022/radio/src/radio-tokens.mjs +0 -3
- package/esm2022/radix-ng-primitives.mjs +0 -5
- package/esm2022/separator/index.mjs +0 -2
- package/esm2022/separator/radix-ng-primitives-separator.mjs +0 -5
- package/esm2022/separator/src/separator.directive.mjs +0 -31
- package/esm2022/switch/index.mjs +0 -30
- package/esm2022/switch/radix-ng-primitives-switch.mjs +0 -5
- package/esm2022/switch/src/switch-input.directive.mjs +0 -32
- package/esm2022/switch/src/switch-root.directive.mjs +0 -95
- package/esm2022/switch/src/switch-thumb.directive.mjs +0 -23
- package/esm2022/tabs/index.mjs +0 -38
- package/esm2022/tabs/radix-ng-primitives-tabs.mjs +0 -5
- package/esm2022/tabs/src/tabs-content.directive.mjs +0 -29
- package/esm2022/tabs/src/tabs-context.service.mjs +0 -43
- package/esm2022/tabs/src/tabs-list.directive.mjs +0 -23
- package/esm2022/tabs/src/tabs-root.directive.mjs +0 -54
- package/esm2022/tabs/src/tabs-trigger.directive.mjs +0 -52
- package/esm2022/toggle/index.mjs +0 -2
- package/esm2022/toggle/radix-ng-primitives-toggle.mjs +0 -5
- package/esm2022/toggle/src/toggle.directive.mjs +0 -39
- package/esm2022/toggle-group/index.mjs +0 -6
- package/esm2022/toggle-group/radix-ng-primitives-toggle-group.mjs +0 -5
- package/esm2022/toggle-group/src/toggle-group-button.directive.mjs +0 -75
- package/esm2022/toggle-group/src/toggle-group-button.token.mjs +0 -6
- package/esm2022/toggle-group/src/toggle-group-multi.directive.mjs +0 -143
- package/esm2022/toggle-group/src/toggle-group.directive.mjs +0 -134
- package/esm2022/toggle-group/src/toggle-group.token.mjs +0 -6
- package/fesm2022/radix-ng-primitives-accordion.mjs +0 -431
- package/fesm2022/radix-ng-primitives-accordion.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs +0 -161
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-avatar.mjs +0 -156
- package/fesm2022/radix-ng-primitives-avatar.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-checkbox.mjs +0 -241
- package/fesm2022/radix-ng-primitives-checkbox.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-collapsible.mjs +0 -213
- package/fesm2022/radix-ng-primitives-collapsible.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-dialog.mjs +0 -4
- package/fesm2022/radix-ng-primitives-dialog.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +0 -502
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-label.mjs +0 -66
- package/fesm2022/radix-ng-primitives-label.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-menu.mjs +0 -158
- package/fesm2022/radix-ng-primitives-menu.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-menubar.mjs +0 -245
- package/fesm2022/radix-ng-primitives-menubar.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-progress.mjs +0 -165
- package/fesm2022/radix-ng-primitives-progress.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-radio.mjs +0 -289
- package/fesm2022/radix-ng-primitives-radio.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-separator.mjs +0 -38
- package/fesm2022/radix-ng-primitives-separator.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +0 -173
- package/fesm2022/radix-ng-primitives-switch.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-tabs.mjs +0 -222
- package/fesm2022/radix-ng-primitives-tabs.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +0 -358
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +0 -46
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives.mjs +0 -4
- package/fesm2022/radix-ng-primitives.mjs.map +0 -1
- package/index.d.ts +0 -1
- package/label/src/label.directive.d.ts +0 -29
- package/menu/index.d.ts +0 -18
- package/menu/src/menu-content.directive.d.ts +0 -6
- package/menu/src/menu-directive.d.ts +0 -6
- package/menu/src/menu-group.directive.d.ts +0 -6
- package/menu/src/menu-item.directive.d.ts +0 -12
- package/menu/src/menu-label.directive.d.ts +0 -5
- package/menu/src/menu-separator.directive.d.ts +0 -6
- package/menubar/index.d.ts +0 -24
- package/menubar/src/menubar-content.directive.d.ts +0 -6
- package/menubar/src/menubar-item-checkbox.directive.d.ts +0 -14
- package/menubar/src/menubar-item-indicator.directive.d.ts +0 -5
- package/menubar/src/menubar-item-radio.directive.d.ts +0 -14
- package/menubar/src/menubar-item.directive.d.ts +0 -8
- package/menubar/src/menubar-radio-group.directive.d.ts +0 -6
- package/menubar/src/menubar-root.directive.d.ts +0 -7
- package/menubar/src/menubar-separator.directive.d.ts +0 -6
- package/menubar/src/menubar-trigger.directive.d.ts +0 -11
- package/progress/src/progress-indicator.directive.d.ts +0 -16
- package/progress/src/progress-root.directive.d.ts +0 -63
- package/radio/src/radio-indicator.directive.d.ts +0 -9
- package/radio/src/radio-item.directive.d.ts +0 -21
- package/radio/src/radio-root.directive.d.ts +0 -72
- package/separator/src/separator.directive.d.ts +0 -22
- package/switch/index.d.ts +0 -13
- package/switch/src/switch-input.directive.d.ts +0 -6
- package/switch/src/switch-root.directive.d.ts +0 -51
- package/switch/src/switch-thumb.directive.d.ts +0 -6
- package/tabs/index.d.ts +0 -15
- package/tabs/src/tabs-content.directive.d.ts +0 -8
- package/tabs/src/tabs-context.service.d.ts +0 -22
- package/tabs/src/tabs-list.directive.d.ts +0 -6
- package/tabs/src/tabs-root.directive.d.ts +0 -37
- package/tabs/src/tabs-trigger.directive.d.ts +0 -19
- package/toggle/src/toggle.directive.d.ts +0 -30
- package/toggle-group/src/toggle-group-button.directive.d.ts +0 -39
- package/toggle-group/src/toggle-group-button.token.d.ts +0 -4
- package/toggle-group/src/toggle-group-multi.directive.d.ts +0 -93
- package/toggle-group/src/toggle-group.directive.d.ts +0 -84
- package/toggle-group/src/toggle-group.token.d.ts +0 -5
- /package/accordion/{index.d.ts → index.ts} +0 -0
- /package/avatar/{index.d.ts → index.ts} +0 -0
- /package/checkbox/{index.d.ts → index.ts} +0 -0
- /package/collapsible/{index.d.ts → index.ts} +0 -0
- /package/dropdown-menu/{index.d.ts → index.ts} +0 -0
- /package/{dialog/index.d.ts → index.ts} +0 -0
- /package/label/{index.d.ts → index.ts} +0 -0
- /package/separator/{index.d.ts → index.ts} +0 -0
- /package/toggle/{index.d.ts → index.ts} +0 -0
- /package/toggle-group/{index.d.ts → index.ts} +0 -0
@@ -0,0 +1,207 @@
|
|
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,12 +1,16 @@
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
2
|
+
|
2
3
|
export interface RadioGroupProps {
|
3
4
|
name?: string;
|
4
5
|
disabled?: boolean;
|
5
6
|
defaultValue?: string;
|
6
7
|
value?: string;
|
7
8
|
}
|
9
|
+
|
8
10
|
export interface RadioGroupDirective extends RadioGroupProps {
|
9
11
|
select(value: string): void;
|
12
|
+
|
10
13
|
onTouched(): void;
|
11
14
|
}
|
12
|
-
|
15
|
+
|
16
|
+
export const RDX_RADIO_GROUP = new InjectionToken<RadioGroupDirective>('RdxRadioGroup');
|
@@ -0,0 +1,39 @@
|
|
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
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
/* reset */
|
2
|
+
button {
|
3
|
+
all: unset;
|
4
|
+
}
|
5
|
+
|
6
|
+
.RadioGroup {
|
7
|
+
display: flex;
|
8
|
+
align-items: center;
|
9
|
+
}
|
10
|
+
|
11
|
+
.RadioGroupRoot {
|
12
|
+
display: flex;
|
13
|
+
flex-direction: column;
|
14
|
+
gap: 10px;
|
15
|
+
}
|
16
|
+
|
17
|
+
.RadioGroupItem {
|
18
|
+
background-color: white;
|
19
|
+
width: 25px;
|
20
|
+
height: 25px;
|
21
|
+
border-radius: 100%;
|
22
|
+
box-shadow: 0 2px 10px var(--black-a7);
|
23
|
+
}
|
24
|
+
|
25
|
+
.RadioGroupItem:hover {
|
26
|
+
background-color: var(--violet-3);
|
27
|
+
}
|
28
|
+
|
29
|
+
.RadioGroupItem:focus {
|
30
|
+
box-shadow: 0 0 0 2px black;
|
31
|
+
}
|
32
|
+
|
33
|
+
.RadioGroupIndicator {
|
34
|
+
display: flex;
|
35
|
+
align-items: center;
|
36
|
+
justify-content: center;
|
37
|
+
width: 100%;
|
38
|
+
height: 100%;
|
39
|
+
position: relative;
|
40
|
+
}
|
41
|
+
|
42
|
+
.RadioGroupIndicator::after {
|
43
|
+
content: '';
|
44
|
+
display: block;
|
45
|
+
width: 11px;
|
46
|
+
height: 11px;
|
47
|
+
border-radius: 50%;
|
48
|
+
background-color: var(--violet-11);
|
49
|
+
}
|
50
|
+
|
51
|
+
.RadioGroupIndicator[data-state='unchecked'] {
|
52
|
+
display: none;
|
53
|
+
}
|
54
|
+
|
55
|
+
.Input {
|
56
|
+
transform: translateX(-100%);
|
57
|
+
position: absolute;
|
58
|
+
pointer-events: none;
|
59
|
+
opacity: 0;
|
60
|
+
margin: 0;
|
61
|
+
width: 25px;
|
62
|
+
height: 25px;
|
63
|
+
}
|
64
|
+
|
65
|
+
.Label {
|
66
|
+
color: white;
|
67
|
+
font-size: 15px;
|
68
|
+
line-height: 1;
|
69
|
+
padding-left: 15px;
|
70
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { ArgTypes, Canvas, Markdown, Meta } from '@storybook/blocks';
|
2
|
+
import * as RadioDirectiveStories from './radio.stories';
|
3
|
+
import { RdxRadioGroupDirective } from '../src/radio-root.directive';
|
4
|
+
import { RdxRadioItemDirective } from '../src/radio-item.directive';
|
5
|
+
|
6
|
+
<Meta title="Primitives/Radio Group" />
|
7
|
+
|
8
|
+
# Radio Group
|
9
|
+
|
10
|
+
#### A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.
|
11
|
+
|
12
|
+
<Canvas sourceState="hidden" of={RadioDirectiveStories.Default} />
|
13
|
+
|
14
|
+
## Features
|
15
|
+
|
16
|
+
- ✅ Full keyboard navigation.
|
17
|
+
- ✅ Supports horizontal/vertical orientation.
|
18
|
+
- ✅ Can be controlled or uncontrolled.
|
19
|
+
|
20
|
+
## Import
|
21
|
+
|
22
|
+
Get started with importing the directives:
|
23
|
+
|
24
|
+
```typescript
|
25
|
+
import { RdxRadioIndicatorDirective, RadioItemDirectiveб } from '@radix-ng/primitives/radio';
|
26
|
+
```
|
27
|
+
|
28
|
+
## Anatomy
|
29
|
+
|
30
|
+
```html
|
31
|
+
<div rdxRadioRoot>
|
32
|
+
<button rdxRadioItem value="default">
|
33
|
+
<div rdxRadioIndicator></div>
|
34
|
+
</button>
|
35
|
+
</div>
|
36
|
+
```
|
37
|
+
|
38
|
+
## API Reference
|
39
|
+
|
40
|
+
### CheckboxGroupDirective
|
41
|
+
|
42
|
+
<ArgTypes of={RdxRadioGroupDirective} />
|
43
|
+
|
44
|
+
### CheckboxGroupItemDirective
|
45
|
+
|
46
|
+
<ArgTypes of={RdxRadioItemDirective} />
|
47
|
+
|
48
|
+
### RdxRadioIndicatorDirective
|
49
|
+
|
50
|
+
## Accessibility
|
51
|
+
|
52
|
+
Adheres to the [Radio Group WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton)
|
53
|
+
and uses [roving tabindex](https://www.w3.org/TR/wai-aria-practices-1.2/examples/radio/radio.html) to manage focus movement among radio items.
|
54
|
+
|
55
|
+
### Keyboard Interactions
|
56
|
+
|
57
|
+
<Markdown>
|
58
|
+
{`
|
59
|
+
| Key | Description |
|
60
|
+
| ----------- | --------- |
|
61
|
+
| Tab | Moves focus to either the checked radio item or the first radio item in the group. |
|
62
|
+
| Space | When focus is on an unchecked radio item, checks it. |
|
63
|
+
| ArrowDown | Moves focus and checks the next radio item in the group. |
|
64
|
+
| ArrowRight | Moves focus and checks the next radio item in the group. |
|
65
|
+
| ArrowUp | Moves focus to the previous radio item in the group. |
|
66
|
+
| ArrowLeft | Moves focus to the previous radio item in the group. |
|
67
|
+
`}
|
68
|
+
</Markdown>
|
@@ -0,0 +1,155 @@
|
|
1
|
+
import { componentWrapperDecorator, Meta, moduleMetadata, StoryObj } from '@storybook/angular';
|
2
|
+
import { RdxLabelDirective } from '../../label';
|
3
|
+
import { RdxRadioIndicatorDirective } from '../src/radio-indicator.directive';
|
4
|
+
import { RdxRadioItemDirective } from '../src/radio-item.directive';
|
5
|
+
import { RdxRadioGroupDirective } from '../src/radio-root.directive';
|
6
|
+
import { RadioGroupComponent } from './radio-group.component';
|
7
|
+
|
8
|
+
const html = String.raw;
|
9
|
+
|
10
|
+
export default {
|
11
|
+
title: 'Primitives/Radio Group',
|
12
|
+
decorators: [
|
13
|
+
moduleMetadata({
|
14
|
+
imports: [
|
15
|
+
RdxLabelDirective,
|
16
|
+
RdxRadioItemDirective,
|
17
|
+
RdxRadioIndicatorDirective,
|
18
|
+
RdxRadioGroupDirective,
|
19
|
+
RadioGroupComponent
|
20
|
+
]
|
21
|
+
}),
|
22
|
+
componentWrapperDecorator(
|
23
|
+
(story) =>
|
24
|
+
`<div class="radix-themes light light-theme"
|
25
|
+
data-radius="medium"
|
26
|
+
data-scaling="100%">${story}</div>`
|
27
|
+
)
|
28
|
+
]
|
29
|
+
} as Meta;
|
30
|
+
|
31
|
+
type Story = StoryObj;
|
32
|
+
|
33
|
+
export const Default: Story = {
|
34
|
+
render: () => ({
|
35
|
+
template: html`
|
36
|
+
<form>
|
37
|
+
<div class="RadioGroupRoot" rdxRadioRoot aria-label="View density">
|
38
|
+
<div style="display: flex; align-items: center;">
|
39
|
+
<button class="RadioGroupItem" id="r1" rdxRadioItem value="default">
|
40
|
+
<div class="RadioGroupIndicator" rdxRadioIndicator></div>
|
41
|
+
<input
|
42
|
+
class="Input"
|
43
|
+
rdxRadioIndicator
|
44
|
+
type="radio"
|
45
|
+
aria-hidden="true"
|
46
|
+
tabindex="-1"
|
47
|
+
value="default"
|
48
|
+
/>
|
49
|
+
</button>
|
50
|
+
<label class="Label" rdxLabel htmlFor="r1">Default</label>
|
51
|
+
</div>
|
52
|
+
<div style="display: flex; align-items: center;">
|
53
|
+
<button class="RadioGroupItem" id="r2" rdxRadioItem value="comfortable">
|
54
|
+
<div class="RadioGroupIndicator" rdxRadioIndicator></div>
|
55
|
+
<input
|
56
|
+
class="Input"
|
57
|
+
rdxRadioIndicator
|
58
|
+
type="radio"
|
59
|
+
aria-hidden="true"
|
60
|
+
tabindex="-1"
|
61
|
+
value="comfortable"
|
62
|
+
/>
|
63
|
+
</button>
|
64
|
+
<label class="Label" rdxLabel htmlFor="r2">Comfortable</label>
|
65
|
+
</div>
|
66
|
+
<div style="display: flex; align-items: center;">
|
67
|
+
<button class="RadioGroupItem" id="r3" rdxRadioItem value="compact">
|
68
|
+
<div class="RadioGroupIndicator" rdxRadioIndicator></div>
|
69
|
+
<input
|
70
|
+
class="Input"
|
71
|
+
rdxRadioIndicator
|
72
|
+
type="radio"
|
73
|
+
aria-hidden="true"
|
74
|
+
tabindex="-1"
|
75
|
+
value="compact"
|
76
|
+
/>
|
77
|
+
</button>
|
78
|
+
<label class="Label" rdxLabel htmlFor="r3">Compact</label>
|
79
|
+
</div>
|
80
|
+
</div>
|
81
|
+
</form>
|
82
|
+
|
83
|
+
<style>
|
84
|
+
/* reset */
|
85
|
+
button {
|
86
|
+
all: unset;
|
87
|
+
}
|
88
|
+
|
89
|
+
.RadioGroupRoot {
|
90
|
+
display: flex;
|
91
|
+
flex-direction: column;
|
92
|
+
gap: 10px;
|
93
|
+
}
|
94
|
+
|
95
|
+
.RadioGroupItem {
|
96
|
+
background-color: white;
|
97
|
+
width: 25px;
|
98
|
+
height: 25px;
|
99
|
+
border-radius: 100%;
|
100
|
+
box-shadow: 0 2px 10px var(--black-a7);
|
101
|
+
}
|
102
|
+
.RadioGroupItem:hover {
|
103
|
+
background-color: var(--violet-3);
|
104
|
+
}
|
105
|
+
.RadioGroupItem:focus {
|
106
|
+
box-shadow: 0 0 0 2px black;
|
107
|
+
}
|
108
|
+
|
109
|
+
.RadioGroupIndicator {
|
110
|
+
display: flex;
|
111
|
+
align-items: center;
|
112
|
+
justify-content: center;
|
113
|
+
width: 100%;
|
114
|
+
height: 100%;
|
115
|
+
position: relative;
|
116
|
+
}
|
117
|
+
.RadioGroupIndicator::after {
|
118
|
+
content: '';
|
119
|
+
display: block;
|
120
|
+
width: 11px;
|
121
|
+
height: 11px;
|
122
|
+
border-radius: 50%;
|
123
|
+
background-color: var(--violet-11);
|
124
|
+
}
|
125
|
+
|
126
|
+
.RadioGroupIndicator[data-state='unchecked'] {
|
127
|
+
display: none;
|
128
|
+
}
|
129
|
+
|
130
|
+
.Input {
|
131
|
+
transform: translateX(-100%);
|
132
|
+
position: absolute;
|
133
|
+
pointer-events: none;
|
134
|
+
opacity: 0;
|
135
|
+
margin: 0;
|
136
|
+
width: 25px;
|
137
|
+
height: 25px;
|
138
|
+
}
|
139
|
+
|
140
|
+
.Label {
|
141
|
+
color: white;
|
142
|
+
font-size: 15px;
|
143
|
+
line-height: 1;
|
144
|
+
padding-left: 15px;
|
145
|
+
}
|
146
|
+
</style>
|
147
|
+
`
|
148
|
+
})
|
149
|
+
};
|
150
|
+
|
151
|
+
export const RadioGroup: Story = {
|
152
|
+
render: () => ({
|
153
|
+
template: `<radio-groups-forms-example></radio-groups-forms-example>`
|
154
|
+
})
|
155
|
+
};
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { Component, DebugElement } from '@angular/core';
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
3
|
+
import { By } from '@angular/platform-browser';
|
4
|
+
import { Orientation, RdxSeparatorRootDirective } from '../src/separator.directive';
|
5
|
+
|
6
|
+
@Component({
|
7
|
+
template: '<div rdxSeparatorRoot [orientation]="orientation" [decorative]="decorative"></div>'
|
8
|
+
})
|
9
|
+
class TestComponent {
|
10
|
+
orientation: Orientation = 'horizontal';
|
11
|
+
decorative = false;
|
12
|
+
}
|
13
|
+
|
14
|
+
describe('SeparatorDirective', () => {
|
15
|
+
let component: TestComponent;
|
16
|
+
let fixture: ComponentFixture<TestComponent>;
|
17
|
+
let div: DebugElement;
|
18
|
+
|
19
|
+
beforeEach(async () => {
|
20
|
+
await TestBed.configureTestingModule({
|
21
|
+
declarations: [TestComponent],
|
22
|
+
imports: [RdxSeparatorRootDirective]
|
23
|
+
}).compileComponents();
|
24
|
+
});
|
25
|
+
|
26
|
+
beforeEach(() => {
|
27
|
+
fixture = TestBed.createComponent(TestComponent);
|
28
|
+
component = fixture.componentInstance;
|
29
|
+
div = fixture.debugElement.query(By.css('div'));
|
30
|
+
fixture.detectChanges();
|
31
|
+
});
|
32
|
+
|
33
|
+
it('should create an instance', () => {
|
34
|
+
const directive = new RdxSeparatorRootDirective();
|
35
|
+
expect(directive).toBeTruthy();
|
36
|
+
});
|
37
|
+
|
38
|
+
it('should apply the correct role attribute based on decorative input', () => {
|
39
|
+
expect(div.nativeElement.getAttribute('role')).toBe('separator');
|
40
|
+
component.decorative = true;
|
41
|
+
fixture.detectChanges();
|
42
|
+
expect(div.nativeElement.getAttribute('role')).toBe('none');
|
43
|
+
});
|
44
|
+
|
45
|
+
it('should apply the correct aria-orientation attribute based on orientation input', () => {
|
46
|
+
expect(div.nativeElement.getAttribute('aria-orientation')).toBe(null);
|
47
|
+
component.orientation = 'vertical';
|
48
|
+
fixture.detectChanges();
|
49
|
+
expect(div.nativeElement.getAttribute('aria-orientation')).toBe('vertical');
|
50
|
+
});
|
51
|
+
|
52
|
+
it('should apply the correct data-orientation attribute based on orientation input', () => {
|
53
|
+
expect(div.nativeElement.getAttribute('data-orientation')).toBe('horizontal');
|
54
|
+
component.orientation = 'vertical';
|
55
|
+
fixture.detectChanges();
|
56
|
+
expect(div.nativeElement.getAttribute('data-orientation')).toBe('vertical');
|
57
|
+
});
|
58
|
+
});
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { booleanAttribute, Directive, Input } from '@angular/core';
|
2
|
+
|
3
|
+
const DEFAULT_ORIENTATION = 'horizontal';
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
5
|
+
const ORIENTATIONS = ['horizontal', 'vertical'] as const;
|
6
|
+
|
7
|
+
export type Orientation = (typeof ORIENTATIONS)[number];
|
8
|
+
|
9
|
+
export interface SeparatorProps {
|
10
|
+
/**
|
11
|
+
* Either `vertical` or `horizontal`. Defaults to `horizontal`.
|
12
|
+
*/
|
13
|
+
orientation?: Orientation;
|
14
|
+
/**
|
15
|
+
* Whether the component is purely decorative. When true, accessibility-related attributes
|
16
|
+
* are updated so that the rendered element is removed from the accessibility tree.
|
17
|
+
*/
|
18
|
+
decorative?: boolean;
|
19
|
+
}
|
20
|
+
|
21
|
+
@Directive({
|
22
|
+
selector: 'div[rdxSeparatorRoot]',
|
23
|
+
standalone: true,
|
24
|
+
host: {
|
25
|
+
'[attr.role]': 'decorative ? "none" : "separator"',
|
26
|
+
// `aria-orientation` defaults to `horizontal` so we only need it if `orientation` is vertical
|
27
|
+
'[attr.aria-orientation]': '!decorative && orientation === "vertical" ? "vertical" : null',
|
28
|
+
'[attr.data-orientation]': 'orientation'
|
29
|
+
}
|
30
|
+
})
|
31
|
+
export class RdxSeparatorRootDirective implements SeparatorProps {
|
32
|
+
@Input() orientation: Orientation = DEFAULT_ORIENTATION;
|
33
|
+
|
34
|
+
@Input({ transform: booleanAttribute }) decorative = false;
|
35
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { ArgTypes, Canvas, Meta } from '@storybook/blocks';
|
2
|
+
import { RdxSeparatorRootDirective } from '../src/separator.directive';
|
3
|
+
import * as SeparatorDirectiveStories from './separator.stories';
|
4
|
+
|
5
|
+
<Meta title="Primitives/Separator" />
|
6
|
+
|
7
|
+
# Separator
|
8
|
+
|
9
|
+
#### Visually or semantically separates content.
|
10
|
+
|
11
|
+
<Canvas sourceState="hidden" of={SeparatorDirectiveStories.Default} />
|
12
|
+
|
13
|
+
## Features
|
14
|
+
|
15
|
+
- ✅ Supports horizontal and vertical orientations.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Get started with importing the directive:
|
20
|
+
|
21
|
+
```typescript
|
22
|
+
import { RdxSeparatorRootDirective } from '@radix-ng/primitives/separator';
|
23
|
+
```
|
24
|
+
|
25
|
+
## Examples
|
26
|
+
|
27
|
+
```html
|
28
|
+
<div rdxSeparatorRoot decorative="decorative" orientation="vertical"></div>
|
29
|
+
```
|
30
|
+
|
31
|
+
## API Reference
|
32
|
+
|
33
|
+
<ArgTypes of={RdxSeparatorRootDirective} />
|
34
|
+
|
35
|
+
## Accessibility
|
36
|
+
|
37
|
+
Adheres to the [`separator` role requirements](https://www.w3.org/TR/wai-aria-1.2/#separator).
|