@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,12 +1,5 @@
|
|
|
1
1
|
import { cn } from '@/lib/utils';
|
|
2
|
-
import {
|
|
3
|
-
ChangeDetectionStrategy,
|
|
4
|
-
Component,
|
|
5
|
-
computed,
|
|
6
|
-
inject,
|
|
7
|
-
input,
|
|
8
|
-
signal,
|
|
9
|
-
} from '@angular/core';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';
|
|
10
3
|
import { Check, LucideAngularModule, Settings2 } from 'lucide-angular';
|
|
11
4
|
import { DATA_TABLE_CONTEXT } from './data-table-context';
|
|
12
5
|
|
|
@@ -26,7 +19,9 @@ import { DATA_TABLE_CONTEXT } from './data-table-context';
|
|
|
26
19
|
View
|
|
27
20
|
</button>
|
|
28
21
|
@if (isOpen()) {
|
|
29
|
-
<div
|
|
22
|
+
<div
|
|
23
|
+
class="absolute right-0 z-50 mt-2 w-48 rounded-md border bg-popover p-1 text-popover-foreground shadow-md"
|
|
24
|
+
>
|
|
30
25
|
<div class="px-2 py-1.5 text-sm font-semibold">Toggle columns</div>
|
|
31
26
|
<div class="-mx-1 my-1 h-px bg-muted"></div>
|
|
32
27
|
@for (column of toggleableColumns(); track column.id) {
|
|
@@ -47,43 +42,39 @@ import { DATA_TABLE_CONTEXT } from './data-table-context';
|
|
|
47
42
|
</div>
|
|
48
43
|
`,
|
|
49
44
|
host: {
|
|
45
|
+
'attr.data-slot': '"data-table-view-options"',
|
|
50
46
|
'[class]': 'computedClass()',
|
|
51
47
|
'(document:click)': 'onDocumentClick($event)',
|
|
52
48
|
},
|
|
53
49
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
54
50
|
})
|
|
55
51
|
export class DataTableViewOptions {
|
|
56
|
-
protected readonly context = inject(DATA_TABLE_CONTEXT);
|
|
57
|
-
protected readonly icons = { Settings2, Check };
|
|
58
|
-
|
|
59
52
|
/** Additional CSS classes */
|
|
60
53
|
readonly class = input<string>('');
|
|
61
54
|
|
|
62
|
-
protected readonly
|
|
55
|
+
protected readonly context = inject(DATA_TABLE_CONTEXT);
|
|
63
56
|
|
|
64
57
|
protected readonly toggleableColumns = computed(() =>
|
|
65
|
-
this.context.columns().filter((col) => col.enableHiding !== false)
|
|
58
|
+
this.context.columns().filter((col) => col.enableHiding !== false),
|
|
66
59
|
);
|
|
60
|
+
protected readonly computedClass = computed(() => cn('ml-auto', this.class()));
|
|
67
61
|
|
|
68
|
-
protected readonly
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
protected readonly isOpen = signal(false);
|
|
63
|
+
|
|
64
|
+
protected readonly icons = { Settings2, Check };
|
|
71
65
|
|
|
72
66
|
protected toggleDropdown(): void {
|
|
73
67
|
this.isOpen.update((v) => !v);
|
|
74
68
|
}
|
|
75
|
-
|
|
76
69
|
protected onDocumentClick(event: Event): void {
|
|
77
70
|
const target = event.target as HTMLElement;
|
|
78
71
|
if (!target.closest('[data-slot="data-table"]')) {
|
|
79
72
|
this.isOpen.set(false);
|
|
80
73
|
}
|
|
81
74
|
}
|
|
82
|
-
|
|
83
75
|
protected isColumnVisible(columnId: string): boolean {
|
|
84
76
|
return this.context.columnVisibility()[columnId] !== false;
|
|
85
77
|
}
|
|
86
|
-
|
|
87
78
|
protected toggleColumn(columnId: string): void {
|
|
88
79
|
const visibility = { ...this.context.columnVisibility() };
|
|
89
80
|
visibility[columnId] = !visibility[columnId];
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { cn } from '@/lib/utils';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Component,
|
|
5
|
+
computed,
|
|
6
|
+
effect,
|
|
7
|
+
forwardRef,
|
|
8
|
+
input,
|
|
9
|
+
output,
|
|
10
|
+
signal,
|
|
11
11
|
} from '@angular/core';
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
ColumnVisibilityState,
|
|
14
|
+
DATA_TABLE_CONTEXT,
|
|
15
|
+
DataTableContext,
|
|
16
|
+
RowSelectionState,
|
|
17
|
+
SortingState,
|
|
18
|
+
type ColumnDef,
|
|
19
19
|
} from './data-table-context';
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -36,8 +36,8 @@ import {
|
|
|
36
36
|
template: `<ng-content />`,
|
|
37
37
|
host: {
|
|
38
38
|
'[class]': 'computedClass()',
|
|
39
|
-
'data-slot': 'data-table',
|
|
40
|
-
|
|
39
|
+
'attr.data-slot': '"data-table"',
|
|
40
|
+
ngSkipHydration: 'true',
|
|
41
41
|
},
|
|
42
42
|
providers: [
|
|
43
43
|
{
|
|
@@ -49,33 +49,47 @@ import {
|
|
|
49
49
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
50
50
|
})
|
|
51
51
|
export class DataTable<T = unknown> {
|
|
52
|
+
constructor() {
|
|
53
|
+
// Sync data
|
|
54
|
+
effect(() => {
|
|
55
|
+
this.context.data.set(this.data());
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Sync columns
|
|
59
|
+
effect(() => {
|
|
60
|
+
this.context.columns.set(this.columns());
|
|
61
|
+
// Initialize column visibility
|
|
62
|
+
const visibility: ColumnVisibilityState = {};
|
|
63
|
+
this.columns().forEach((col) => {
|
|
64
|
+
visibility[col.id] = true;
|
|
65
|
+
});
|
|
66
|
+
this.context.columnVisibility.set(visibility);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Sorting change event */
|
|
71
|
+
readonly sortingChange = output<SortingState[]>();
|
|
72
|
+
/** Row selection change event */
|
|
73
|
+
readonly rowSelectionChange = output<RowSelectionState>();
|
|
74
|
+
|
|
52
75
|
/** The data to display */
|
|
53
76
|
readonly data = input.required<T[]>();
|
|
54
|
-
|
|
55
77
|
/** Column definitions */
|
|
56
78
|
readonly columns = input.required<ColumnDef<T>[]>();
|
|
57
79
|
|
|
58
80
|
/** Page size options */
|
|
59
81
|
readonly pageSizeOptions = input<number[]>([10, 20, 30, 40, 50]);
|
|
60
|
-
|
|
61
82
|
/** Initial page size */
|
|
62
83
|
readonly initialPageSize = input<number>(10);
|
|
63
|
-
|
|
64
84
|
/** Enable row selection */
|
|
65
85
|
readonly enableRowSelection = input<boolean>(false);
|
|
66
|
-
|
|
67
86
|
/** Enable multi-row selection */
|
|
68
87
|
readonly enableMultiRowSelection = input<boolean>(true);
|
|
69
|
-
|
|
70
|
-
/** Sorting change event */
|
|
71
|
-
readonly sortingChange = output<SortingState[]>();
|
|
72
|
-
|
|
73
|
-
/** Row selection change event */
|
|
74
|
-
readonly rowSelectionChange = output<RowSelectionState>();
|
|
75
|
-
|
|
76
88
|
/** Additional CSS classes */
|
|
77
89
|
readonly class = input<string>('');
|
|
78
90
|
|
|
91
|
+
protected readonly computedClass = computed(() => cn('w-full space-y-4', this.class()));
|
|
92
|
+
|
|
79
93
|
/** Context for child components */
|
|
80
94
|
readonly context: DataTableContext<T> = {
|
|
81
95
|
data: signal<T[]>([]),
|
|
@@ -106,26 +120,4 @@ export class DataTable<T = unknown> {
|
|
|
106
120
|
this.context.pageSize.set(pageSize);
|
|
107
121
|
},
|
|
108
122
|
};
|
|
109
|
-
|
|
110
|
-
constructor() {
|
|
111
|
-
// Sync data
|
|
112
|
-
effect(() => {
|
|
113
|
-
this.context.data.set(this.data());
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// Sync columns
|
|
117
|
-
effect(() => {
|
|
118
|
-
this.context.columns.set(this.columns());
|
|
119
|
-
// Initialize column visibility
|
|
120
|
-
const visibility: ColumnVisibilityState = {};
|
|
121
|
-
this.columns().forEach((col) => {
|
|
122
|
-
visibility[col.id] = true;
|
|
123
|
-
});
|
|
124
|
-
this.context.columnVisibility.set(visibility);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
protected readonly computedClass = computed(() =>
|
|
129
|
-
cn('w-full space-y-4', this.class())
|
|
130
|
-
);
|
|
131
123
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
export { DataTableContent } from './data-table-content.component';
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
DATA_TABLE_CONTEXT,
|
|
4
|
+
type ColumnDef,
|
|
5
|
+
type ColumnVisibilityState,
|
|
6
|
+
type DataTableContext,
|
|
7
|
+
type RowSelectionState,
|
|
8
|
+
type SortDirection,
|
|
9
|
+
type SortingState,
|
|
10
10
|
} from './data-table-context';
|
|
11
11
|
export { DataTablePagination } from './data-table-pagination.component';
|
|
12
12
|
export { DataTableSearch } from './data-table-search.component';
|
|
13
13
|
export { DataTableToolbar } from './data-table-toolbar.component';
|
|
14
14
|
export { DataTableViewOptions } from './data-table-view-options.component';
|
|
15
15
|
export { DataTable } from './data-table.component';
|
|
16
|
-
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
computed,
|
|
6
6
|
input,
|
|
7
7
|
model,
|
|
8
|
-
output
|
|
8
|
+
output,
|
|
9
|
+
viewChild,
|
|
9
10
|
} from '@angular/core';
|
|
10
11
|
import { CalendarIcon, LucideAngularModule } from 'lucide-angular';
|
|
11
12
|
import { buttonVariants } from '../button';
|
|
@@ -20,26 +21,24 @@ import { Popover, PopoverContent, PopoverTrigger } from '../popover';
|
|
|
20
21
|
selector: 'DatePicker',
|
|
21
22
|
imports: [LucideAngularModule, Popover, PopoverTrigger, PopoverContent, Calendar],
|
|
22
23
|
template: `
|
|
23
|
-
<Popover>
|
|
24
|
-
<PopoverTrigger>
|
|
25
|
-
<button
|
|
26
|
-
|
|
27
|
-
[class]="computedButtonClass()"
|
|
28
|
-
>
|
|
29
|
-
<lucide-icon [img]="CalendarIconRef" class="mr-2 h-4 w-4" />
|
|
24
|
+
<Popover class="block w-full">
|
|
25
|
+
<PopoverTrigger class="block w-full">
|
|
26
|
+
<button type="button" [class]="computedButtonClass()">
|
|
27
|
+
<lucide-icon [img]="CalendarIconRef" class="h-4 w-4 shrink-0" />
|
|
30
28
|
@if (date()) {
|
|
31
|
-
{{ formatDate(date()!) }}
|
|
29
|
+
<span class="flex-1 truncate text-left">{{ formatDate(date()!) }}</span>
|
|
32
30
|
} @else {
|
|
33
|
-
<span>{{ placeholder() }}</span>
|
|
31
|
+
<span class="flex-1 truncate text-left">{{ placeholder() }}</span>
|
|
34
32
|
}
|
|
35
33
|
</button>
|
|
36
34
|
</PopoverTrigger>
|
|
37
|
-
<PopoverContent class="
|
|
35
|
+
<PopoverContent class="p-0" align="start" [matchTriggerWidth]="true">
|
|
38
36
|
<Calendar
|
|
39
37
|
[mode]="'single'"
|
|
40
38
|
[selected]="date()"
|
|
41
39
|
(onSelect)="onDateSelect($event)"
|
|
42
40
|
[disabled]="disabledDates()"
|
|
41
|
+
class="w-full"
|
|
43
42
|
/>
|
|
44
43
|
</PopoverContent>
|
|
45
44
|
</Popover>
|
|
@@ -50,35 +49,36 @@ import { Popover, PopoverContent, PopoverTrigger } from '../popover';
|
|
|
50
49
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
51
50
|
})
|
|
52
51
|
export class DatePicker {
|
|
53
|
-
|
|
52
|
+
private readonly popover = viewChild(Popover);
|
|
53
|
+
|
|
54
|
+
/** Date select event */
|
|
55
|
+
readonly onSelect = output<Date | undefined>();
|
|
54
56
|
|
|
55
57
|
/** Selected date */
|
|
56
58
|
readonly date = model<Date | undefined>(undefined);
|
|
57
59
|
|
|
60
|
+
/** Additional CSS classes */
|
|
61
|
+
readonly class = input<string>('');
|
|
58
62
|
/** Placeholder text */
|
|
59
63
|
readonly placeholder = input<string>('Pick a date');
|
|
60
|
-
|
|
61
64
|
/** Date format */
|
|
62
65
|
readonly dateFormat = input<string>('PPP');
|
|
63
|
-
|
|
64
66
|
/** Disabled dates function */
|
|
65
67
|
readonly disabledDates = input<((date: Date) => boolean) | undefined>(undefined);
|
|
66
68
|
|
|
67
|
-
/** Additional CSS classes */
|
|
68
|
-
readonly class = input<string>('');
|
|
69
|
-
|
|
70
|
-
/** Date select event */
|
|
71
|
-
readonly onSelect = output<Date | undefined>();
|
|
72
|
-
|
|
73
69
|
protected readonly computedButtonClass = computed(() =>
|
|
74
70
|
cn(
|
|
75
71
|
buttonVariants({ variant: 'outline' }),
|
|
76
|
-
'w-
|
|
72
|
+
'h-10 w-full justify-start gap-3 px-4 py-6 text-left font-normal hover:bg-gray-100 dark:hover:bg-neutral-800',
|
|
73
|
+
this.popover()?.isOpen() &&
|
|
74
|
+
'border-primary/30 ring-primary/20 ring-2 dark:border-white/30 dark:ring-white/20',
|
|
77
75
|
!this.date() && 'text-muted-foreground',
|
|
78
|
-
this.class()
|
|
79
|
-
)
|
|
76
|
+
this.class(),
|
|
77
|
+
),
|
|
80
78
|
);
|
|
81
79
|
|
|
80
|
+
protected readonly CalendarIconRef = CalendarIcon;
|
|
81
|
+
|
|
82
82
|
protected formatDate(date: Date): string {
|
|
83
83
|
return date.toLocaleDateString('en-US', {
|
|
84
84
|
year: 'numeric',
|
|
@@ -86,9 +86,9 @@ export class DatePicker {
|
|
|
86
86
|
day: 'numeric',
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
|
|
90
89
|
protected onDateSelect(date: Date | undefined): void {
|
|
91
90
|
this.date.set(date);
|
|
92
91
|
this.onSelect.emit(date);
|
|
92
|
+
this.popover()?.setOpen(false);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
inject,
|
|
5
|
-
input,
|
|
6
|
-
} from '@angular/core';
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core';
|
|
7
2
|
import { DIALOG_CONTEXT } from './dialog-context';
|
|
8
3
|
|
|
9
4
|
/**
|
|
@@ -14,16 +9,17 @@ import { DIALOG_CONTEXT } from './dialog-context';
|
|
|
14
9
|
selector: 'DialogClose',
|
|
15
10
|
template: `<ng-content />`,
|
|
16
11
|
host: {
|
|
12
|
+
'attr.data-slot': '"dialog-close"',
|
|
17
13
|
'(click)': 'onClick($event)',
|
|
18
14
|
},
|
|
19
15
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
20
16
|
})
|
|
21
17
|
export class DialogClose {
|
|
22
|
-
protected readonly context = inject(DIALOG_CONTEXT);
|
|
23
|
-
|
|
24
18
|
/** Render as child */
|
|
25
19
|
readonly asChild = input<boolean>(false);
|
|
26
20
|
|
|
21
|
+
protected readonly context = inject(DIALOG_CONTEXT);
|
|
22
|
+
|
|
27
23
|
onClick(event: Event): void {
|
|
28
24
|
event.stopPropagation();
|
|
29
25
|
this.context.setOpen(false);
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { cn
|
|
1
|
+
import { cn } from '@/lib/utils';
|
|
2
2
|
import { FocusTrapDirective } from '@/lib/utils/accessibility';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
ChangeDetectionStrategy,
|
|
5
|
+
ChangeDetectorRef,
|
|
6
|
+
Component,
|
|
7
|
+
computed,
|
|
8
|
+
DestroyRef,
|
|
9
|
+
effect,
|
|
10
|
+
HostListener,
|
|
11
|
+
inject,
|
|
12
|
+
input,
|
|
13
|
+
signal,
|
|
14
14
|
} from '@angular/core';
|
|
15
15
|
import { DIALOG_CONTEXT } from './dialog-context';
|
|
16
16
|
|
|
17
|
+
/** Animation duration in ms — must match Tailwind's duration-200 */
|
|
18
|
+
const EXIT_ANIMATION_MS = 200;
|
|
19
|
+
|
|
17
20
|
/**
|
|
18
21
|
* DialogContent component - the content of the dialog.
|
|
19
22
|
* Matches shadcn/ui React DialogContent exactly.
|
|
20
|
-
* Includes focus trapping, focus restoration, proper ARIA relationships,
|
|
21
|
-
* and Radix-compatible exit animations via Presence component.
|
|
22
23
|
*/
|
|
23
24
|
@Component({
|
|
24
25
|
selector: 'DialogContent',
|
|
25
|
-
imports: [FocusTrapDirective
|
|
26
|
+
imports: [FocusTrapDirective],
|
|
26
27
|
template: `
|
|
27
|
-
|
|
28
|
+
@if (shouldRender()) {
|
|
28
29
|
<!-- Overlay -->
|
|
29
30
|
<div
|
|
30
|
-
class="fixed inset-0 z-50 bg-black/
|
|
31
|
+
class="fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-200"
|
|
31
32
|
[attr.data-state]="context.isOpen() ? 'open' : 'closed'"
|
|
32
33
|
(click)="onOverlayClick($event)"
|
|
33
34
|
aria-hidden="true"
|
|
34
35
|
></div>
|
|
35
36
|
<!-- Content -->
|
|
36
37
|
<div
|
|
37
|
-
#dialogContent
|
|
38
38
|
hlmFocusTrap
|
|
39
39
|
[trapFocus]="context.isOpen()"
|
|
40
40
|
[autoFocus]="true"
|
|
41
|
-
[restoreFocus]="
|
|
41
|
+
[restoreFocus]="true"
|
|
42
42
|
[initialFocus]="initialFocus()"
|
|
43
43
|
[class]="computedClass()"
|
|
44
44
|
[attr.data-state]="context.isOpen() ? 'open' : 'closed'"
|
|
@@ -49,13 +49,12 @@ import { DIALOG_CONTEXT } from './dialog-context';
|
|
|
49
49
|
aria-modal="true"
|
|
50
50
|
>
|
|
51
51
|
<ng-content />
|
|
52
|
-
<!-- Close button -->
|
|
53
52
|
@if (showClose()) {
|
|
54
53
|
<button
|
|
55
54
|
type="button"
|
|
56
|
-
class="absolute right-4 top-4 rounded-
|
|
55
|
+
class="absolute right-4 top-4 rounded-md opacity-70 ring-offset-background transition-all hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none hover:bg-zinc-800 text-zinc-400 hover:text-white h-8 w-8 flex items-center justify-center p-0"
|
|
57
56
|
(click)="onClose()"
|
|
58
|
-
aria-label="
|
|
57
|
+
[attr.aria-label]="ariaCloselabel()"
|
|
59
58
|
>
|
|
60
59
|
<svg
|
|
61
60
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -73,32 +72,56 @@ import { DIALOG_CONTEXT } from './dialog-context';
|
|
|
73
72
|
<path d="M18 6 6 18" />
|
|
74
73
|
<path d="m6 6 12 12" />
|
|
75
74
|
</svg>
|
|
76
|
-
<span class="sr-only">
|
|
75
|
+
<span class="sr-only">{{ ariaCloselabel() }}</span>
|
|
77
76
|
</button>
|
|
78
77
|
}
|
|
79
78
|
</div>
|
|
80
|
-
|
|
79
|
+
}
|
|
81
80
|
`,
|
|
82
81
|
host: {
|
|
82
|
+
'attr.data-slot': '"dialog-content"',
|
|
83
83
|
class: 'contents',
|
|
84
84
|
},
|
|
85
85
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
86
86
|
})
|
|
87
|
-
export class DialogContent
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
export class DialogContent {
|
|
88
|
+
constructor() {
|
|
89
|
+
effect(() => {
|
|
90
|
+
const isOpen = this.context.isOpen();
|
|
91
|
+
this._cdr.markForCheck();
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
if (isOpen) {
|
|
94
|
+
this.shouldRender.set(true);
|
|
95
|
+
this.lockBodyScroll();
|
|
96
|
+
} else {
|
|
97
|
+
this.unlockBodyScroll();
|
|
98
|
+
if (this.shouldRender()) {
|
|
99
|
+
// Keep DOM alive for the exit animation, then unmount
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
this.shouldRender.set(false);
|
|
102
|
+
this._cdr.markForCheck();
|
|
103
|
+
}, EXIT_ANIMATION_MS);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
93
107
|
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
this._destroyRef.onDestroy(() => {
|
|
109
|
+
this.unlockBodyScroll();
|
|
110
|
+
this.restoreFocus();
|
|
111
|
+
});
|
|
112
|
+
}
|
|
96
113
|
|
|
97
|
-
|
|
114
|
+
readonly class = input<string>('');
|
|
115
|
+
readonly showClose = input<boolean>(true);
|
|
116
|
+
readonly ariaCloselabel = input<string>('Close dialog');
|
|
98
117
|
readonly initialFocus = input<string | undefined>(undefined);
|
|
99
118
|
|
|
100
|
-
|
|
101
|
-
private
|
|
119
|
+
private readonly _destroyRef = inject(DestroyRef);
|
|
120
|
+
private readonly _cdr = inject(ChangeDetectorRef);
|
|
121
|
+
|
|
122
|
+
readonly context = inject(DIALOG_CONTEXT);
|
|
123
|
+
|
|
124
|
+
protected readonly shouldRender = signal(false);
|
|
102
125
|
|
|
103
126
|
protected readonly computedClass = computed(() =>
|
|
104
127
|
cn(
|
|
@@ -109,41 +132,11 @@ export class DialogContent implements OnDestroy {
|
|
|
109
132
|
'data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]',
|
|
110
133
|
'data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
|
|
111
134
|
'sm:rounded-lg',
|
|
112
|
-
this.class()
|
|
113
|
-
)
|
|
135
|
+
this.class(),
|
|
136
|
+
),
|
|
114
137
|
);
|
|
115
138
|
|
|
116
|
-
|
|
117
|
-
// Handle body scroll lock based on open state
|
|
118
|
-
effect(() => {
|
|
119
|
-
const isOpen = this.context.isOpen();
|
|
120
|
-
if (isOpen) {
|
|
121
|
-
this.lockBodyScroll();
|
|
122
|
-
} else {
|
|
123
|
-
this.unlockBodyScroll();
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
private lockBodyScroll(): void {
|
|
129
|
-
if (typeof document !== 'undefined') {
|
|
130
|
-
this.previousBodyOverflow = document.body.style.overflow;
|
|
131
|
-
document.body.style.overflow = 'hidden';
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private unlockBodyScroll(): void {
|
|
136
|
-
if (typeof document !== 'undefined') {
|
|
137
|
-
document.body.style.overflow = this.previousBodyOverflow;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
ngOnDestroy(): void {
|
|
142
|
-
// Restore body scroll
|
|
143
|
-
this.unlockBodyScroll();
|
|
144
|
-
// Restore focus to trigger element
|
|
145
|
-
this.restoreFocus();
|
|
146
|
-
}
|
|
139
|
+
private previousBodyOverflow = '';
|
|
147
140
|
|
|
148
141
|
@HostListener('document:keydown.escape')
|
|
149
142
|
onEscapeKey(): void {
|
|
@@ -151,27 +144,33 @@ export class DialogContent implements OnDestroy {
|
|
|
151
144
|
this.close();
|
|
152
145
|
}
|
|
153
146
|
}
|
|
154
|
-
|
|
155
147
|
onOverlayClick(event: Event): void {
|
|
156
148
|
event.stopPropagation();
|
|
157
149
|
this.close();
|
|
158
150
|
}
|
|
159
|
-
|
|
160
151
|
onClose(): void {
|
|
161
152
|
this.close();
|
|
162
153
|
}
|
|
163
154
|
|
|
155
|
+
private lockBodyScroll(): void {
|
|
156
|
+
if (typeof document !== 'undefined') {
|
|
157
|
+
this.previousBodyOverflow = document.body.style.overflow;
|
|
158
|
+
document.body.style.overflow = 'hidden';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
private unlockBodyScroll(): void {
|
|
162
|
+
if (typeof document !== 'undefined') {
|
|
163
|
+
document.body.style.overflow = this.previousBodyOverflow;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
164
166
|
private close(): void {
|
|
165
167
|
this.restoreFocus();
|
|
166
168
|
this.context.setOpen(false);
|
|
167
169
|
}
|
|
168
|
-
|
|
169
170
|
private restoreFocus(): void {
|
|
170
|
-
const triggerEl = this.context.
|
|
171
|
+
const triggerEl = this.context.getTriggerElement();
|
|
171
172
|
if (triggerEl) {
|
|
172
|
-
setTimeout(() =>
|
|
173
|
-
triggerEl.focus();
|
|
174
|
-
}, 0);
|
|
173
|
+
setTimeout(() => triggerEl.focus(), 0);
|
|
175
174
|
}
|
|
176
175
|
}
|
|
177
176
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { InjectionToken
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
export interface DialogContextValue {
|
|
4
|
-
open
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/** Get the current open state */
|
|
5
|
+
isOpen(): boolean;
|
|
6
|
+
/** Set the open state */
|
|
7
|
+
setOpen(open: boolean): void;
|
|
7
8
|
/** Unique IDs for ARIA relationships */
|
|
8
9
|
titleId: string;
|
|
9
10
|
descriptionId: string;
|
|
10
11
|
contentId: string;
|
|
11
12
|
/** Trigger element reference for focus restoration */
|
|
12
|
-
|
|
13
|
+
setTriggerElement(element: HTMLElement | null): void;
|
|
14
|
+
getTriggerElement(): HTMLElement | null;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export const DIALOG_CONTEXT = new InjectionToken<DialogContextValue>('DIALOG_CONTEXT');
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { cn } from '@/lib/utils';
|
|
2
|
-
import {
|
|
3
|
-
ChangeDetectionStrategy,
|
|
4
|
-
Component,
|
|
5
|
-
computed,
|
|
6
|
-
inject,
|
|
7
|
-
input,
|
|
8
|
-
} from '@angular/core';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';
|
|
9
3
|
import { DIALOG_CONTEXT } from './dialog-context';
|
|
10
4
|
|
|
11
5
|
/**
|
|
@@ -17,18 +11,19 @@ import { DIALOG_CONTEXT } from './dialog-context';
|
|
|
17
11
|
selector: 'DialogDescription',
|
|
18
12
|
template: `<ng-content />`,
|
|
19
13
|
host: {
|
|
14
|
+
'attr.data-slot': '"dialog-description"',
|
|
20
15
|
'[class]': 'computedClass()',
|
|
21
16
|
'[attr.id]': 'context.descriptionId',
|
|
22
17
|
},
|
|
23
18
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
24
19
|
})
|
|
25
20
|
export class DialogDescription {
|
|
26
|
-
protected readonly context = inject(DIALOG_CONTEXT);
|
|
27
|
-
|
|
28
21
|
/** Additional CSS classes */
|
|
29
22
|
readonly class = input<string>('');
|
|
30
23
|
|
|
24
|
+
protected readonly context = inject(DIALOG_CONTEXT);
|
|
25
|
+
|
|
31
26
|
protected readonly computedClass = computed(() =>
|
|
32
|
-
cn('text-sm text-muted-foreground', this.class())
|
|
27
|
+
cn('text-sm text-muted-foreground', this.class()),
|
|
33
28
|
);
|
|
34
29
|
}
|