@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,16 +1,16 @@
|
|
|
1
1
|
import { cn } from '@/lib/utils';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
afterNextRender,
|
|
4
|
+
ChangeDetectionStrategy,
|
|
5
|
+
Component,
|
|
6
|
+
computed,
|
|
7
|
+
effect,
|
|
8
|
+
ElementRef,
|
|
9
|
+
inject,
|
|
10
|
+
input,
|
|
11
|
+
OnDestroy,
|
|
12
|
+
OnInit,
|
|
13
|
+
output,
|
|
14
14
|
} from '@angular/core';
|
|
15
15
|
import { COMMAND_CONTEXT } from './command-context';
|
|
16
16
|
|
|
@@ -25,6 +25,7 @@ let itemIndexCounter = 0;
|
|
|
25
25
|
selector: 'CommandItem',
|
|
26
26
|
template: `<ng-content />`,
|
|
27
27
|
host: {
|
|
28
|
+
'attr.data-slot': '"command-item"',
|
|
28
29
|
'[class]': 'computedClass()',
|
|
29
30
|
'[attr.role]': '"option"',
|
|
30
31
|
'[attr.id]': 'itemId',
|
|
@@ -40,106 +41,93 @@ let itemIndexCounter = 0;
|
|
|
40
41
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
41
42
|
})
|
|
42
43
|
export class CommandItem implements OnInit, OnDestroy {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
constructor() {
|
|
45
|
+
// Scroll into view when focused
|
|
46
|
+
effect(() => {
|
|
47
|
+
if (this.isFocused()) {
|
|
48
|
+
this._elementRef.nativeElement.scrollIntoView({ block: 'nearest' });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
// Update local index after render (browser-only)
|
|
53
|
+
afterNextRender(() => {
|
|
54
|
+
this.updateLocalIndex();
|
|
55
|
+
this.context.itemCount.update((c) => c + 1);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Select event emitted when item is clicked */
|
|
60
|
+
readonly onSelect = output<string>();
|
|
48
61
|
|
|
49
62
|
/** Unique value for this item */
|
|
50
63
|
readonly value = input<string>('');
|
|
51
|
-
|
|
52
64
|
/** Keywords for search filtering */
|
|
53
65
|
readonly keywords = input<string[]>([]);
|
|
54
|
-
|
|
55
66
|
/** Whether the item is disabled */
|
|
56
67
|
readonly disabled = input<boolean>(false);
|
|
57
|
-
|
|
58
68
|
/** Additional CSS classes */
|
|
59
69
|
readonly class = input<string>('');
|
|
60
70
|
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
private readonly _elementRef = inject(ElementRef);
|
|
72
|
+
|
|
73
|
+
protected readonly context = inject(COMMAND_CONTEXT);
|
|
63
74
|
|
|
64
75
|
/** Whether item matches current search filter */
|
|
65
76
|
protected readonly isVisible = computed(() => {
|
|
66
77
|
return this.context.shouldShowItem(this.value(), this.keywords());
|
|
67
78
|
});
|
|
68
|
-
|
|
69
79
|
/** Get visible index among shown items */
|
|
70
80
|
protected readonly visibleIndex = computed(() => {
|
|
71
81
|
if (!this.isVisible()) return -1;
|
|
72
82
|
|
|
73
|
-
const parent = this.
|
|
83
|
+
const parent = this._elementRef.nativeElement.closest('CommandList, [role="listbox"]');
|
|
74
84
|
if (parent) {
|
|
75
|
-
const visibleItems = Array.from(
|
|
76
|
-
|
|
77
|
-
);
|
|
78
|
-
return visibleItems.indexOf(this.elementRef.nativeElement);
|
|
85
|
+
const visibleItems = Array.from(parent.querySelectorAll('CommandItem:not([hidden])'));
|
|
86
|
+
return visibleItems.indexOf(this._elementRef.nativeElement);
|
|
79
87
|
}
|
|
80
88
|
return this.localIndex;
|
|
81
89
|
});
|
|
82
|
-
|
|
83
90
|
protected readonly isFocused = computed(() => {
|
|
84
91
|
const focusedIdx = this.context.focusedIndex();
|
|
85
92
|
return this.isVisible() && this.getLocalIndex() === focusedIdx;
|
|
86
93
|
});
|
|
87
|
-
|
|
88
|
-
private localIndex = -1;
|
|
89
|
-
|
|
90
94
|
protected readonly computedClass = computed(() =>
|
|
91
95
|
cn(
|
|
92
|
-
|
|
96
|
+
'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[selected]:bg-accent data-[selected]:text-accent-foreground data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0 [&>lucide-icon]:size-4 [&>lucide-icon]:shrink-0',
|
|
93
97
|
!this.disabled() && 'cursor-pointer hover:bg-accent hover:text-accent-foreground',
|
|
94
|
-
this.class()
|
|
95
|
-
)
|
|
98
|
+
this.class(),
|
|
99
|
+
),
|
|
96
100
|
);
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (this.isFocused()) {
|
|
102
|
-
this.elementRef.nativeElement.scrollIntoView({ block: 'nearest' });
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Update local index after render (browser-only)
|
|
107
|
-
afterNextRender(() => {
|
|
108
|
-
this.updateLocalIndex();
|
|
109
|
-
this.context.itemCount.update(c => c + 1);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
102
|
+
readonly itemIndex = itemIndexCounter++;
|
|
103
|
+
readonly itemId = `command-item-${this.itemIndex}`;
|
|
104
|
+
private localIndex = -1;
|
|
112
105
|
|
|
113
106
|
ngOnInit(): void {
|
|
114
107
|
this.context.registerItem(this.value());
|
|
115
108
|
}
|
|
116
|
-
|
|
117
109
|
ngOnDestroy(): void {
|
|
118
110
|
this.context.unregisterItem(this.value());
|
|
119
|
-
this.context.itemCount.update(c => Math.max(0, c - 1));
|
|
111
|
+
this.context.itemCount.update((c) => Math.max(0, c - 1));
|
|
120
112
|
}
|
|
121
113
|
|
|
122
114
|
private updateLocalIndex(): void {
|
|
123
115
|
// Find our position among sibling command items
|
|
124
|
-
const parent = this.
|
|
116
|
+
const parent = this._elementRef.nativeElement.closest('CommandList, [role="listbox"]');
|
|
125
117
|
if (parent) {
|
|
126
118
|
const items = Array.from(parent.querySelectorAll('CommandItem'));
|
|
127
|
-
this.localIndex = items.indexOf(this.
|
|
119
|
+
this.localIndex = items.indexOf(this._elementRef.nativeElement);
|
|
128
120
|
}
|
|
129
121
|
}
|
|
130
|
-
|
|
131
122
|
private getLocalIndex(): number {
|
|
132
123
|
// Dynamically compute index based on visible DOM position
|
|
133
|
-
const parent = this.
|
|
124
|
+
const parent = this._elementRef.nativeElement.closest('CommandList, [role="listbox"]');
|
|
134
125
|
if (parent) {
|
|
135
|
-
const visibleItems = Array.from(
|
|
136
|
-
|
|
137
|
-
);
|
|
138
|
-
return visibleItems.indexOf(this.elementRef.nativeElement);
|
|
126
|
+
const visibleItems = Array.from(parent.querySelectorAll('CommandItem:not([hidden])'));
|
|
127
|
+
return visibleItems.indexOf(this._elementRef.nativeElement);
|
|
139
128
|
}
|
|
140
129
|
return this.localIndex;
|
|
141
130
|
}
|
|
142
|
-
|
|
143
131
|
protected handleClick(): void {
|
|
144
132
|
if (this.disabled() || !this.isVisible()) return;
|
|
145
133
|
this.context.selectedValue.set(this.value());
|
|
@@ -11,20 +11,21 @@ import { COMMAND_CONTEXT } from './command-context';
|
|
|
11
11
|
selector: 'CommandList',
|
|
12
12
|
template: `<ng-content />`,
|
|
13
13
|
host: {
|
|
14
|
+
'attr.data-slot': '"command-list"',
|
|
14
15
|
'[class]': 'computedClass()',
|
|
15
16
|
'[attr.id]': 'context.listId',
|
|
16
|
-
|
|
17
|
+
role: 'listbox',
|
|
17
18
|
'[attr.aria-label]': '"Command suggestions"',
|
|
18
19
|
},
|
|
19
20
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
20
21
|
})
|
|
21
22
|
export class CommandList {
|
|
22
|
-
protected readonly context = inject(COMMAND_CONTEXT);
|
|
23
|
-
|
|
24
23
|
/** Additional CSS classes */
|
|
25
24
|
readonly class = input<string>('');
|
|
26
25
|
|
|
26
|
+
protected readonly context = inject(COMMAND_CONTEXT);
|
|
27
|
+
|
|
27
28
|
protected readonly computedClass = computed(() =>
|
|
28
|
-
cn('max-h-[300px] overflow-y-auto overflow-x-hidden', this.class())
|
|
29
|
+
cn('max-h-[300px] overflow-y-auto overflow-x-hidden', this.class()),
|
|
29
30
|
);
|
|
30
31
|
}
|
|
@@ -9,6 +9,7 @@ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/co
|
|
|
9
9
|
selector: 'CommandSeparator',
|
|
10
10
|
template: ``,
|
|
11
11
|
host: {
|
|
12
|
+
'attr.data-slot': '"command-separator"',
|
|
12
13
|
'[class]': 'computedClass()',
|
|
13
14
|
},
|
|
14
15
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -17,7 +18,5 @@ export class CommandSeparator {
|
|
|
17
18
|
/** Additional CSS classes */
|
|
18
19
|
readonly class = input<string>('');
|
|
19
20
|
|
|
20
|
-
protected readonly computedClass = computed(() =>
|
|
21
|
-
cn('-mx-1 h-px bg-border', this.class())
|
|
22
|
-
);
|
|
21
|
+
protected readonly computedClass = computed(() => cn('-mx-1 h-px bg-border', this.class()));
|
|
23
22
|
}
|
|
@@ -9,6 +9,7 @@ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/co
|
|
|
9
9
|
selector: 'CommandShortcut',
|
|
10
10
|
template: `<ng-content />`,
|
|
11
11
|
host: {
|
|
12
|
+
'attr.data-slot': '"command-shortcut"',
|
|
12
13
|
'[class]': 'computedClass()',
|
|
13
14
|
},
|
|
14
15
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -18,6 +19,6 @@ export class CommandShortcut {
|
|
|
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
|
}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { cn } from '@/lib/utils';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Component,
|
|
5
|
+
computed,
|
|
6
|
+
forwardRef,
|
|
7
|
+
input,
|
|
8
|
+
signal,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import {
|
|
11
|
+
COMMAND_CONTEXT,
|
|
12
|
+
type CommandContextValue,
|
|
13
|
+
type CommandFilterFunction,
|
|
14
|
+
} from './command-context';
|
|
4
15
|
|
|
5
16
|
let commandIdCounter = 0;
|
|
6
17
|
|
|
7
18
|
/**
|
|
8
19
|
* Default filter function for command items.
|
|
9
20
|
*/
|
|
10
|
-
const defaultFilterFn: CommandFilterFunction = (
|
|
21
|
+
const defaultFilterFn: CommandFilterFunction = (
|
|
22
|
+
value: string,
|
|
23
|
+
search: string,
|
|
24
|
+
keywords?: string[],
|
|
25
|
+
): number => {
|
|
11
26
|
if (!search.trim()) return 1;
|
|
12
27
|
|
|
13
28
|
const extendedValue = keywords ? `${value} ${keywords.join(' ')}` : value;
|
|
@@ -48,6 +63,7 @@ const defaultFilterFn: CommandFilterFunction = (value: string, search: string, k
|
|
|
48
63
|
},
|
|
49
64
|
],
|
|
50
65
|
host: {
|
|
66
|
+
'attr.data-slot': '"command"',
|
|
51
67
|
'[class]': 'computedClass()',
|
|
52
68
|
},
|
|
53
69
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -59,47 +75,42 @@ export class Command implements CommandContextValue {
|
|
|
59
75
|
/** Custom filter function for search */
|
|
60
76
|
readonly filter = input<CommandFilterFunction | undefined>(undefined);
|
|
61
77
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
readonly filterFunction = computed(() => {
|
|
79
|
+
return this.filter() ?? defaultFilterFn;
|
|
80
|
+
});
|
|
81
|
+
protected readonly computedClass = computed(() =>
|
|
82
|
+
cn(
|
|
83
|
+
'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
|
|
84
|
+
this.class(),
|
|
85
|
+
),
|
|
86
|
+
);
|
|
65
87
|
|
|
66
88
|
readonly search = signal('');
|
|
67
89
|
readonly selectedValue = signal('');
|
|
68
|
-
readonly focusedIndex = signal(
|
|
90
|
+
readonly focusedIndex = signal(0);
|
|
69
91
|
readonly itemCount = signal(0);
|
|
70
92
|
readonly visibleItemCount = signal(0);
|
|
93
|
+
|
|
94
|
+
// CommandContextValue implementation
|
|
95
|
+
private readonly _id = commandIdCounter++;
|
|
96
|
+
private readonly _items: string[] = [];
|
|
71
97
|
readonly listId = `command-list-${this._id}`;
|
|
72
98
|
readonly inputId = `command-input-${this._id}`;
|
|
73
|
-
|
|
74
|
-
readonly filterFunction = computed(() => {
|
|
75
|
-
return this.filter() ?? defaultFilterFn;
|
|
76
|
-
});
|
|
77
|
-
|
|
78
99
|
registerItem = (value: string) => {
|
|
79
100
|
if (!this._items.includes(value)) {
|
|
80
101
|
this._items.push(value);
|
|
81
102
|
}
|
|
82
103
|
};
|
|
83
|
-
|
|
84
104
|
unregisterItem = (value: string) => {
|
|
85
105
|
const index = this._items.indexOf(value);
|
|
86
106
|
if (index > -1) {
|
|
87
107
|
this._items.splice(index, 1);
|
|
88
108
|
}
|
|
89
109
|
};
|
|
90
|
-
|
|
91
110
|
getItems = () => this._items;
|
|
92
|
-
|
|
93
111
|
shouldShowItem = (value: string, keywords?: string[]): boolean => {
|
|
94
112
|
const searchValue = this.search();
|
|
95
113
|
if (!searchValue) return true;
|
|
96
114
|
return this.filterFunction()(value, searchValue, keywords) > 0;
|
|
97
115
|
};
|
|
98
|
-
|
|
99
|
-
protected readonly computedClass = computed(() =>
|
|
100
|
-
cn(
|
|
101
|
-
'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
|
|
102
|
-
this.class()
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
116
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { cn } from '@/lib/utils';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Component,
|
|
5
|
+
computed,
|
|
6
|
+
inject,
|
|
7
|
+
input,
|
|
8
|
+
model,
|
|
9
|
+
output,
|
|
10
|
+
} from '@angular/core';
|
|
3
11
|
import { Check, LucideAngularModule } from 'lucide-angular';
|
|
4
12
|
import { CONTEXT_MENU_CONTEXT } from './context-menu-context';
|
|
5
13
|
|
|
@@ -19,6 +27,7 @@ import { CONTEXT_MENU_CONTEXT } from './context-menu-context';
|
|
|
19
27
|
<ng-content />
|
|
20
28
|
`,
|
|
21
29
|
host: {
|
|
30
|
+
'attr.data-slot': '"context-menu-checkbox-item"',
|
|
22
31
|
'[class]': 'computedClass()',
|
|
23
32
|
'[attr.role]': '"menuitemcheckbox"',
|
|
24
33
|
'[attr.aria-checked]': 'checked()',
|
|
@@ -33,29 +42,29 @@ import { CONTEXT_MENU_CONTEXT } from './context-menu-context';
|
|
|
33
42
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
34
43
|
})
|
|
35
44
|
export class ContextMenuCheckboxItem {
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
/** Checked change event */
|
|
46
|
+
readonly onCheckedChange = output<boolean>();
|
|
38
47
|
|
|
39
48
|
/** Whether the checkbox is checked */
|
|
40
49
|
readonly checked = model<boolean>(false);
|
|
41
50
|
|
|
42
|
-
/** Whether the item is disabled */
|
|
43
|
-
readonly disabled = input<boolean>(false);
|
|
44
|
-
|
|
45
51
|
/** Additional CSS classes */
|
|
46
52
|
readonly class = input<string>('');
|
|
53
|
+
/** Whether the item is disabled */
|
|
54
|
+
readonly disabled = input<boolean>(false);
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
readonly onCheckedChange = output<boolean>();
|
|
56
|
+
private readonly _context = inject(CONTEXT_MENU_CONTEXT);
|
|
50
57
|
|
|
51
58
|
protected readonly computedClass = computed(() =>
|
|
52
59
|
cn(
|
|
53
|
-
|
|
60
|
+
'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',
|
|
54
61
|
!this.disabled() && 'cursor-pointer hover:bg-accent hover:text-accent-foreground',
|
|
55
|
-
this.class()
|
|
56
|
-
)
|
|
62
|
+
this.class(),
|
|
63
|
+
),
|
|
57
64
|
);
|
|
58
65
|
|
|
66
|
+
protected readonly CheckIcon = Check;
|
|
67
|
+
|
|
59
68
|
protected handleClick(event: Event): void {
|
|
60
69
|
if (this.disabled()) {
|
|
61
70
|
event.preventDefault();
|
|
@@ -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 { CONTEXT_MENU_CONTEXT } from './context-menu-context';
|
|
14
14
|
|
|
@@ -38,6 +38,7 @@ import { CONTEXT_MENU_CONTEXT } from './context-menu-context';
|
|
|
38
38
|
</Presence>
|
|
39
39
|
`,
|
|
40
40
|
host: {
|
|
41
|
+
'attr.data-slot': '"context-menu-content"',
|
|
41
42
|
class: 'contents',
|
|
42
43
|
'(document:click)': 'onDocumentClick()',
|
|
43
44
|
'(document:keydown.escape)': 'onEscapeKey()',
|
|
@@ -46,26 +47,6 @@ import { CONTEXT_MENU_CONTEXT } from './context-menu-context';
|
|
|
46
47
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
47
48
|
})
|
|
48
49
|
export class ContextMenuContent implements OnDestroy {
|
|
49
|
-
protected readonly context = inject(CONTEXT_MENU_CONTEXT);
|
|
50
|
-
private readonly elementRef = inject(ElementRef);
|
|
51
|
-
|
|
52
|
-
/** Additional CSS classes */
|
|
53
|
-
readonly class = input<string>('');
|
|
54
|
-
|
|
55
|
-
private menuItems: HTMLElement[] = [];
|
|
56
|
-
private typeaheadBuffer = '';
|
|
57
|
-
private typeaheadTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
58
|
-
|
|
59
|
-
protected readonly computedClass = computed(() =>
|
|
60
|
-
cn(
|
|
61
|
-
'z-50 min-w-[12rem] overflow-hidden rounded-xl border bg-popover p-2 text-popover-foreground shadow-lg',
|
|
62
|
-
'data-[state=open]:animate-in data-[state=closed]:animate-out',
|
|
63
|
-
'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
|
64
|
-
'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
65
|
-
this.class()
|
|
66
|
-
)
|
|
67
|
-
);
|
|
68
|
-
|
|
69
50
|
constructor() {
|
|
70
51
|
// Focus first item when menu opens
|
|
71
52
|
effect(() => {
|
|
@@ -89,6 +70,27 @@ export class ContextMenuContent implements OnDestroy {
|
|
|
89
70
|
});
|
|
90
71
|
}
|
|
91
72
|
|
|
73
|
+
/** Additional CSS classes */
|
|
74
|
+
readonly class = input<string>('');
|
|
75
|
+
|
|
76
|
+
private readonly _elementRef = inject(ElementRef);
|
|
77
|
+
|
|
78
|
+
protected readonly context = inject(CONTEXT_MENU_CONTEXT);
|
|
79
|
+
|
|
80
|
+
protected readonly computedClass = computed(() =>
|
|
81
|
+
cn(
|
|
82
|
+
'z-50 min-w-[12rem] overflow-hidden rounded-xl border bg-popover p-2 text-popover-foreground shadow-lg',
|
|
83
|
+
'data-[state=open]:animate-in data-[state=closed]:animate-out',
|
|
84
|
+
'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
|
85
|
+
'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
86
|
+
this.class(),
|
|
87
|
+
),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
private menuItems: HTMLElement[] = [];
|
|
91
|
+
private typeaheadBuffer = '';
|
|
92
|
+
private typeaheadTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
93
|
+
|
|
92
94
|
ngOnDestroy(): void {
|
|
93
95
|
if (this.typeaheadTimeout) {
|
|
94
96
|
clearTimeout(this.typeaheadTimeout);
|
|
@@ -96,14 +98,15 @@ export class ContextMenuContent implements OnDestroy {
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
private updateMenuItems(): void {
|
|
99
|
-
const content = this.
|
|
101
|
+
const content = this._elementRef.nativeElement.querySelector('[role="menu"]');
|
|
100
102
|
if (content) {
|
|
101
103
|
this.menuItems = Array.from(
|
|
102
|
-
content.querySelectorAll(
|
|
104
|
+
content.querySelectorAll(
|
|
105
|
+
'[role="menuitem"]:not([aria-disabled="true"]):not([data-disabled])',
|
|
106
|
+
),
|
|
103
107
|
);
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
|
-
|
|
107
110
|
protected onKeydown(event: KeyboardEvent): void {
|
|
108
111
|
this.updateMenuItems();
|
|
109
112
|
|
|
@@ -136,27 +139,22 @@ export class ContextMenuContent implements OnDestroy {
|
|
|
136
139
|
break;
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
|
-
|
|
140
142
|
private focusNext(): void {
|
|
141
143
|
const currentIndex = this.context.focusedIndex();
|
|
142
144
|
const nextIndex = currentIndex < this.menuItems.length - 1 ? currentIndex + 1 : 0;
|
|
143
145
|
this.focusItem(nextIndex);
|
|
144
146
|
}
|
|
145
|
-
|
|
146
147
|
private focusPrevious(): void {
|
|
147
148
|
const currentIndex = this.context.focusedIndex();
|
|
148
149
|
const prevIndex = currentIndex > 0 ? currentIndex - 1 : this.menuItems.length - 1;
|
|
149
150
|
this.focusItem(prevIndex);
|
|
150
151
|
}
|
|
151
|
-
|
|
152
152
|
private focusFirst(): void {
|
|
153
153
|
this.focusItem(0);
|
|
154
154
|
}
|
|
155
|
-
|
|
156
155
|
private focusLast(): void {
|
|
157
156
|
this.focusItem(this.menuItems.length - 1);
|
|
158
157
|
}
|
|
159
|
-
|
|
160
158
|
private focusItem(index: number): void {
|
|
161
159
|
if (index >= 0 && index < this.menuItems.length) {
|
|
162
160
|
// Update roving tabindex
|
|
@@ -167,7 +165,6 @@ export class ContextMenuContent implements OnDestroy {
|
|
|
167
165
|
this.context.focusedIndex.set(index);
|
|
168
166
|
}
|
|
169
167
|
}
|
|
170
|
-
|
|
171
168
|
private handleTypeahead(key: string): void {
|
|
172
169
|
this.typeaheadBuffer += key.toLowerCase();
|
|
173
170
|
|
|
@@ -181,14 +178,13 @@ export class ContextMenuContent implements OnDestroy {
|
|
|
181
178
|
|
|
182
179
|
// Find first matching item
|
|
183
180
|
const matchIndex = this.menuItems.findIndex((item) =>
|
|
184
|
-
item.textContent?.toLowerCase().trim().startsWith(this.typeaheadBuffer)
|
|
181
|
+
item.textContent?.toLowerCase().trim().startsWith(this.typeaheadBuffer),
|
|
185
182
|
);
|
|
186
183
|
|
|
187
184
|
if (matchIndex >= 0) {
|
|
188
185
|
this.focusItem(matchIndex);
|
|
189
186
|
}
|
|
190
187
|
}
|
|
191
|
-
|
|
192
188
|
private close(): void {
|
|
193
189
|
this.context.open.set(false);
|
|
194
190
|
this.context.focusedIndex.set(-1);
|
|
@@ -198,15 +194,12 @@ export class ContextMenuContent implements OnDestroy {
|
|
|
198
194
|
triggerEl.focus();
|
|
199
195
|
}
|
|
200
196
|
}
|
|
201
|
-
|
|
202
197
|
protected onDocumentClick(): void {
|
|
203
198
|
this.close();
|
|
204
199
|
}
|
|
205
|
-
|
|
206
200
|
protected onEscapeKey(): void {
|
|
207
201
|
this.close();
|
|
208
202
|
}
|
|
209
|
-
|
|
210
203
|
protected onAnotherContextMenu(): void {
|
|
211
204
|
// Will be handled by new context menu trigger
|
|
212
205
|
}
|
|
@@ -11,6 +11,7 @@ import { CONTEXT_MENU_CONTEXT } from './context-menu-context';
|
|
|
11
11
|
selector: 'ContextMenuItem',
|
|
12
12
|
template: `<ng-content />`,
|
|
13
13
|
host: {
|
|
14
|
+
'attr.data-slot': '"context-menu-item"',
|
|
14
15
|
'[class]': 'computedClass()',
|
|
15
16
|
'[attr.role]': '"menuitem"',
|
|
16
17
|
'[attr.tabindex]': 'disabled() ? -1 : -1',
|
|
@@ -23,27 +24,25 @@ import { CONTEXT_MENU_CONTEXT } from './context-menu-context';
|
|
|
23
24
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
24
25
|
})
|
|
25
26
|
export class ContextMenuItem {
|
|
26
|
-
|
|
27
|
+
/** Select event emitted when item is clicked */
|
|
28
|
+
readonly onSelect = output<void>();
|
|
27
29
|
|
|
30
|
+
/** Additional CSS classes */
|
|
31
|
+
readonly class = input<string>('');
|
|
28
32
|
/** Whether the item is disabled */
|
|
29
33
|
readonly disabled = input<boolean>(false);
|
|
30
|
-
|
|
31
34
|
/** Whether the item is inset (extra padding) */
|
|
32
35
|
readonly inset = input<boolean>(false);
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
readonly class = input<string>('');
|
|
36
|
-
|
|
37
|
-
/** Select event emitted when item is clicked */
|
|
38
|
-
readonly onSelect = output<void>();
|
|
37
|
+
private readonly _context = inject(CONTEXT_MENU_CONTEXT);
|
|
39
38
|
|
|
40
39
|
protected readonly computedClass = computed(() =>
|
|
41
40
|
cn(
|
|
42
|
-
|
|
41
|
+
'relative flex cursor-default select-none items-center gap-3 rounded-md px-3 py-2.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0 [&>lucide-icon]:size-4 [&>lucide-icon]:shrink-0',
|
|
43
42
|
this.inset() && 'pl-8',
|
|
44
43
|
!this.disabled() && 'cursor-pointer hover:bg-accent hover:text-accent-foreground',
|
|
45
|
-
this.class()
|
|
46
|
-
)
|
|
44
|
+
this.class(),
|
|
45
|
+
),
|
|
47
46
|
);
|
|
48
47
|
|
|
49
48
|
protected handleClick(event: Event): void {
|
|
@@ -52,10 +51,10 @@ export class ContextMenuItem {
|
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
53
|
this.onSelect.emit();
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
54
|
+
this._context.open.set(false);
|
|
55
|
+
this._context.focusedIndex.set(-1);
|
|
57
56
|
// Restore focus to trigger element
|
|
58
|
-
const triggerEl = this.
|
|
57
|
+
const triggerEl = this._context.triggerElement();
|
|
59
58
|
if (triggerEl) {
|
|
60
59
|
triggerEl.focus();
|
|
61
60
|
}
|
|
@@ -9,6 +9,7 @@ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/co
|
|
|
9
9
|
selector: 'ContextMenuLabel',
|
|
10
10
|
template: `<ng-content />`,
|
|
11
11
|
host: {
|
|
12
|
+
'attr.data-slot': '"context-menu-label"',
|
|
12
13
|
'[class]': 'computedClass()',
|
|
13
14
|
},
|
|
14
15
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -21,10 +22,6 @@ export class ContextMenuLabel {
|
|
|
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 text-foreground',
|
|
26
|
-
this.inset() && 'pl-8',
|
|
27
|
-
this.class()
|
|
28
|
-
)
|
|
25
|
+
cn('px-2 py-1.5 text-sm font-semibold text-foreground', this.inset() && 'pl-8', this.class()),
|
|
29
26
|
);
|
|
30
27
|
}
|