@radix-ng/primitives 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.compodocrc.json +12 -0
- package/CHANGELOG.md +182 -0
- package/LICENSE +21 -0
- 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/README.md +1 -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 -112
- 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 -16
- package/accordion/src/accordion-header.directive.d.ts +0 -7
- package/accordion/src/accordion-item.directive.d.ts +0 -62
- 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 -11395
- 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 -36
- package/esm2022/accordion/src/accordion-header.directive.mjs +0 -23
- package/esm2022/accordion/src/accordion-item.directive.mjs +0 -170
- package/esm2022/accordion/src/accordion-root.directive.mjs +0 -157
- 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/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 -418
- 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-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/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/{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,213 @@
|
|
1
|
+
import { componentWrapperDecorator, Meta, moduleMetadata, StoryObj } from '@storybook/angular';
|
2
|
+
import { RdxTabsContentDirective } from '../src/tabs-content.directive';
|
3
|
+
import { RdxTabsListDirective } from '../src/tabs-list.directive';
|
4
|
+
import { RdxTabsRootDirective } from '../src/tabs-root.directive';
|
5
|
+
import { RdxTabsTriggerDirective } from '../src/tabs-trigger.directive';
|
6
|
+
|
7
|
+
export default {
|
8
|
+
title: 'Primitives/Tabs',
|
9
|
+
decorators: [
|
10
|
+
moduleMetadata({
|
11
|
+
imports: [
|
12
|
+
RdxTabsRootDirective,
|
13
|
+
RdxTabsListDirective,
|
14
|
+
RdxTabsTriggerDirective,
|
15
|
+
RdxTabsContentDirective
|
16
|
+
]
|
17
|
+
}),
|
18
|
+
componentWrapperDecorator(
|
19
|
+
(story) =>
|
20
|
+
`
|
21
|
+
<div class="radix-themes light light-theme"
|
22
|
+
data-radius="medium"
|
23
|
+
data-scaling="100%">${story}</div>`
|
24
|
+
)
|
25
|
+
]
|
26
|
+
} as Meta;
|
27
|
+
|
28
|
+
type Story = StoryObj;
|
29
|
+
|
30
|
+
export const Default: Story = {
|
31
|
+
render: (args) => ({
|
32
|
+
props: args,
|
33
|
+
template: `
|
34
|
+
<div rdxTabsRoot defaultValue="tab1" class="TabsRoot">
|
35
|
+
<div rdxTabsList class="TabsList">
|
36
|
+
<button rdxTabsTrigger value="tab1" class="TabsTrigger">Account</button>
|
37
|
+
<button rdxTabsTrigger value="tab2" class="TabsTrigger">Password</button>
|
38
|
+
</div>
|
39
|
+
<div rdxTabsContent class="TabsContent" value="tab1">
|
40
|
+
<p class="Text">Make changes to your account here. Click save when you're done.</p>
|
41
|
+
<fieldset class="Fieldset">
|
42
|
+
<label class="Label" for="name">
|
43
|
+
Name
|
44
|
+
</label>
|
45
|
+
<input class="Input" id="name" value="Pedro Duarte" />
|
46
|
+
</fieldset>
|
47
|
+
<fieldset class="Fieldset">
|
48
|
+
<label class="Label" for="username">
|
49
|
+
Username
|
50
|
+
</label>
|
51
|
+
<input class="Input" id="username" value="@peduarte" />
|
52
|
+
</fieldset>
|
53
|
+
<div style="display: flex; margin-top: 20px; justify-content: flex-end; ">
|
54
|
+
<button class="Button green">Save changes</button>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
<div rdxTabsContent class="TabsContent" value="tab2">
|
58
|
+
<p class="Text">Change your password here. After saving, you'll be logged out.</p>
|
59
|
+
<fieldset class="Fieldset">
|
60
|
+
<label class="Label" for="currentPassword">
|
61
|
+
Current password
|
62
|
+
</label>
|
63
|
+
<input class="Input" id="currentPassword" type="password" />
|
64
|
+
</fieldset>
|
65
|
+
<fieldset class="Fieldset">
|
66
|
+
<label class="Label" for="newPassword">
|
67
|
+
New password
|
68
|
+
</label>
|
69
|
+
<input class="Input" id="newPassword" type="password" />
|
70
|
+
</fieldset>
|
71
|
+
<fieldset class="Fieldset">
|
72
|
+
<label class="Label" for="confirmPassword">
|
73
|
+
Confirm password
|
74
|
+
</label>
|
75
|
+
<input class="Input" id="confirmPassword" type="password" />
|
76
|
+
</fieldset>
|
77
|
+
<div style="display: flex; margin-top: 20px; justify-content: flex-end;">
|
78
|
+
<button class="Button green">Change password</button>
|
79
|
+
</div>
|
80
|
+
</div>
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<style>
|
84
|
+
/* reset */
|
85
|
+
button,
|
86
|
+
fieldset,
|
87
|
+
input {
|
88
|
+
all: unset;
|
89
|
+
}
|
90
|
+
|
91
|
+
.TabsRoot {
|
92
|
+
display: flex;
|
93
|
+
flex-direction: column;
|
94
|
+
width: 300px;
|
95
|
+
box-shadow: 0 2px 10px var(--black-a4);
|
96
|
+
}
|
97
|
+
|
98
|
+
.TabsList {
|
99
|
+
flex-shrink: 0;
|
100
|
+
display: flex;
|
101
|
+
border-bottom: 1px solid var(--mauve-6);
|
102
|
+
}
|
103
|
+
|
104
|
+
.TabsTrigger {
|
105
|
+
font-family: inherit;
|
106
|
+
background-color: white;
|
107
|
+
padding: 0 20px;
|
108
|
+
height: 45px;
|
109
|
+
flex: 1;
|
110
|
+
display: flex;
|
111
|
+
align-items: center;
|
112
|
+
justify-content: center;
|
113
|
+
font-size: 15px;
|
114
|
+
line-height: 1;
|
115
|
+
color: var(--mauve-11);
|
116
|
+
user-select: none;
|
117
|
+
}
|
118
|
+
.TabsTrigger:first-child {
|
119
|
+
border-top-left-radius: 6px;
|
120
|
+
}
|
121
|
+
.TabsTrigger:last-child {
|
122
|
+
border-top-right-radius: 6px;
|
123
|
+
}
|
124
|
+
.TabsTrigger:hover {
|
125
|
+
color: var(--violet-11);
|
126
|
+
}
|
127
|
+
.TabsTrigger[data-state='active'] {
|
128
|
+
color: var(--violet-11);
|
129
|
+
box-shadow:
|
130
|
+
inset 0 -1px 0 0 currentColor,
|
131
|
+
0 1px 0 0 currentColor;
|
132
|
+
}
|
133
|
+
.TabsTrigger:focus {
|
134
|
+
position: relative;
|
135
|
+
box-shadow: 0 0 0 2px black;
|
136
|
+
}
|
137
|
+
|
138
|
+
.TabsContent {
|
139
|
+
flex-grow: 1;
|
140
|
+
padding: 20px;
|
141
|
+
background-color: white;
|
142
|
+
border-bottom-left-radius: 6px;
|
143
|
+
border-bottom-right-radius: 6px;
|
144
|
+
outline: none;
|
145
|
+
}
|
146
|
+
.TabsContent:focus {
|
147
|
+
box-shadow: 0 0 0 2px black;
|
148
|
+
}
|
149
|
+
|
150
|
+
.Text {
|
151
|
+
margin-top: 0;
|
152
|
+
margin-bottom: 20px;
|
153
|
+
color: var(--mauve-11);
|
154
|
+
font-size: 15px;
|
155
|
+
line-height: 1.5;
|
156
|
+
}
|
157
|
+
|
158
|
+
.Fieldset {
|
159
|
+
margin-bottom: 15px;
|
160
|
+
width: 100%;
|
161
|
+
display: flex;
|
162
|
+
flex-direction: column;
|
163
|
+
justify-content: flex-start;
|
164
|
+
}
|
165
|
+
|
166
|
+
.Label {
|
167
|
+
font-size: 13px;
|
168
|
+
line-height: 1;
|
169
|
+
margin-bottom: 10px;
|
170
|
+
color: var(--violet-12);
|
171
|
+
display: block;
|
172
|
+
}
|
173
|
+
|
174
|
+
.Input {
|
175
|
+
flex: 1 0 auto;
|
176
|
+
border-radius: 4px;
|
177
|
+
padding: 0 10px;
|
178
|
+
font-size: 15px;
|
179
|
+
line-height: 1;
|
180
|
+
color: var(--violet-11);
|
181
|
+
box-shadow: 0 0 0 1px var(--violet-7);
|
182
|
+
height: 35px;
|
183
|
+
}
|
184
|
+
.Input:focus {
|
185
|
+
box-shadow: 0 0 0 2px var(--violet-8);
|
186
|
+
}
|
187
|
+
|
188
|
+
.Button {
|
189
|
+
display: inline-flex;
|
190
|
+
align-items: center;
|
191
|
+
justify-content: center;
|
192
|
+
border-radius: 4px;
|
193
|
+
padding: 0 15px;
|
194
|
+
font-size: 15px;
|
195
|
+
line-height: 1;
|
196
|
+
font-weight: 500;
|
197
|
+
height: 35px;
|
198
|
+
}
|
199
|
+
.Button.green {
|
200
|
+
background-color: var(--green-4);
|
201
|
+
color: var(--green-11);
|
202
|
+
}
|
203
|
+
.Button.green:hover {
|
204
|
+
background-color: var(--green-5);
|
205
|
+
}
|
206
|
+
.Button.green:focus {
|
207
|
+
box-shadow: 0 0 0 2px var(--green-7);
|
208
|
+
}
|
209
|
+
|
210
|
+
</style>
|
211
|
+
`
|
212
|
+
})
|
213
|
+
};
|
package/test-setup.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
import 'jest-preset-angular/setup-jest';
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { Component, DebugElement, Input } from '@angular/core';
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
3
|
+
import { By } from '@angular/platform-browser';
|
4
|
+
import { RdxToggleDirective } from '../src/toggle.directive';
|
5
|
+
|
6
|
+
@Component({
|
7
|
+
template:
|
8
|
+
'<button rdxToggle [pressed]="pressed" [disabled]="disabled" (onPressedChange)="onToggle($event)">Toggle</button>'
|
9
|
+
})
|
10
|
+
class TestComponent {
|
11
|
+
@Input() pressed = false;
|
12
|
+
@Input() disabled = false;
|
13
|
+
|
14
|
+
onToggle(pressed: boolean) {
|
15
|
+
this.pressed = pressed;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
describe('RdxToggleDirective', () => {
|
20
|
+
let component: TestComponent;
|
21
|
+
let fixture: ComponentFixture<TestComponent>;
|
22
|
+
let button: DebugElement;
|
23
|
+
|
24
|
+
beforeEach(async () => {
|
25
|
+
await TestBed.configureTestingModule({
|
26
|
+
imports: [RdxToggleDirective],
|
27
|
+
declarations: [TestComponent]
|
28
|
+
}).compileComponents();
|
29
|
+
});
|
30
|
+
|
31
|
+
beforeEach(() => {
|
32
|
+
fixture = TestBed.createComponent(TestComponent);
|
33
|
+
component = fixture.componentInstance;
|
34
|
+
button = fixture.debugElement.query(By.css('button'));
|
35
|
+
fixture.detectChanges();
|
36
|
+
});
|
37
|
+
|
38
|
+
it('should initialize with default values', () => {
|
39
|
+
expect(component.pressed).toBe(false);
|
40
|
+
expect(component.disabled).toBe(false);
|
41
|
+
});
|
42
|
+
|
43
|
+
it('should apply the correct aria-pressed attribute', () => {
|
44
|
+
expect(button.nativeElement.getAttribute('aria-pressed')).toBe('false');
|
45
|
+
component.pressed = true;
|
46
|
+
fixture.detectChanges();
|
47
|
+
expect(button.nativeElement.getAttribute('aria-pressed')).toBe('true');
|
48
|
+
});
|
49
|
+
|
50
|
+
it('should apply the correct data-state attribute', () => {
|
51
|
+
expect(button.nativeElement.getAttribute('data-state')).toBe('off');
|
52
|
+
component.pressed = true;
|
53
|
+
fixture.detectChanges();
|
54
|
+
expect(button.nativeElement.getAttribute('data-state')).toBe('on');
|
55
|
+
});
|
56
|
+
|
57
|
+
it('should apply the correct data-disabled attribute', () => {
|
58
|
+
expect(button.nativeElement.getAttribute('data-disabled')).toBe('false');
|
59
|
+
component.disabled = true;
|
60
|
+
fixture.detectChanges();
|
61
|
+
expect(button.nativeElement.getAttribute('data-disabled')).toBe('true');
|
62
|
+
});
|
63
|
+
|
64
|
+
it('should toggle the pressed state on click', () => {
|
65
|
+
expect(component.pressed).toBe(false);
|
66
|
+
button.nativeElement.click();
|
67
|
+
expect(component.pressed).toBe(true);
|
68
|
+
button.nativeElement.click();
|
69
|
+
expect(component.pressed).toBe(false);
|
70
|
+
});
|
71
|
+
|
72
|
+
it('should not toggle the pressed state when disabled', () => {
|
73
|
+
component.disabled = true;
|
74
|
+
fixture.detectChanges();
|
75
|
+
expect(component.pressed).toBe(false);
|
76
|
+
button.nativeElement.click();
|
77
|
+
expect(component.pressed).toBe(false);
|
78
|
+
});
|
79
|
+
|
80
|
+
it('should emit the pressed state change event on toggle', () => {
|
81
|
+
const spy = jest.spyOn(component, 'onToggle');
|
82
|
+
button.nativeElement.click();
|
83
|
+
expect(spy).toHaveBeenCalledWith(true);
|
84
|
+
button.nativeElement.click();
|
85
|
+
expect(spy).toHaveBeenCalledWith(false);
|
86
|
+
});
|
87
|
+
});
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { Directive, EventEmitter, input, model, Output } from '@angular/core';
|
2
|
+
|
3
|
+
export interface ToggleProps {
|
4
|
+
/**
|
5
|
+
* The controlled state of the toggle.
|
6
|
+
*/
|
7
|
+
pressed?: boolean;
|
8
|
+
/**
|
9
|
+
* The state of the toggle when initially rendered. Use `defaultPressed`
|
10
|
+
* if you do not need to control the state of the toggle.
|
11
|
+
* @defaultValue false
|
12
|
+
*/
|
13
|
+
defaultPressed?: boolean;
|
14
|
+
/**
|
15
|
+
* The callback that fires when the state of the toggle changes.
|
16
|
+
*/
|
17
|
+
onPressedChange?: EventEmitter<boolean>;
|
18
|
+
}
|
19
|
+
|
20
|
+
@Directive({
|
21
|
+
selector: 'button[rdxToggle]',
|
22
|
+
exportAs: 'rdxToggle',
|
23
|
+
standalone: true,
|
24
|
+
host: {
|
25
|
+
type: 'button',
|
26
|
+
'[attr.aria-pressed]': 'pressed()',
|
27
|
+
'[attr.data-state]': 'pressed() ? "on" : "off"',
|
28
|
+
'[attr.data-disabled]': 'disabled()',
|
29
|
+
|
30
|
+
'(click)': 'toggle()'
|
31
|
+
}
|
32
|
+
})
|
33
|
+
export class RdxToggleDirective {
|
34
|
+
readonly defaultPressed = input<boolean>(false);
|
35
|
+
readonly pressed = model<boolean>(this.defaultPressed());
|
36
|
+
readonly disabled = input<boolean>(false);
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Event emitted when the toggle is pressed.
|
40
|
+
*/
|
41
|
+
@Output() readonly onPressedChange = new EventEmitter<boolean>();
|
42
|
+
|
43
|
+
protected toggle(): void {
|
44
|
+
if (!this.disabled()) {
|
45
|
+
this.pressed.set(!this.pressed());
|
46
|
+
this.onPressedChange.emit(this.pressed());
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { ArgTypes, Canvas, Markdown, Meta } from '@storybook/blocks';
|
2
|
+
import * as ToggleDirectiveStories from './toggle.stories';
|
3
|
+
import { RdxToggleDirective } from '../src/toggle.directive';
|
4
|
+
|
5
|
+
<Meta title="Primitives/Toggle" />
|
6
|
+
|
7
|
+
# Toggle
|
8
|
+
|
9
|
+
#### A two-\_state button that can be either on or off.
|
10
|
+
|
11
|
+
<Canvas sourceState="hidden" of={ToggleDirectiveStories.Default} />
|
12
|
+
|
13
|
+
## Features
|
14
|
+
|
15
|
+
- ✅ Full keyboard navigation.
|
16
|
+
- ✅ Can be controlled or uncontrolled.
|
17
|
+
|
18
|
+
## Import
|
19
|
+
|
20
|
+
Get started with importing the directives:
|
21
|
+
|
22
|
+
```typescript
|
23
|
+
import { RdxToggleDirective } from '@radix-ng/primitives/toggle';
|
24
|
+
```
|
25
|
+
|
26
|
+
## Examples
|
27
|
+
|
28
|
+
```html
|
29
|
+
<button rdxToggle aria-label="Toggle italic">
|
30
|
+
<icon />
|
31
|
+
</button>
|
32
|
+
```
|
33
|
+
|
34
|
+
## API Reference
|
35
|
+
|
36
|
+
### RdxToggleDirective
|
37
|
+
|
38
|
+
<ArgTypes of={RdxToggleDirective} />
|
39
|
+
|
40
|
+
<Markdown>
|
41
|
+
{`
|
42
|
+
| Data Attribute | Value |
|
43
|
+
| ----------- | --------- |
|
44
|
+
| [data-state] | "on" or "off" |
|
45
|
+
| [data-disabled] | Present when disabled |
|
46
|
+
`}
|
47
|
+
</Markdown>
|
48
|
+
|
49
|
+
## Accessibility
|
50
|
+
|
51
|
+
### Keyboard Interactions
|
52
|
+
|
53
|
+
<Markdown>
|
54
|
+
{`
|
55
|
+
| Key | Description |
|
56
|
+
| ----------- | --------- |
|
57
|
+
| Space | Activates/deactivates the toggle. |
|
58
|
+
| Enter | Activates/deactivates the toggle. |
|
59
|
+
`}
|
60
|
+
</Markdown>
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import { componentWrapperDecorator, Meta, moduleMetadata, StoryObj } from '@storybook/angular';
|
2
|
+
import { Italic, LucideAngularModule } from 'lucide-angular';
|
3
|
+
import { RdxToggleDirective } from '../src/toggle.directive';
|
4
|
+
|
5
|
+
export default {
|
6
|
+
title: 'Primitives/Toggle',
|
7
|
+
decorators: [
|
8
|
+
moduleMetadata({
|
9
|
+
imports: [
|
10
|
+
RdxToggleDirective,
|
11
|
+
LucideAngularModule,
|
12
|
+
LucideAngularModule.pick({ Italic })
|
13
|
+
]
|
14
|
+
}),
|
15
|
+
componentWrapperDecorator(
|
16
|
+
(story) =>
|
17
|
+
`<div class="radix-themes light light-theme"
|
18
|
+
data-radius="medium"
|
19
|
+
data-scaling="100%">${story}
|
20
|
+
|
21
|
+
<style>
|
22
|
+
button {
|
23
|
+
all: unset;
|
24
|
+
}
|
25
|
+
.Toggle {
|
26
|
+
background-color: white;
|
27
|
+
color: var(--mauve-11);
|
28
|
+
height: 35px;
|
29
|
+
width: 35px;
|
30
|
+
border-radius: 4px;
|
31
|
+
display: flex;
|
32
|
+
font-size: 15px;
|
33
|
+
line-height: 1;
|
34
|
+
align-items: center;
|
35
|
+
justify-content: center;
|
36
|
+
box-shadow: 0 2px 10px var(--black-a7);
|
37
|
+
}
|
38
|
+
.Toggle:hover {
|
39
|
+
background-color: var(--violet-3);
|
40
|
+
}
|
41
|
+
.Toggle[data-state='on'] {
|
42
|
+
background-color: var(--violet-6);
|
43
|
+
color: var(--violet-12);
|
44
|
+
}
|
45
|
+
.Toggle:focus {
|
46
|
+
box-shadow: 0 0 0 2px black;
|
47
|
+
}
|
48
|
+
</style>
|
49
|
+
|
50
|
+
</div>`
|
51
|
+
)
|
52
|
+
],
|
53
|
+
argTypes: {
|
54
|
+
pressed: {
|
55
|
+
control: 'boolean'
|
56
|
+
}
|
57
|
+
}
|
58
|
+
} as Meta;
|
59
|
+
|
60
|
+
type Story = StoryObj;
|
61
|
+
|
62
|
+
export const Default: Story = {
|
63
|
+
render: () => ({
|
64
|
+
template: `
|
65
|
+
<button rdxToggle aria-label="Toggle italic" class="Toggle">
|
66
|
+
<lucide-angular name="italic" size="16"></lucide-angular>
|
67
|
+
</button>
|
68
|
+
`
|
69
|
+
})
|
70
|
+
};
|
71
|
+
|
72
|
+
export const State: Story = {
|
73
|
+
render: (args) => ({
|
74
|
+
props: {
|
75
|
+
...args,
|
76
|
+
pressed: true
|
77
|
+
},
|
78
|
+
template: `
|
79
|
+
<button rdxToggle [pressed]="pressed" aria-label="Toggle italic" class="Toggle">
|
80
|
+
<lucide-angular name="italic" size="16"></lucide-angular>
|
81
|
+
</button>
|
82
|
+
`
|
83
|
+
})
|
84
|
+
};
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { booleanAttribute, Directive, Input, OnChanges, SimpleChanges } from '@angular/core';
|
2
|
+
import { RdxToggleGroupButtonToken } from './toggle-group-button.token';
|
3
|
+
import { injectToggleGroup } from './toggle-group.token';
|
4
|
+
|
5
|
+
@Directive({
|
6
|
+
selector: 'button[rdxToggleGroupButton]',
|
7
|
+
standalone: true,
|
8
|
+
providers: [{ provide: RdxToggleGroupButtonToken, useExisting: RdxToggleGroupButtonDirective }],
|
9
|
+
host: {
|
10
|
+
role: 'radio',
|
11
|
+
'[attr.aria-checked]': 'checked',
|
12
|
+
'[attr.aria-disabled]': 'disabled || toggleGroup.disabled',
|
13
|
+
'[attr.data-disabled]': 'disabled || toggleGroup.disabled',
|
14
|
+
'[attr.data-state]': 'checked ? "on" : "off"',
|
15
|
+
'[attr.data-orientation]': 'toggleGroup.orientation',
|
16
|
+
|
17
|
+
'(click)': 'toggle()'
|
18
|
+
}
|
19
|
+
})
|
20
|
+
export class RdxToggleGroupButtonDirective implements OnChanges {
|
21
|
+
/**
|
22
|
+
* Access the toggle group.
|
23
|
+
* @ignore
|
24
|
+
*/
|
25
|
+
protected readonly toggleGroup = injectToggleGroup();
|
26
|
+
|
27
|
+
/**
|
28
|
+
* The value of this toggle button.
|
29
|
+
*/
|
30
|
+
@Input({ required: true }) value!: string;
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Whether this toggle button is disabled.
|
34
|
+
* @default false
|
35
|
+
*/
|
36
|
+
@Input({ transform: booleanAttribute }) disabled = false;
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Whether this toggle button is checked.
|
40
|
+
*/
|
41
|
+
protected get checked(): boolean {
|
42
|
+
return this.toggleGroup.isSelected(this.value);
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* @ignore
|
47
|
+
*/
|
48
|
+
ngOnChanges(changes: SimpleChanges): void {
|
49
|
+
if ('disabled' in changes) {
|
50
|
+
// TODO
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @ignore
|
56
|
+
*/
|
57
|
+
toggle(): void {
|
58
|
+
if (this.disabled) {
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
|
62
|
+
this.toggleGroup.toggle(this.value);
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Ensure the disabled state is propagated to the roving focus item.
|
67
|
+
* @internal
|
68
|
+
* @ignore
|
69
|
+
*/
|
70
|
+
updateDisabled(): void {
|
71
|
+
// TODO
|
72
|
+
}
|
73
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { inject, InjectionToken } from '@angular/core';
|
2
|
+
import type { RdxToggleGroupButtonDirective } from './toggle-group-button.directive';
|
3
|
+
|
4
|
+
export const RdxToggleGroupButtonToken = new InjectionToken<RdxToggleGroupButtonDirective>('RdxToggleGroupButtonToken');
|
5
|
+
|
6
|
+
export function injectToggleGroupButton(): RdxToggleGroupButtonDirective {
|
7
|
+
return inject(RdxToggleGroupButtonToken);
|
8
|
+
}
|