@ng-cn/core 1.0.15 → 1.0.17
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/package.json +34 -33
- package/schematics/component/index.js +454 -95
- package/schematics/component/index.ts +459 -98
- package/schematics/ng-add/index.js +539 -55
- package/schematics/ng-add/index.ts +555 -62
- package/schematics/ng-add/schema.json +8 -2
- package/schematics/test-schematic.js +1 -2
- package/src/app/lib/components/ui/.gitkeep +0 -0
- package/src/app/lib/components/ui/accordion/accordion-content.component.ts +16 -24
- package/src/app/lib/components/ui/accordion/accordion-context.ts +4 -9
- package/src/app/lib/components/ui/accordion/accordion-item.component.ts +33 -29
- package/src/app/lib/components/ui/accordion/accordion-trigger.component.ts +11 -14
- package/src/app/lib/components/ui/accordion/accordion.component.ts +60 -49
- package/src/app/lib/components/ui/accordion/index.ts +5 -6
- package/src/app/lib/components/ui/alert/alert-description.component.ts +3 -8
- package/src/app/lib/components/ui/alert/alert-title.component.ts +2 -7
- package/src/app/lib/components/ui/alert/alert-variants.ts +19 -5
- package/src/app/lib/components/ui/alert/alert.component.ts +2 -10
- package/src/app/lib/components/ui/alert/index.ts +0 -1
- package/src/app/lib/components/ui/alert-dialog/alert-dialog-action.component.ts +5 -12
- package/src/app/lib/components/ui/alert-dialog/alert-dialog-cancel.component.ts +5 -11
- package/src/app/lib/components/ui/alert-dialog/alert-dialog-content.component.ts +63 -66
- package/src/app/lib/components/ui/alert-dialog/alert-dialog-context.ts +10 -5
- package/src/app/lib/components/ui/alert-dialog/alert-dialog-description.component.ts +5 -10
- package/src/app/lib/components/ui/alert-dialog/alert-dialog-footer.component.ts +3 -7
- package/src/app/lib/components/ui/alert-dialog/alert-dialog-header.component.ts +3 -7
- package/src/app/lib/components/ui/alert-dialog/alert-dialog-title.component.ts +5 -12
- package/src/app/lib/components/ui/alert-dialog/alert-dialog-trigger.component.ts +8 -12
- package/src/app/lib/components/ui/alert-dialog/alert-dialog.component.ts +28 -34
- package/src/app/lib/components/ui/alert-dialog/index.ts +0 -1
- package/src/app/lib/components/ui/aspect-ratio/aspect-ratio.component.ts +3 -9
- package/src/app/lib/components/ui/avatar/avatar-context.ts +9 -0
- package/src/app/lib/components/ui/avatar/avatar-fallback.component.ts +7 -18
- package/src/app/lib/components/ui/avatar/avatar-image.component.ts +39 -17
- package/src/app/lib/components/ui/avatar/avatar.component.ts +17 -20
- package/src/app/lib/components/ui/avatar/index.ts +1 -1
- package/src/app/lib/components/ui/avatar/ui-avatar.component.ts +9 -30
- package/src/app/lib/components/ui/badge/badge-variants.ts +5 -5
- package/src/app/lib/components/ui/badge/badge.component.ts +4 -8
- package/src/app/lib/components/ui/badge/index.ts +0 -1
- package/src/app/lib/components/ui/breadcrumb/breadcrumb-ellipsis.component.ts +3 -7
- package/src/app/lib/components/ui/breadcrumb/breadcrumb-item.component.ts +5 -14
- package/src/app/lib/components/ui/breadcrumb/breadcrumb-link.component.ts +6 -18
- package/src/app/lib/components/ui/breadcrumb/breadcrumb-list.component.ts +6 -15
- package/src/app/lib/components/ui/breadcrumb/breadcrumb-page.component.ts +3 -7
- package/src/app/lib/components/ui/breadcrumb/breadcrumb-separator.component.ts +22 -31
- package/src/app/lib/components/ui/breadcrumb/breadcrumb.component.ts +3 -9
- package/src/app/lib/components/ui/breadcrumb/index.ts +0 -1
- package/src/app/lib/components/ui/button/button-variants.ts +6 -8
- package/src/app/lib/components/ui/button/button.component.ts +4 -8
- package/src/app/lib/components/ui/button/index.ts +0 -1
- package/src/app/lib/components/ui/button-group/button-group-variants.ts +12 -15
- package/src/app/lib/components/ui/button-group/button-group.component.ts +6 -14
- package/src/app/lib/components/ui/button-group/index.ts +1 -5
- package/src/app/lib/components/ui/calendar/calendar.component.ts +103 -115
- package/src/app/lib/components/ui/card/card-action.component.ts +2 -10
- package/src/app/lib/components/ui/card/card-content.component.ts +1 -6
- package/src/app/lib/components/ui/card/card-description.component.ts +2 -7
- package/src/app/lib/components/ui/card/card-footer.component.ts +2 -7
- package/src/app/lib/components/ui/card/card-header.component.ts +3 -8
- package/src/app/lib/components/ui/card/card-title.component.ts +2 -9
- package/src/app/lib/components/ui/card/card.component.ts +3 -8
- package/src/app/lib/components/ui/card/index.ts +0 -1
- package/src/app/lib/components/ui/carousel/carousel-content.component.ts +3 -9
- package/src/app/lib/components/ui/carousel/carousel-item.component.ts +5 -5
- package/src/app/lib/components/ui/carousel/carousel-next.component.ts +9 -8
- package/src/app/lib/components/ui/carousel/carousel-previous.component.ts +9 -8
- package/src/app/lib/components/ui/carousel/carousel.component.ts +14 -25
- package/src/app/lib/components/ui/carousel/index.ts +5 -2
- package/src/app/lib/components/ui/chart/chart-container.component.ts +20 -26
- package/src/app/lib/components/ui/chart/chart-legend-content.component.ts +6 -16
- package/src/app/lib/components/ui/chart/chart-legend.component.ts +2 -7
- package/src/app/lib/components/ui/chart/chart-tooltip-content.component.ts +2 -9
- package/src/app/lib/components/ui/chart/chart-tooltip.component.ts +2 -7
- package/src/app/lib/components/ui/chart/chart.component.ts +12 -32
- package/src/app/lib/components/ui/chart/index.ts +7 -8
- package/src/app/lib/components/ui/checkbox/checkbox.component.ts +55 -74
- package/src/app/lib/components/ui/collapsible/collapsible-content.component.ts +16 -25
- package/src/app/lib/components/ui/collapsible/collapsible-context.ts +0 -8
- package/src/app/lib/components/ui/collapsible/collapsible-trigger.component.ts +6 -16
- package/src/app/lib/components/ui/collapsible/collapsible.component.ts +29 -33
- package/src/app/lib/components/ui/collapsible/index.ts +0 -1
- package/src/app/lib/components/ui/combobox/combobox-content.component.ts +8 -15
- package/src/app/lib/components/ui/combobox/combobox-context.ts +5 -4
- package/src/app/lib/components/ui/combobox/combobox-empty.component.ts +5 -12
- package/src/app/lib/components/ui/combobox/combobox-group.component.ts +3 -7
- package/src/app/lib/components/ui/combobox/combobox-input.component.ts +25 -25
- package/src/app/lib/components/ui/combobox/combobox-item.component.ts +45 -44
- package/src/app/lib/components/ui/combobox/combobox-list.component.ts +14 -12
- package/src/app/lib/components/ui/combobox/combobox-trigger.component.ts +24 -14
- package/src/app/lib/components/ui/combobox/combobox-value.component.ts +27 -22
- package/src/app/lib/components/ui/combobox/combobox.component.ts +74 -54
- package/src/app/lib/components/ui/combobox/index.ts +1 -6
- package/src/app/lib/components/ui/command/command-context.ts +1 -5
- package/src/app/lib/components/ui/command/command-dialog.component.ts +12 -14
- package/src/app/lib/components/ui/command/command-empty.component.ts +2 -3
- package/src/app/lib/components/ui/command/command-group.component.ts +32 -25
- package/src/app/lib/components/ui/command/command-input.component.ts +29 -28
- package/src/app/lib/components/ui/command/command-item.component.ts +46 -58
- package/src/app/lib/components/ui/command/command-list.component.ts +5 -4
- package/src/app/lib/components/ui/command/command-separator.component.ts +2 -3
- package/src/app/lib/components/ui/command/command-shortcut.component.ts +2 -1
- package/src/app/lib/components/ui/command/command.component.ts +33 -22
- package/src/app/lib/components/ui/command/index.ts +0 -1
- package/src/app/lib/components/ui/context-menu/context-menu-checkbox-item.component.ts +20 -11
- package/src/app/lib/components/ui/context-menu/context-menu-content.component.ts +36 -43
- package/src/app/lib/components/ui/context-menu/context-menu-context.ts +1 -1
- package/src/app/lib/components/ui/context-menu/context-menu-item.component.ts +12 -13
- package/src/app/lib/components/ui/context-menu/context-menu-label.component.ts +2 -5
- package/src/app/lib/components/ui/context-menu/context-menu-radio-group.component.ts +9 -2
- package/src/app/lib/components/ui/context-menu/context-menu-radio-item.component.ts +14 -14
- package/src/app/lib/components/ui/context-menu/context-menu-separator.component.ts +2 -3
- package/src/app/lib/components/ui/context-menu/context-menu-shortcut.component.ts +2 -1
- package/src/app/lib/components/ui/context-menu/context-menu-sub-content.component.ts +5 -5
- package/src/app/lib/components/ui/context-menu/context-menu-sub-trigger.component.ts +8 -7
- package/src/app/lib/components/ui/context-menu/context-menu-sub.component.ts +9 -2
- package/src/app/lib/components/ui/context-menu/context-menu-trigger.component.ts +8 -7
- package/src/app/lib/components/ui/context-menu/context-menu.component.ts +1 -0
- package/src/app/lib/components/ui/context-menu/index.ts +15 -4
- package/src/app/lib/components/ui/data-table/data-table-content.component.ts +22 -28
- package/src/app/lib/components/ui/data-table/data-table-context.ts +1 -3
- package/src/app/lib/components/ui/data-table/data-table-pagination.component.ts +17 -27
- package/src/app/lib/components/ui/data-table/data-table-search.component.ts +6 -14
- package/src/app/lib/components/ui/data-table/data-table-toolbar.component.ts +3 -7
- package/src/app/lib/components/ui/data-table/data-table-view-options.component.ts +11 -20
- package/src/app/lib/components/ui/data-table/data-table.component.ts +41 -49
- package/src/app/lib/components/ui/data-table/index.ts +7 -8
- package/src/app/lib/components/ui/date-picker/date-picker.component.ts +24 -24
- package/src/app/lib/components/ui/dialog/dialog-close.component.ts +4 -8
- package/src/app/lib/components/ui/dialog/dialog-content.component.ts +72 -73
- package/src/app/lib/components/ui/dialog/dialog-context.ts +7 -5
- package/src/app/lib/components/ui/dialog/dialog-description.component.ts +5 -10
- package/src/app/lib/components/ui/dialog/dialog-footer.component.ts +3 -7
- package/src/app/lib/components/ui/dialog/dialog-header.component.ts +3 -7
- package/src/app/lib/components/ui/dialog/dialog-title.component.ts +5 -10
- package/src/app/lib/components/ui/dialog/dialog-trigger.component.ts +7 -11
- package/src/app/lib/components/ui/dialog/dialog.component.ts +29 -34
- package/src/app/lib/components/ui/dialog/index.ts +0 -1
- package/src/app/lib/components/ui/drawer/drawer-close.component.ts +4 -8
- package/src/app/lib/components/ui/drawer/drawer-content.component.ts +39 -35
- package/src/app/lib/components/ui/drawer/drawer-description.component.ts +5 -10
- package/src/app/lib/components/ui/drawer/drawer-footer.component.ts +3 -7
- package/src/app/lib/components/ui/drawer/drawer-header.component.ts +3 -7
- package/src/app/lib/components/ui/drawer/drawer-title.component.ts +5 -10
- package/src/app/lib/components/ui/drawer/drawer-trigger.component.ts +7 -11
- package/src/app/lib/components/ui/drawer/drawer.component.ts +25 -26
- package/src/app/lib/components/ui/drawer/index.ts +0 -1
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-item.component.ts +20 -11
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-content.component.ts +96 -61
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-context.ts +1 -1
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-group.component.ts +1 -0
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-item.component.ts +10 -11
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-label.component.ts +2 -5
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-radio-group.component.ts +14 -5
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-radio-item.component.ts +14 -14
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-separator.component.ts +2 -3
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-shortcut.component.ts +2 -1
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-sub-content.component.ts +5 -5
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-sub-trigger.component.ts +8 -7
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-sub.component.ts +9 -2
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu-trigger.component.ts +6 -5
- package/src/app/lib/components/ui/dropdown-menu/dropdown-menu.component.ts +1 -0
- package/src/app/lib/components/ui/dropdown-menu/index.ts +10 -3
- package/src/app/lib/components/ui/empty/empty-action.component.ts +2 -9
- package/src/app/lib/components/ui/empty/empty-description.component.ts +2 -10
- package/src/app/lib/components/ui/empty/empty-icon.component.ts +3 -8
- package/src/app/lib/components/ui/empty/empty-title.component.ts +2 -9
- package/src/app/lib/components/ui/empty/empty.component.ts +3 -8
- package/src/app/lib/components/ui/empty/index.ts +0 -1
- package/src/app/lib/components/ui/form/form-context.ts +1 -11
- package/src/app/lib/components/ui/form/form-control.component.ts +22 -22
- package/src/app/lib/components/ui/form/form-description.component.ts +4 -10
- package/src/app/lib/components/ui/form/form-field.component.ts +7 -10
- package/src/app/lib/components/ui/form/form-item.component.ts +2 -12
- package/src/app/lib/components/ui/form/form-label.component.ts +15 -15
- package/src/app/lib/components/ui/form/form-message.component.ts +7 -15
- package/src/app/lib/components/ui/form/form.component.ts +9 -20
- package/src/app/lib/components/ui/form/index.ts +4 -5
- package/src/app/lib/components/ui/hover-card/hover-card-content.component.ts +21 -33
- package/src/app/lib/components/ui/hover-card/hover-card-context.ts +0 -8
- package/src/app/lib/components/ui/hover-card/hover-card-trigger.component.ts +17 -26
- package/src/app/lib/components/ui/hover-card/hover-card.component.ts +18 -28
- package/src/app/lib/components/ui/hover-card/index.ts +9 -6
- package/src/app/lib/components/ui/input/input.component.ts +57 -75
- package/src/app/lib/components/ui/input-group/index.ts +0 -1
- package/src/app/lib/components/ui/input-group/input-group-addon.component.ts +4 -11
- package/src/app/lib/components/ui/input-group/input-group-input.component.ts +3 -8
- package/src/app/lib/components/ui/input-group/input-group.component.ts +4 -9
- package/src/app/lib/components/ui/input-otp/index.ts +4 -5
- package/src/app/lib/components/ui/input-otp/input-otp-context.ts +0 -8
- package/src/app/lib/components/ui/input-otp/input-otp-group.component.ts +2 -3
- package/src/app/lib/components/ui/input-otp/input-otp-separator.component.ts +4 -3
- package/src/app/lib/components/ui/input-otp/input-otp-slot.component.ts +8 -10
- package/src/app/lib/components/ui/input-otp/input-otp.component.ts +27 -45
- package/src/app/lib/components/ui/kbd/index.ts +0 -1
- package/src/app/lib/components/ui/kbd/kbd-variants.ts +1 -1
- package/src/app/lib/components/ui/kbd/kbd.component.ts +4 -8
- package/src/app/lib/components/ui/label/label.component.ts +15 -28
- package/src/app/lib/components/ui/menubar/index.ts +11 -8
- package/src/app/lib/components/ui/menubar/menubar-checkbox-item.component.ts +21 -12
- package/src/app/lib/components/ui/menubar/menubar-content.component.ts +46 -53
- package/src/app/lib/components/ui/menubar/menubar-context.ts +3 -9
- package/src/app/lib/components/ui/menubar/menubar-item.component.ts +13 -14
- package/src/app/lib/components/ui/menubar/menubar-label.component.ts +2 -5
- package/src/app/lib/components/ui/menubar/menubar-menu.component.ts +14 -2
- package/src/app/lib/components/ui/menubar/menubar-radio-group.component.ts +9 -2
- package/src/app/lib/components/ui/menubar/menubar-radio-item.component.ts +13 -13
- package/src/app/lib/components/ui/menubar/menubar-separator.component.ts +2 -3
- package/src/app/lib/components/ui/menubar/menubar-shortcut.component.ts +2 -1
- package/src/app/lib/components/ui/menubar/menubar-sub-content.component.ts +5 -5
- package/src/app/lib/components/ui/menubar/menubar-sub-trigger.component.ts +7 -6
- package/src/app/lib/components/ui/menubar/menubar-sub.component.ts +8 -1
- package/src/app/lib/components/ui/menubar/menubar-trigger.component.ts +26 -21
- package/src/app/lib/components/ui/menubar/menubar.component.ts +6 -13
- package/src/app/lib/components/ui/native-select/index.ts +1 -5
- package/src/app/lib/components/ui/native-select/native-select-variants.ts +1 -1
- package/src/app/lib/components/ui/native-select/native-select.component.ts +14 -15
- package/src/app/lib/components/ui/navigation-menu/index.ts +10 -8
- package/src/app/lib/components/ui/navigation-menu/navigation-menu-content.component.ts +18 -13
- package/src/app/lib/components/ui/navigation-menu/navigation-menu-context.ts +2 -10
- package/src/app/lib/components/ui/navigation-menu/navigation-menu-indicator.component.ts +3 -2
- package/src/app/lib/components/ui/navigation-menu/navigation-menu-item.component.ts +6 -1
- package/src/app/lib/components/ui/navigation-menu/navigation-menu-link.component.ts +3 -8
- package/src/app/lib/components/ui/navigation-menu/navigation-menu-list.component.ts +2 -4
- package/src/app/lib/components/ui/navigation-menu/navigation-menu-trigger-style.ts +1 -1
- package/src/app/lib/components/ui/navigation-menu/navigation-menu-trigger.component.ts +8 -7
- package/src/app/lib/components/ui/navigation-menu/navigation-menu-viewport.component.ts +3 -2
- package/src/app/lib/components/ui/navigation-menu/navigation-menu.component.ts +8 -15
- package/src/app/lib/components/ui/pagination/index.ts +0 -1
- package/src/app/lib/components/ui/pagination/pagination-content.component.ts +3 -7
- package/src/app/lib/components/ui/pagination/pagination-ellipsis.component.ts +3 -7
- package/src/app/lib/components/ui/pagination/pagination-item.component.ts +3 -9
- package/src/app/lib/components/ui/pagination/pagination-link.component.ts +4 -8
- package/src/app/lib/components/ui/pagination/pagination-next.component.ts +3 -11
- package/src/app/lib/components/ui/pagination/pagination-previous.component.ts +3 -11
- package/src/app/lib/components/ui/pagination/pagination.component.ts +3 -7
- package/src/app/lib/components/ui/popover/index.ts +9 -6
- package/src/app/lib/components/ui/popover/popover-anchor.component.ts +2 -13
- package/src/app/lib/components/ui/popover/popover-content.component.ts +119 -69
- package/src/app/lib/components/ui/popover/popover-context.ts +0 -8
- package/src/app/lib/components/ui/popover/popover-trigger.component.ts +22 -22
- package/src/app/lib/components/ui/popover/popover.component.ts +20 -33
- package/src/app/lib/components/ui/progress/index.ts +1 -6
- package/src/app/lib/components/ui/progress/progress.component.ts +15 -30
- package/src/app/lib/components/ui/radio-group/index.ts +1 -4
- package/src/app/lib/components/ui/radio-group/radio-group-context.ts +1 -7
- package/src/app/lib/components/ui/radio-group/radio-group-item.component.ts +36 -69
- package/src/app/lib/components/ui/radio-group/radio-group.component.ts +38 -67
- package/src/app/lib/components/ui/resizable/index.ts +0 -1
- package/src/app/lib/components/ui/resizable/resizable-handle.component.ts +25 -39
- package/src/app/lib/components/ui/resizable/resizable-panel-group.component.ts +15 -18
- package/src/app/lib/components/ui/resizable/resizable-panel.component.ts +12 -31
- package/src/app/lib/components/ui/scroll-area/index.ts +4 -5
- package/src/app/lib/components/ui/scroll-area/scroll-area.component.ts +5 -19
- package/src/app/lib/components/ui/scroll-area/scroll-bar.component.ts +8 -27
- package/src/app/lib/components/ui/segmented/index.ts +5 -9
- package/src/app/lib/components/ui/segmented/segmented-context.ts +1 -3
- package/src/app/lib/components/ui/segmented/segmented-item.component.ts +21 -29
- package/src/app/lib/components/ui/segmented/segmented-variants.ts +2 -2
- package/src/app/lib/components/ui/segmented/segmented.component.ts +24 -32
- package/src/app/lib/components/ui/select/index.ts +5 -6
- package/src/app/lib/components/ui/select/select-content.component.ts +34 -62
- package/src/app/lib/components/ui/select/select-context.ts +4 -14
- package/src/app/lib/components/ui/select/select-group.component.ts +6 -7
- package/src/app/lib/components/ui/select/select-item.component.ts +46 -55
- package/src/app/lib/components/ui/select/select-label.component.ts +2 -7
- package/src/app/lib/components/ui/select/select-separator.component.ts +3 -8
- package/src/app/lib/components/ui/select/select-trigger.component.ts +28 -25
- package/src/app/lib/components/ui/select/select-value.component.ts +7 -13
- package/src/app/lib/components/ui/select/select.component.ts +52 -64
- package/src/app/lib/components/ui/separator/index.ts +1 -6
- package/src/app/lib/components/ui/separator/separator.component.ts +4 -19
- package/src/app/lib/components/ui/sheet/index.ts +0 -1
- package/src/app/lib/components/ui/sheet/sheet-close.component.ts +4 -8
- package/src/app/lib/components/ui/sheet/sheet-content.component.ts +31 -36
- package/src/app/lib/components/ui/sheet/sheet-description.component.ts +5 -10
- package/src/app/lib/components/ui/sheet/sheet-footer.component.ts +3 -7
- package/src/app/lib/components/ui/sheet/sheet-header.component.ts +3 -7
- package/src/app/lib/components/ui/sheet/sheet-title.component.ts +5 -10
- package/src/app/lib/components/ui/sheet/sheet-trigger.component.ts +7 -11
- package/src/app/lib/components/ui/sheet/sheet-variants.ts +1 -1
- package/src/app/lib/components/ui/sheet/sheet.component.ts +36 -36
- package/src/app/lib/components/ui/sidebar/index.ts +14 -15
- package/src/app/lib/components/ui/sidebar/sidebar-content.component.ts +4 -8
- package/src/app/lib/components/ui/sidebar/sidebar-context.ts +1 -3
- package/src/app/lib/components/ui/sidebar/sidebar-footer.component.ts +3 -9
- package/src/app/lib/components/ui/sidebar/sidebar-group-action.component.ts +4 -8
- package/src/app/lib/components/ui/sidebar/sidebar-group-content.component.ts +3 -9
- package/src/app/lib/components/ui/sidebar/sidebar-group-label.component.ts +4 -8
- package/src/app/lib/components/ui/sidebar/sidebar-group.component.ts +3 -7
- package/src/app/lib/components/ui/sidebar/sidebar-header.component.ts +3 -9
- package/src/app/lib/components/ui/sidebar/sidebar-input.component.ts +4 -8
- package/src/app/lib/components/ui/sidebar/sidebar-inset.component.ts +4 -8
- package/src/app/lib/components/ui/sidebar/sidebar-menu-action.component.ts +4 -8
- package/src/app/lib/components/ui/sidebar/sidebar-menu-badge.component.ts +4 -8
- package/src/app/lib/components/ui/sidebar/sidebar-menu-button.component.ts +4 -9
- package/src/app/lib/components/ui/sidebar/sidebar-menu-item.component.ts +3 -9
- package/src/app/lib/components/ui/sidebar/sidebar-menu-skeleton.component.ts +6 -11
- package/src/app/lib/components/ui/sidebar/sidebar-menu-sub-button.component.ts +4 -8
- package/src/app/lib/components/ui/sidebar/sidebar-menu-sub-item.component.ts +2 -6
- package/src/app/lib/components/ui/sidebar/sidebar-menu-sub.component.ts +4 -8
- package/src/app/lib/components/ui/sidebar/sidebar-menu.component.ts +3 -7
- package/src/app/lib/components/ui/sidebar/sidebar-provider.component.ts +46 -52
- package/src/app/lib/components/ui/sidebar/sidebar-rail.component.ts +6 -11
- package/src/app/lib/components/ui/sidebar/sidebar-route-active.service.ts +17 -17
- package/src/app/lib/components/ui/sidebar/sidebar-separator.component.ts +3 -7
- package/src/app/lib/components/ui/sidebar/sidebar-trigger.component.ts +6 -11
- package/src/app/lib/components/ui/sidebar/sidebar.component.ts +20 -31
- package/src/app/lib/components/ui/skeleton/skeleton.component.ts +3 -8
- package/src/app/lib/components/ui/slider/index.ts +1 -6
- package/src/app/lib/components/ui/slider/slider.component.ts +73 -138
- package/src/app/lib/components/ui/spinner/index.ts +0 -1
- package/src/app/lib/components/ui/spinner/spinner-variants.ts +19 -22
- package/src/app/lib/components/ui/spinner/spinner.component.ts +4 -8
- package/src/app/lib/components/ui/switch/index.ts +1 -6
- package/src/app/lib/components/ui/switch/switch.component.ts +83 -108
- package/src/app/lib/components/ui/table/index.ts +0 -1
- package/src/app/lib/components/ui/table/table-body.component.ts +6 -10
- package/src/app/lib/components/ui/table/table-caption.component.ts +6 -8
- package/src/app/lib/components/ui/table/table-cell.component.ts +4 -8
- package/src/app/lib/components/ui/table/table-footer.component.ts +6 -8
- package/src/app/lib/components/ui/table/table-head.component.ts +4 -8
- package/src/app/lib/components/ui/table/table-header.component.ts +6 -10
- package/src/app/lib/components/ui/table/table-row.component.ts +6 -11
- package/src/app/lib/components/ui/table/table.component.ts +4 -8
- package/src/app/lib/components/ui/tabs/index.ts +14 -7
- package/src/app/lib/components/ui/tabs/tabs-content.component.ts +11 -36
- package/src/app/lib/components/ui/tabs/tabs-context.ts +0 -8
- package/src/app/lib/components/ui/tabs/tabs-list.component.ts +54 -60
- package/src/app/lib/components/ui/tabs/tabs-trigger.component.ts +20 -35
- package/src/app/lib/components/ui/tabs/tabs.component.ts +32 -49
- package/src/app/lib/components/ui/textarea/textarea.component.ts +3 -8
- package/src/app/lib/components/ui/toast/index.ts +6 -7
- package/src/app/lib/components/ui/toast/toast-action.component.ts +7 -18
- package/src/app/lib/components/ui/toast/toast-description.component.ts +2 -11
- package/src/app/lib/components/ui/toast/toast-title.component.ts +2 -9
- package/src/app/lib/components/ui/toast/toast-variants.ts +1 -1
- package/src/app/lib/components/ui/toast/toast.component.ts +18 -24
- package/src/app/lib/components/ui/toast/toast.service.ts +22 -37
- package/src/app/lib/components/ui/toast/toaster.component.ts +6 -16
- package/src/app/lib/components/ui/toggle/index.ts +1 -5
- package/src/app/lib/components/ui/toggle/toggle-variants.ts +2 -2
- package/src/app/lib/components/ui/toggle/toggle.component.ts +32 -51
- package/src/app/lib/components/ui/toggle-group/index.ts +1 -4
- package/src/app/lib/components/ui/toggle-group/toggle-group-context.ts +1 -7
- package/src/app/lib/components/ui/toggle-group/toggle-group-item.component.ts +38 -59
- package/src/app/lib/components/ui/toggle-group/toggle-group.component.ts +33 -51
- package/src/app/lib/components/ui/tooltip/index.ts +9 -6
- package/src/app/lib/components/ui/tooltip/tooltip-content.component.ts +6 -24
- package/src/app/lib/components/ui/tooltip/tooltip-context.ts +0 -8
- package/src/app/lib/components/ui/tooltip/tooltip-provider.component.ts +12 -24
- package/src/app/lib/components/ui/tooltip/tooltip-trigger.component.ts +4 -21
- package/src/app/lib/components/ui/tooltip/tooltip.component.ts +21 -33
- package/src/app/lib/components/ui/typography/index.ts +0 -1
- package/src/app/lib/components/ui/typography/typography-blockquote.component.ts +3 -7
- package/src/app/lib/components/ui/typography/typography-h1.component.ts +3 -10
- package/src/app/lib/components/ui/typography/typography-h2.component.ts +3 -10
- package/src/app/lib/components/ui/typography/typography-h3.component.ts +3 -7
- package/src/app/lib/components/ui/typography/typography-h4.component.ts +3 -7
- package/src/app/lib/components/ui/typography/typography-inline-code.component.ts +4 -8
- package/src/app/lib/components/ui/typography/typography-large.component.ts +3 -9
- package/src/app/lib/components/ui/typography/typography-lead.component.ts +3 -7
- package/src/app/lib/components/ui/typography/typography-list.component.ts +3 -7
- package/src/app/lib/components/ui/typography/typography-muted.component.ts +3 -7
- package/src/app/lib/components/ui/typography/typography-p.component.ts +3 -7
- package/src/app/lib/components/ui/typography/typography-small.component.ts +3 -7
- package/src/app/lib/utils/accessibility/click-outside.directive.ts +1 -8
- package/src/app/lib/utils/accessibility/focus-management.service.ts +4 -15
- package/src/app/lib/utils/accessibility/focus-trap.directive.ts +32 -106
- package/src/app/lib/utils/accessibility/index.ts +16 -5
- package/src/app/lib/utils/accessibility/keyboard-navigation.directive.ts +5 -8
- package/src/app/lib/utils/accessibility/live-region.directive.ts +10 -13
- package/src/app/lib/utils/accessibility/touch-target.directive.ts +1 -8
- package/src/app/lib/utils/animation/animation.utils.ts +4 -7
- package/src/app/lib/utils/animation/index.ts +15 -5
- package/src/app/lib/utils/animation/presence.component.ts +1 -1
- package/src/app/lib/utils/animation/presence.directive.ts +2 -2
- package/src/app/lib/utils/positioning/index.ts +40 -18
- package/src/app/lib/components/ui/index.ts +0 -551
- package/src/app/lib/index.ts +0 -7
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { cn, Presence } from '@/lib/utils';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
afterNextRender,
|
|
4
|
+
ChangeDetectionStrategy,
|
|
5
|
+
Component,
|
|
6
|
+
computed,
|
|
7
|
+
effect,
|
|
8
|
+
ElementRef,
|
|
9
|
+
inject,
|
|
10
|
+
input,
|
|
11
|
+
OnDestroy,
|
|
12
12
|
} from '@angular/core';
|
|
13
13
|
import { MENUBAR_CONTEXT, MENUBAR_MENU_CONTEXT } from './menubar-context';
|
|
14
14
|
|
|
@@ -35,6 +35,7 @@ import { MENUBAR_CONTEXT, MENUBAR_MENU_CONTEXT } from './menubar-context';
|
|
|
35
35
|
</Presence>
|
|
36
36
|
`,
|
|
37
37
|
host: {
|
|
38
|
+
'attr.data-slot': '"menubar-content"',
|
|
38
39
|
class: 'contents',
|
|
39
40
|
'(document:click)': 'onDocumentClick($event)',
|
|
40
41
|
'(document:keydown.escape)': 'onEscapeKey()',
|
|
@@ -42,25 +43,44 @@ import { MENUBAR_CONTEXT, MENUBAR_MENU_CONTEXT } from './menubar-context';
|
|
|
42
43
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
43
44
|
})
|
|
44
45
|
export class MenubarContent implements OnDestroy {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
constructor() {
|
|
47
|
+
// Focus first item when menu opens
|
|
48
|
+
effect(() => {
|
|
49
|
+
if (this.menuContext.open()) {
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
this.updateMenuItems();
|
|
52
|
+
const focusedIdx = this.menuContext.focusedItemIndex();
|
|
53
|
+
if (focusedIdx >= 0 && this.menuItems[focusedIdx]) {
|
|
54
|
+
this.menuItems[focusedIdx].focus();
|
|
55
|
+
} else if (this.menuItems.length > 0) {
|
|
56
|
+
this.menuItems[0].focus();
|
|
57
|
+
this.menuContext.focusedItemIndex.set(0);
|
|
58
|
+
}
|
|
59
|
+
}, 0);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Initial menu items update (browser-only)
|
|
64
|
+
afterNextRender(() => {
|
|
65
|
+
this.updateMenuItems();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
48
68
|
|
|
49
69
|
/** Alignment */
|
|
50
70
|
readonly align = input<'start' | 'center' | 'end'>('start');
|
|
51
71
|
|
|
52
72
|
/** Side offset */
|
|
53
73
|
readonly sideOffset = input<number>(8);
|
|
54
|
-
|
|
55
74
|
/** Align offset */
|
|
56
75
|
readonly alignOffset = input<number>(-4);
|
|
57
76
|
|
|
58
77
|
/** Additional CSS classes */
|
|
59
78
|
readonly class = input<string>('');
|
|
60
79
|
|
|
61
|
-
private
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
private readonly _elementRef = inject(ElementRef);
|
|
81
|
+
|
|
82
|
+
protected readonly context = inject(MENUBAR_CONTEXT);
|
|
83
|
+
protected readonly menuContext = inject(MENUBAR_MENU_CONTEXT);
|
|
64
84
|
|
|
65
85
|
protected readonly computedClass = computed(() => {
|
|
66
86
|
const alignClasses = {
|
|
@@ -75,32 +95,13 @@ export class MenubarContent implements OnDestroy {
|
|
|
75
95
|
'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
|
76
96
|
'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
77
97
|
alignClasses[this.align()],
|
|
78
|
-
this.class()
|
|
98
|
+
this.class(),
|
|
79
99
|
);
|
|
80
100
|
});
|
|
81
101
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (this.menuContext.open()) {
|
|
86
|
-
setTimeout(() => {
|
|
87
|
-
this.updateMenuItems();
|
|
88
|
-
const focusedIdx = this.menuContext.focusedItemIndex();
|
|
89
|
-
if (focusedIdx >= 0 && this.menuItems[focusedIdx]) {
|
|
90
|
-
this.menuItems[focusedIdx].focus();
|
|
91
|
-
} else if (this.menuItems.length > 0) {
|
|
92
|
-
this.menuItems[0].focus();
|
|
93
|
-
this.menuContext.focusedItemIndex.set(0);
|
|
94
|
-
}
|
|
95
|
-
}, 0);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Initial menu items update (browser-only)
|
|
100
|
-
afterNextRender(() => {
|
|
101
|
-
this.updateMenuItems();
|
|
102
|
-
});
|
|
103
|
-
}
|
|
102
|
+
private menuItems: HTMLElement[] = [];
|
|
103
|
+
private typeaheadBuffer = '';
|
|
104
|
+
private typeaheadTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
104
105
|
|
|
105
106
|
ngOnDestroy(): void {
|
|
106
107
|
if (this.typeaheadTimeout) {
|
|
@@ -109,14 +110,15 @@ export class MenubarContent implements OnDestroy {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
private updateMenuItems(): void {
|
|
112
|
-
const content = this.
|
|
113
|
+
const content = this._elementRef.nativeElement.querySelector('[role="menu"]');
|
|
113
114
|
if (content) {
|
|
114
115
|
this.menuItems = Array.from(
|
|
115
|
-
content.querySelectorAll(
|
|
116
|
+
content.querySelectorAll(
|
|
117
|
+
'[role="menuitem"]:not([aria-disabled="true"]):not([data-disabled])',
|
|
118
|
+
),
|
|
116
119
|
);
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
|
-
|
|
120
122
|
protected onKeydown(event: KeyboardEvent): void {
|
|
121
123
|
this.updateMenuItems();
|
|
122
124
|
|
|
@@ -161,27 +163,22 @@ export class MenubarContent implements OnDestroy {
|
|
|
161
163
|
break;
|
|
162
164
|
}
|
|
163
165
|
}
|
|
164
|
-
|
|
165
166
|
private focusNext(): void {
|
|
166
167
|
const currentIndex = this.menuContext.focusedItemIndex();
|
|
167
168
|
const nextIndex = currentIndex < this.menuItems.length - 1 ? currentIndex + 1 : 0;
|
|
168
169
|
this.focusItem(nextIndex);
|
|
169
170
|
}
|
|
170
|
-
|
|
171
171
|
private focusPrevious(): void {
|
|
172
172
|
const currentIndex = this.menuContext.focusedItemIndex();
|
|
173
173
|
const prevIndex = currentIndex > 0 ? currentIndex - 1 : this.menuItems.length - 1;
|
|
174
174
|
this.focusItem(prevIndex);
|
|
175
175
|
}
|
|
176
|
-
|
|
177
176
|
private focusFirst(): void {
|
|
178
177
|
this.focusItem(0);
|
|
179
178
|
}
|
|
180
|
-
|
|
181
179
|
private focusLast(): void {
|
|
182
180
|
this.focusItem(this.menuItems.length - 1);
|
|
183
181
|
}
|
|
184
|
-
|
|
185
182
|
private focusItem(index: number): void {
|
|
186
183
|
if (index >= 0 && index < this.menuItems.length) {
|
|
187
184
|
// Update roving tabindex
|
|
@@ -192,7 +189,6 @@ export class MenubarContent implements OnDestroy {
|
|
|
192
189
|
this.menuContext.focusedItemIndex.set(index);
|
|
193
190
|
}
|
|
194
191
|
}
|
|
195
|
-
|
|
196
192
|
private handleTypeahead(key: string): void {
|
|
197
193
|
this.typeaheadBuffer += key.toLowerCase();
|
|
198
194
|
|
|
@@ -206,30 +202,27 @@ export class MenubarContent implements OnDestroy {
|
|
|
206
202
|
|
|
207
203
|
// Find first matching item
|
|
208
204
|
const matchIndex = this.menuItems.findIndex((item) =>
|
|
209
|
-
item.textContent?.toLowerCase().trim().startsWith(this.typeaheadBuffer)
|
|
205
|
+
item.textContent?.toLowerCase().trim().startsWith(this.typeaheadBuffer),
|
|
210
206
|
);
|
|
211
207
|
|
|
212
208
|
if (matchIndex >= 0) {
|
|
213
209
|
this.focusItem(matchIndex);
|
|
214
210
|
}
|
|
215
211
|
}
|
|
216
|
-
|
|
217
212
|
private close(): void {
|
|
218
213
|
this.menuContext.open.set(false);
|
|
219
214
|
this.context.activeMenu.set(null);
|
|
220
215
|
this.menuContext.focusedItemIndex.set(-1);
|
|
221
216
|
}
|
|
222
|
-
|
|
223
217
|
protected onDocumentClick(event: MouseEvent): void {
|
|
224
218
|
const target = event.target as HTMLElement;
|
|
225
|
-
const hostElement = this.
|
|
219
|
+
const hostElement = this._elementRef.nativeElement;
|
|
226
220
|
const parent = hostElement.closest('MenubarMenu');
|
|
227
221
|
|
|
228
222
|
if (parent && !parent.contains(target)) {
|
|
229
223
|
this.close();
|
|
230
224
|
}
|
|
231
225
|
}
|
|
232
|
-
|
|
233
226
|
protected onEscapeKey(): void {
|
|
234
227
|
this.close();
|
|
235
228
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { InjectionToken, type WritableSignal } from '@angular/core';
|
|
2
2
|
|
|
3
|
-
// ============================================================================
|
|
4
|
-
// Types
|
|
5
|
-
// ============================================================================
|
|
6
|
-
|
|
7
3
|
/**
|
|
8
4
|
* Direction for menubar layout
|
|
9
5
|
*/
|
|
@@ -14,10 +10,6 @@ export type MenubarDirection = 'ltr' | 'rtl';
|
|
|
14
10
|
*/
|
|
15
11
|
export type MenubarNavigationDirection = 'horizontal' | 'vertical';
|
|
16
12
|
|
|
17
|
-
// ============================================================================
|
|
18
|
-
// Context Interfaces
|
|
19
|
-
// ============================================================================
|
|
20
|
-
|
|
21
13
|
/**
|
|
22
14
|
* Context value for the Menubar component
|
|
23
15
|
*
|
|
@@ -60,4 +52,6 @@ export interface MenubarMenuContextValue {
|
|
|
60
52
|
focusedItemIndex: WritableSignal<number>;
|
|
61
53
|
}
|
|
62
54
|
|
|
63
|
-
export const MENUBAR_MENU_CONTEXT = new InjectionToken<MenubarMenuContextValue>(
|
|
55
|
+
export const MENUBAR_MENU_CONTEXT = new InjectionToken<MenubarMenuContextValue>(
|
|
56
|
+
'MENUBAR_MENU_CONTEXT',
|
|
57
|
+
);
|
|
@@ -11,6 +11,7 @@ import { MENUBAR_CONTEXT, MENUBAR_MENU_CONTEXT } from './menubar-context';
|
|
|
11
11
|
selector: 'MenubarItem',
|
|
12
12
|
template: `<ng-content />`,
|
|
13
13
|
host: {
|
|
14
|
+
'attr.data-slot': '"menubar-item"',
|
|
14
15
|
'[class]': 'computedClass()',
|
|
15
16
|
'[attr.role]': '"menuitem"',
|
|
16
17
|
'[attr.tabindex]': 'disabled() ? -1 : -1',
|
|
@@ -23,28 +24,26 @@ import { MENUBAR_CONTEXT, MENUBAR_MENU_CONTEXT } from './menubar-context';
|
|
|
23
24
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
24
25
|
})
|
|
25
26
|
export class MenubarItem {
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
/** Select event */
|
|
28
|
+
readonly onSelect = output<void>();
|
|
28
29
|
|
|
30
|
+
/** Additional CSS classes */
|
|
31
|
+
readonly class = input<string>('');
|
|
29
32
|
/** Whether the item is disabled */
|
|
30
33
|
readonly disabled = input<boolean>(false);
|
|
31
|
-
|
|
32
34
|
/** Whether the item is inset (extra padding) */
|
|
33
35
|
readonly inset = input<boolean>(false);
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
readonly
|
|
37
|
-
|
|
38
|
-
/** Select event */
|
|
39
|
-
readonly onSelect = output<void>();
|
|
37
|
+
private readonly _context = inject(MENUBAR_CONTEXT);
|
|
38
|
+
private readonly _menuContext = inject(MENUBAR_MENU_CONTEXT);
|
|
40
39
|
|
|
41
40
|
protected readonly computedClass = computed(() =>
|
|
42
41
|
cn(
|
|
43
|
-
|
|
42
|
+
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
44
43
|
this.inset() && 'pl-8',
|
|
45
44
|
!this.disabled() && 'cursor-pointer hover:bg-accent hover:text-accent-foreground',
|
|
46
|
-
this.class()
|
|
47
|
-
)
|
|
45
|
+
this.class(),
|
|
46
|
+
),
|
|
48
47
|
);
|
|
49
48
|
|
|
50
49
|
protected handleClick(event: Event): void {
|
|
@@ -53,8 +52,8 @@ export class MenubarItem {
|
|
|
53
52
|
return;
|
|
54
53
|
}
|
|
55
54
|
this.onSelect.emit();
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
55
|
+
this._menuContext.open.set(false);
|
|
56
|
+
this._context.activeMenu.set(null);
|
|
57
|
+
this._menuContext.focusedItemIndex.set(-1);
|
|
59
58
|
}
|
|
60
59
|
}
|
|
@@ -9,6 +9,7 @@ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/co
|
|
|
9
9
|
selector: 'MenubarLabel',
|
|
10
10
|
template: `<ng-content />`,
|
|
11
11
|
host: {
|
|
12
|
+
'attr.data-slot': '"menubar-label"',
|
|
12
13
|
'[class]': 'computedClass()',
|
|
13
14
|
},
|
|
14
15
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -21,10 +22,6 @@ export class MenubarLabel {
|
|
|
21
22
|
readonly class = input<string>('');
|
|
22
23
|
|
|
23
24
|
protected readonly computedClass = computed(() =>
|
|
24
|
-
cn(
|
|
25
|
-
'px-2 py-1.5 text-sm font-semibold',
|
|
26
|
-
this.inset() && 'pl-8',
|
|
27
|
-
this.class()
|
|
28
|
-
)
|
|
25
|
+
cn('px-2 py-1.5 text-sm font-semibold', this.inset() && 'pl-8', this.class()),
|
|
29
26
|
);
|
|
30
27
|
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
inject,
|
|
5
|
+
OnDestroy,
|
|
6
|
+
OnInit,
|
|
7
|
+
signal,
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
import {
|
|
10
|
+
MENUBAR_CONTEXT,
|
|
11
|
+
MENUBAR_MENU_CONTEXT,
|
|
12
|
+
type MenubarMenuContextValue,
|
|
13
|
+
} from './menubar-context';
|
|
3
14
|
|
|
4
15
|
let menuIdCounter = 0;
|
|
5
16
|
|
|
@@ -22,6 +33,7 @@ let menuIdCounter = 0;
|
|
|
22
33
|
},
|
|
23
34
|
],
|
|
24
35
|
host: {
|
|
36
|
+
'attr.data-slot': '"menubar-menu"',
|
|
25
37
|
class: 'relative',
|
|
26
38
|
},
|
|
27
39
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
InjectionToken,
|
|
5
|
+
signal,
|
|
6
|
+
type WritableSignal,
|
|
7
|
+
} from '@angular/core';
|
|
2
8
|
|
|
3
9
|
export interface MenubarRadioGroupContext {
|
|
4
10
|
value: WritableSignal<string>;
|
|
@@ -6,7 +12,7 @@ export interface MenubarRadioGroupContext {
|
|
|
6
12
|
}
|
|
7
13
|
|
|
8
14
|
export const MENUBAR_RADIO_GROUP_CONTEXT = new InjectionToken<MenubarRadioGroupContext>(
|
|
9
|
-
'MENUBAR_RADIO_GROUP_CONTEXT'
|
|
15
|
+
'MENUBAR_RADIO_GROUP_CONTEXT',
|
|
10
16
|
);
|
|
11
17
|
|
|
12
18
|
/**
|
|
@@ -29,6 +35,7 @@ export const MENUBAR_RADIO_GROUP_CONTEXT = new InjectionToken<MenubarRadioGroupC
|
|
|
29
35
|
},
|
|
30
36
|
],
|
|
31
37
|
host: {
|
|
38
|
+
'attr.data-slot': '"menubar-radio-group"',
|
|
32
39
|
'[attr.role]': '"group"',
|
|
33
40
|
},
|
|
34
41
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -19,6 +19,7 @@ import { MENUBAR_RADIO_GROUP_CONTEXT } from './menubar-radio-group.component';
|
|
|
19
19
|
<ng-content />
|
|
20
20
|
`,
|
|
21
21
|
host: {
|
|
22
|
+
'attr.data-slot': '"menubar-radio-item"',
|
|
22
23
|
'[class]': 'computedClass()',
|
|
23
24
|
'[attr.role]': '"menuitemradio"',
|
|
24
25
|
'[attr.aria-checked]': 'isSelected()',
|
|
@@ -30,37 +31,36 @@ import { MENUBAR_RADIO_GROUP_CONTEXT } from './menubar-radio-group.component';
|
|
|
30
31
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
31
32
|
})
|
|
32
33
|
export class MenubarRadioItem {
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
/** Select event */
|
|
35
|
+
readonly onSelect = output<void>();
|
|
35
36
|
|
|
36
37
|
/** The value of this radio item */
|
|
37
38
|
readonly value = input.required<string>();
|
|
38
39
|
|
|
39
|
-
/** Whether the item is disabled */
|
|
40
|
-
readonly disabled = input<boolean>(false);
|
|
41
|
-
|
|
42
40
|
/** Additional CSS classes */
|
|
43
41
|
readonly class = input<string>('');
|
|
42
|
+
/** Whether the item is disabled */
|
|
43
|
+
readonly disabled = input<boolean>(false);
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
readonly onSelect = output<void>();
|
|
47
|
-
|
|
48
|
-
protected readonly isSelected = computed(() => this.radioGroupContext.value() === this.value());
|
|
45
|
+
private readonly _radioGroupContext = inject(MENUBAR_RADIO_GROUP_CONTEXT);
|
|
49
46
|
|
|
47
|
+
protected readonly isSelected = computed(() => this._radioGroupContext.value() === this.value());
|
|
50
48
|
protected readonly computedClass = computed(() =>
|
|
51
49
|
cn(
|
|
52
|
-
|
|
50
|
+
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
53
51
|
!this.disabled() && 'cursor-pointer hover:bg-accent hover:text-accent-foreground',
|
|
54
|
-
this.class()
|
|
55
|
-
)
|
|
52
|
+
this.class(),
|
|
53
|
+
),
|
|
56
54
|
);
|
|
57
55
|
|
|
56
|
+
protected readonly CircleIcon = Circle;
|
|
57
|
+
|
|
58
58
|
protected handleClick(event: Event): void {
|
|
59
59
|
if (this.disabled()) {
|
|
60
60
|
event.preventDefault();
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
this.
|
|
63
|
+
this._radioGroupContext.setValue(this.value());
|
|
64
64
|
this.onSelect.emit();
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -9,6 +9,7 @@ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/co
|
|
|
9
9
|
selector: 'MenubarSeparator',
|
|
10
10
|
template: ``,
|
|
11
11
|
host: {
|
|
12
|
+
'attr.data-slot': '"menubar-separator"',
|
|
12
13
|
'[class]': 'computedClass()',
|
|
13
14
|
'[attr.role]': '"separator"',
|
|
14
15
|
},
|
|
@@ -18,7 +19,5 @@ export class MenubarSeparator {
|
|
|
18
19
|
/** Additional CSS classes */
|
|
19
20
|
readonly class = input<string>('');
|
|
20
21
|
|
|
21
|
-
protected readonly computedClass = computed(() =>
|
|
22
|
-
cn('-mx-1 my-1 h-px bg-muted', this.class())
|
|
23
|
-
);
|
|
22
|
+
protected readonly computedClass = computed(() => cn('-mx-1 my-1 h-px bg-muted', this.class()));
|
|
24
23
|
}
|
|
@@ -9,6 +9,7 @@ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/co
|
|
|
9
9
|
selector: 'MenubarShortcut',
|
|
10
10
|
template: `<ng-content />`,
|
|
11
11
|
host: {
|
|
12
|
+
'attr.data-slot': '"menubar-shortcut"',
|
|
12
13
|
'[class]': 'computedClass()',
|
|
13
14
|
},
|
|
14
15
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -18,6 +19,6 @@ export class MenubarShortcut {
|
|
|
18
19
|
readonly class = input<string>('');
|
|
19
20
|
|
|
20
21
|
protected readonly computedClass = computed(() =>
|
|
21
|
-
cn('ml-auto text-xs tracking-widest text-muted-foreground', this.class())
|
|
22
|
+
cn('ml-auto text-xs tracking-widest text-muted-foreground', this.class()),
|
|
22
23
|
);
|
|
23
24
|
}
|
|
@@ -21,6 +21,7 @@ import { MENUBAR_SUB_CONTEXT } from './menubar-sub.component';
|
|
|
21
21
|
</Presence>
|
|
22
22
|
`,
|
|
23
23
|
host: {
|
|
24
|
+
'attr.data-slot': '"menubar-sub-content"',
|
|
24
25
|
class: 'contents',
|
|
25
26
|
'(mouseenter)': 'onMouseEnter()',
|
|
26
27
|
'(mouseleave)': 'onMouseLeave()',
|
|
@@ -28,23 +29,22 @@ import { MENUBAR_SUB_CONTEXT } from './menubar-sub.component';
|
|
|
28
29
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
29
30
|
})
|
|
30
31
|
export class MenubarSubContent {
|
|
31
|
-
protected readonly subContext = inject(MENUBAR_SUB_CONTEXT);
|
|
32
|
-
|
|
33
32
|
/** Additional CSS classes */
|
|
34
33
|
readonly class = input<string>('');
|
|
35
34
|
|
|
35
|
+
protected readonly subContext = inject(MENUBAR_SUB_CONTEXT);
|
|
36
|
+
|
|
36
37
|
protected readonly computedClass = computed(() =>
|
|
37
38
|
cn(
|
|
38
39
|
'absolute left-full top-0 z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg',
|
|
39
40
|
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
40
|
-
this.class()
|
|
41
|
-
)
|
|
41
|
+
this.class(),
|
|
42
|
+
),
|
|
42
43
|
);
|
|
43
44
|
|
|
44
45
|
protected onMouseEnter(): void {
|
|
45
46
|
this.subContext.open.set(true);
|
|
46
47
|
}
|
|
47
|
-
|
|
48
48
|
protected onMouseLeave(): void {
|
|
49
49
|
this.subContext.open.set(false);
|
|
50
50
|
}
|
|
@@ -15,6 +15,7 @@ import { MENUBAR_SUB_CONTEXT } from './menubar-sub.component';
|
|
|
15
15
|
<lucide-icon [img]="ChevronRightIcon" class="ml-auto h-4 w-4" />
|
|
16
16
|
`,
|
|
17
17
|
host: {
|
|
18
|
+
'attr.data-slot': '"menubar-sub-trigger"',
|
|
18
19
|
'[class]': 'computedClass()',
|
|
19
20
|
'[attr.data-state]': 'subContext.open() ? "open" : "closed"',
|
|
20
21
|
'(mouseenter)': 'onMouseEnter()',
|
|
@@ -23,27 +24,27 @@ import { MENUBAR_SUB_CONTEXT } from './menubar-sub.component';
|
|
|
23
24
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
24
25
|
})
|
|
25
26
|
export class MenubarSubTrigger {
|
|
26
|
-
protected readonly subContext = inject(MENUBAR_SUB_CONTEXT);
|
|
27
|
-
protected readonly ChevronRightIcon = ChevronRight;
|
|
28
|
-
|
|
29
27
|
/** Whether the trigger is inset */
|
|
30
28
|
readonly inset = input<boolean>(false);
|
|
31
29
|
|
|
32
30
|
/** Additional CSS classes */
|
|
33
31
|
readonly class = input<string>('');
|
|
34
32
|
|
|
33
|
+
protected readonly subContext = inject(MENUBAR_SUB_CONTEXT);
|
|
34
|
+
|
|
35
35
|
protected readonly computedClass = computed(() =>
|
|
36
36
|
cn(
|
|
37
37
|
'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',
|
|
38
38
|
this.inset() && 'pl-8',
|
|
39
|
-
this.class()
|
|
40
|
-
)
|
|
39
|
+
this.class(),
|
|
40
|
+
),
|
|
41
41
|
);
|
|
42
42
|
|
|
43
|
+
protected readonly ChevronRightIcon = ChevronRight;
|
|
44
|
+
|
|
43
45
|
protected onMouseEnter(): void {
|
|
44
46
|
this.subContext.open.set(true);
|
|
45
47
|
}
|
|
46
|
-
|
|
47
48
|
protected onMouseLeave(): void {
|
|
48
49
|
// Keep open for mouse to move to sub-content
|
|
49
50
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
InjectionToken,
|
|
5
|
+
signal,
|
|
6
|
+
type WritableSignal,
|
|
7
|
+
} from '@angular/core';
|
|
2
8
|
|
|
3
9
|
export interface MenubarSubContext {
|
|
4
10
|
open: WritableSignal<boolean>;
|
|
@@ -22,6 +28,7 @@ export const MENUBAR_SUB_CONTEXT = new InjectionToken<MenubarSubContext>('MENUBA
|
|
|
22
28
|
},
|
|
23
29
|
],
|
|
24
30
|
host: {
|
|
31
|
+
'attr.data-slot': '"menubar-sub"',
|
|
25
32
|
class: 'relative',
|
|
26
33
|
},
|
|
27
34
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { cn } from '@/lib/utils';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Component,
|
|
5
|
+
computed,
|
|
6
|
+
effect,
|
|
7
|
+
ElementRef,
|
|
8
|
+
inject,
|
|
9
|
+
input,
|
|
10
|
+
} from '@angular/core';
|
|
3
11
|
import { MENUBAR_CONTEXT, MENUBAR_MENU_CONTEXT } from './menubar-context';
|
|
4
12
|
|
|
5
13
|
/**
|
|
@@ -11,6 +19,7 @@ import { MENUBAR_CONTEXT, MENUBAR_MENU_CONTEXT } from './menubar-context';
|
|
|
11
19
|
selector: 'MenubarTrigger',
|
|
12
20
|
template: `<ng-content />`,
|
|
13
21
|
host: {
|
|
22
|
+
'attr.data-slot': '"menubar-trigger"',
|
|
14
23
|
'[class]': 'computedClass()',
|
|
15
24
|
'[attr.role]': '"menuitem"',
|
|
16
25
|
'[attr.tabindex]': 'isFocused() ? 0 : -1',
|
|
@@ -24,37 +33,37 @@ import { MENUBAR_CONTEXT, MENUBAR_MENU_CONTEXT } from './menubar-context';
|
|
|
24
33
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
25
34
|
})
|
|
26
35
|
export class MenubarTrigger {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
constructor() {
|
|
37
|
+
// Focus this trigger when it becomes the focused menu
|
|
38
|
+
effect(() => {
|
|
39
|
+
if (this.isFocused()) {
|
|
40
|
+
this._elementRef.nativeElement.focus();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
30
44
|
|
|
31
45
|
/** Additional CSS classes */
|
|
32
46
|
readonly class = input<string>('');
|
|
33
47
|
|
|
48
|
+
private readonly _elementRef = inject(ElementRef);
|
|
49
|
+
|
|
50
|
+
protected readonly context = inject(MENUBAR_CONTEXT);
|
|
51
|
+
protected readonly menuContext = inject(MENUBAR_MENU_CONTEXT);
|
|
52
|
+
|
|
34
53
|
protected readonly isFocused = computed(() => {
|
|
35
54
|
const menuIds = this.context.menuIds();
|
|
36
55
|
const focusedIdx = this.context.focusedMenuIndex();
|
|
37
56
|
return menuIds[focusedIdx] === this.menuContext.menuId;
|
|
38
57
|
});
|
|
39
|
-
|
|
40
58
|
protected readonly computedClass = computed(() =>
|
|
41
59
|
cn(
|
|
42
60
|
'flex cursor-default select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',
|
|
43
|
-
this.class()
|
|
44
|
-
)
|
|
61
|
+
this.class(),
|
|
62
|
+
),
|
|
45
63
|
);
|
|
46
64
|
|
|
47
|
-
constructor() {
|
|
48
|
-
// Focus this trigger when it becomes the focused menu
|
|
49
|
-
effect(() => {
|
|
50
|
-
if (this.isFocused()) {
|
|
51
|
-
this.elementRef.nativeElement.focus();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
65
|
protected toggle(): void {
|
|
57
|
-
this.menuContext.open.update(v => !v);
|
|
66
|
+
this.menuContext.open.update((v) => !v);
|
|
58
67
|
if (this.menuContext.open()) {
|
|
59
68
|
this.context.activeMenu.set(this.menuContext.menuId);
|
|
60
69
|
this.menuContext.focusedItemIndex.set(0);
|
|
@@ -63,7 +72,6 @@ export class MenubarTrigger {
|
|
|
63
72
|
this.menuContext.focusedItemIndex.set(-1);
|
|
64
73
|
}
|
|
65
74
|
}
|
|
66
|
-
|
|
67
75
|
protected onMouseEnter(): void {
|
|
68
76
|
// If another menu is already open, open this one on hover
|
|
69
77
|
const activeMenu = this.context.activeMenu();
|
|
@@ -73,7 +81,6 @@ export class MenubarTrigger {
|
|
|
73
81
|
this.menuContext.focusedItemIndex.set(0);
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
|
-
|
|
77
84
|
protected onKeydown(event: KeyboardEvent): void {
|
|
78
85
|
switch (event.key) {
|
|
79
86
|
case 'ArrowRight':
|
|
@@ -114,13 +121,11 @@ export class MenubarTrigger {
|
|
|
114
121
|
break;
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
|
-
|
|
118
124
|
private closeCurrentMenu(): void {
|
|
119
125
|
// Close current menu by finding it through activeMenu
|
|
120
126
|
this.menuContext.open.set(false);
|
|
121
127
|
this.menuContext.focusedItemIndex.set(-1);
|
|
122
128
|
}
|
|
123
|
-
|
|
124
129
|
private openFocusedMenu(): void {
|
|
125
130
|
const menuIds = this.context.menuIds();
|
|
126
131
|
const focusedIdx = this.context.focusedMenuIndex();
|