ngwr 10.2.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -19
- package/anchor/styles/_index.scss +4 -4
- package/back-top/styles/_index.scss +6 -1
- package/blur-text/styles/_index.scss +13 -0
- package/button/styles/_index.scss +11 -6
- package/carousel/styles/_index.scss +13 -2
- package/cascader/styles/_index.scss +2 -2
- package/circular-text/styles/_index.scss +2 -0
- package/collapse/styles/_index.scss +1 -1
- package/color-picker/styles/_index.scss +6 -1
- package/compare/styles/_index.scss +1 -2
- package/context-menu/styles/_index.scss +6 -1
- package/descriptions/styles/_index.scss +2 -2
- package/dialog/styles/_index.scss +38 -0
- package/drawer/styles/_index.scss +20 -1
- package/dropdown/styles/_index.scss +19 -5
- package/empty/styles/_index.scss +10 -0
- package/fesm2022/ngwr-action-sheet.mjs +15 -5
- package/fesm2022/ngwr-action-sheet.mjs.map +1 -1
- package/fesm2022/ngwr-affix.mjs +43 -16
- package/fesm2022/ngwr-affix.mjs.map +1 -1
- package/fesm2022/ngwr-alert.mjs +3 -3
- package/fesm2022/ngwr-anchor.mjs +20 -8
- package/fesm2022/ngwr-anchor.mjs.map +1 -1
- package/fesm2022/ngwr-aurora.mjs +4 -4
- package/fesm2022/ngwr-aurora.mjs.map +1 -1
- package/fesm2022/ngwr-avatar.mjs +33 -9
- package/fesm2022/ngwr-avatar.mjs.map +1 -1
- package/fesm2022/ngwr-back-top.mjs +8 -4
- package/fesm2022/ngwr-back-top.mjs.map +1 -1
- package/fesm2022/ngwr-badge.mjs +6 -6
- package/fesm2022/ngwr-badge.mjs.map +1 -1
- package/fesm2022/ngwr-bar-chart.mjs +32 -11
- package/fesm2022/ngwr-bar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-blur-text.mjs +4 -4
- package/fesm2022/ngwr-blur-text.mjs.map +1 -1
- package/fesm2022/ngwr-border-glow.mjs +4 -4
- package/fesm2022/ngwr-border-glow.mjs.map +1 -1
- package/fesm2022/ngwr-breadcrumbs.mjs +9 -8
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-burger.mjs +11 -6
- package/fesm2022/ngwr-burger.mjs.map +1 -1
- package/fesm2022/ngwr-button-testing.mjs +96 -0
- package/fesm2022/ngwr-button-testing.mjs.map +1 -0
- package/fesm2022/ngwr-button.mjs +89 -24
- package/fesm2022/ngwr-button.mjs.map +1 -1
- package/fesm2022/ngwr-calendar-heatmap.mjs +42 -10
- package/fesm2022/ngwr-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +108 -9
- package/fesm2022/ngwr-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-card.mjs +10 -10
- package/fesm2022/ngwr-card.mjs.map +1 -1
- package/fesm2022/ngwr-carousel-testing.mjs +377 -0
- package/fesm2022/ngwr-carousel-testing.mjs.map +1 -0
- package/fesm2022/ngwr-carousel.mjs +72 -18
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-cascader-testing.mjs +534 -0
- package/fesm2022/ngwr-cascader-testing.mjs.map +1 -0
- package/fesm2022/ngwr-cascader.mjs +4 -4
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox-testing.mjs +90 -0
- package/fesm2022/ngwr-checkbox-testing.mjs.map +1 -0
- package/fesm2022/ngwr-checkbox.mjs +15 -9
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-circular-text.mjs +4 -4
- package/fesm2022/ngwr-circular-text.mjs.map +1 -1
- package/fesm2022/ngwr-click-spark.mjs +4 -4
- package/fesm2022/ngwr-click-spark.mjs.map +1 -1
- package/fesm2022/ngwr-clipboard.mjs +18 -4
- package/fesm2022/ngwr-clipboard.mjs.map +1 -1
- package/fesm2022/ngwr-collapse-testing.mjs +368 -0
- package/fesm2022/ngwr-collapse-testing.mjs.map +1 -0
- package/fesm2022/ngwr-collapse.mjs +9 -9
- package/fesm2022/ngwr-color-picker.mjs +139 -19
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-command-palette-testing.mjs +589 -0
- package/fesm2022/ngwr-command-palette-testing.mjs.map +1 -0
- package/fesm2022/ngwr-command-palette.mjs +60 -10
- package/fesm2022/ngwr-command-palette.mjs.map +1 -1
- package/fesm2022/ngwr-compare.mjs +105 -15
- package/fesm2022/ngwr-compare.mjs.map +1 -1
- package/fesm2022/ngwr-confetti.mjs +3 -3
- package/fesm2022/ngwr-config.mjs +106 -0
- package/fesm2022/ngwr-config.mjs.map +1 -0
- package/fesm2022/ngwr-context-menu-testing.mjs +631 -0
- package/fesm2022/ngwr-context-menu-testing.mjs.map +1 -0
- package/fesm2022/ngwr-context-menu.mjs +104 -18
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-cookie.mjs +8 -4
- package/fesm2022/ngwr-cookie.mjs.map +1 -1
- package/fesm2022/ngwr-counter.mjs +17 -9
- package/fesm2022/ngwr-counter.mjs.map +1 -1
- package/fesm2022/ngwr-date-adapter-fns.mjs +3 -3
- package/fesm2022/ngwr-date-adapter-luxon.mjs +55 -7
- package/fesm2022/ngwr-date-adapter-luxon.mjs.map +1 -1
- package/fesm2022/ngwr-date-adapter.mjs +57 -11
- package/fesm2022/ngwr-date-adapter.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker-testing.mjs +766 -0
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -0
- package/fesm2022/ngwr-date-picker.mjs +409 -57
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-decrypt-text.mjs +30 -12
- package/fesm2022/ngwr-decrypt-text.mjs.map +1 -1
- package/fesm2022/ngwr-density.mjs +6 -6
- package/fesm2022/ngwr-descriptions.mjs +6 -6
- package/fesm2022/ngwr-dialog-testing.mjs +89 -0
- package/fesm2022/ngwr-dialog-testing.mjs.map +1 -0
- package/fesm2022/ngwr-dialog.mjs +33 -17
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +48 -24
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-divider.mjs +3 -3
- package/fesm2022/ngwr-donut-chart.mjs +24 -7
- package/fesm2022/ngwr-donut-chart.mjs.map +1 -1
- package/fesm2022/ngwr-drag-drop.mjs +7 -7
- package/fesm2022/ngwr-drag-drop.mjs.map +1 -1
- package/fesm2022/ngwr-drawer-testing.mjs +250 -0
- package/fesm2022/ngwr-drawer-testing.mjs.map +1 -0
- package/fesm2022/ngwr-drawer.mjs +37 -19
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown-testing.mjs +291 -0
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -0
- package/fesm2022/ngwr-dropdown.mjs +19 -11
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-empty.mjs +26 -9
- package/fesm2022/ngwr-empty.mjs.map +1 -1
- package/fesm2022/ngwr-event-calendar.mjs +62 -15
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-falling-text.mjs +4 -4
- package/fesm2022/ngwr-falling-text.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload-testing.mjs +332 -0
- package/fesm2022/ngwr-file-upload-testing.mjs.map +1 -0
- package/fesm2022/ngwr-file-upload.mjs +3 -3
- package/fesm2022/ngwr-form-testing.mjs +451 -0
- package/fesm2022/ngwr-form-testing.mjs.map +1 -0
- package/fesm2022/ngwr-form.mjs +28 -12
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-fuzzy-text.mjs +11 -4
- package/fesm2022/ngwr-fuzzy-text.mjs.map +1 -1
- package/fesm2022/ngwr-gauge.mjs +21 -7
- package/fesm2022/ngwr-gauge.mjs.map +1 -1
- package/fesm2022/ngwr-glitch-text.mjs +4 -4
- package/fesm2022/ngwr-glitch-text.mjs.map +1 -1
- package/fesm2022/ngwr-gradient-text.mjs +4 -4
- package/fesm2022/ngwr-gradient-text.mjs.map +1 -1
- package/fesm2022/ngwr-hotkey.mjs +31 -10
- package/fesm2022/ngwr-hotkey.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +61 -0
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +59 -0
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +9 -9
- package/fesm2022/ngwr-icon.mjs +6 -6
- package/fesm2022/ngwr-image-cropper.mjs +26 -3
- package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
- package/fesm2022/ngwr-input-number-testing.mjs +306 -0
- package/fesm2022/ngwr-input-number-testing.mjs.map +1 -0
- package/fesm2022/ngwr-input-number.mjs +37 -5
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp-testing.mjs +419 -0
- package/fesm2022/ngwr-input-otp-testing.mjs.map +1 -0
- package/fesm2022/ngwr-input-otp.mjs +39 -8
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input-testing.mjs +102 -0
- package/fesm2022/ngwr-input-testing.mjs.map +1 -0
- package/fesm2022/ngwr-input.mjs +62 -25
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-keyboard.mjs +3 -3
- package/fesm2022/ngwr-knob.mjs +46 -10
- package/fesm2022/ngwr-knob.mjs.map +1 -1
- package/fesm2022/ngwr-layout.mjs +36 -20
- package/fesm2022/ngwr-layout.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +35 -8
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-line-chart.mjs +19 -6
- package/fesm2022/ngwr-line-chart.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +14 -9
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-loading-bar.mjs +71 -31
- package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
- package/fesm2022/ngwr-markdown-testing.mjs +516 -0
- package/fesm2022/ngwr-markdown-testing.mjs.map +1 -0
- package/fesm2022/ngwr-markdown.mjs +1492 -0
- package/fesm2022/ngwr-markdown.mjs.map +1 -0
- package/fesm2022/ngwr-marquee.mjs +19 -8
- package/fesm2022/ngwr-marquee.mjs.map +1 -1
- package/fesm2022/ngwr-media.mjs +3 -3
- package/fesm2022/ngwr-mention-testing.mjs +513 -0
- package/fesm2022/ngwr-mention-testing.mjs.map +1 -0
- package/fesm2022/ngwr-mention.mjs +16 -7
- package/fesm2022/ngwr-mention.mjs.map +1 -1
- package/fesm2022/ngwr-meta.mjs +28 -13
- package/fesm2022/ngwr-meta.mjs.map +1 -1
- package/fesm2022/ngwr-meter-group.mjs +22 -8
- package/fesm2022/ngwr-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +57 -8
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-page-header.mjs +3 -3
- package/fesm2022/ngwr-pagination-testing.mjs +389 -0
- package/fesm2022/ngwr-pagination-testing.mjs.map +1 -0
- package/fesm2022/ngwr-pagination.mjs +27 -11
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +21 -21
- package/fesm2022/ngwr-platform.mjs +9 -9
- package/fesm2022/ngwr-popconfirm-testing.mjs +309 -0
- package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -0
- package/fesm2022/ngwr-popconfirm.mjs +99 -21
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover-testing.mjs +316 -0
- package/fesm2022/ngwr-popover-testing.mjs.map +1 -0
- package/fesm2022/ngwr-popover.mjs +48 -10
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-progress.mjs +3 -3
- package/fesm2022/ngwr-pull-to-refresh.mjs +19 -4
- package/fesm2022/ngwr-pull-to-refresh.mjs.map +1 -1
- package/fesm2022/ngwr-qr.mjs +15 -5
- package/fesm2022/ngwr-qr.mjs.map +1 -1
- package/fesm2022/ngwr-radio-testing.mjs +392 -0
- package/fesm2022/ngwr-radio-testing.mjs.map +1 -0
- package/fesm2022/ngwr-radio.mjs +16 -9
- package/fesm2022/ngwr-radio.mjs.map +1 -1
- package/fesm2022/ngwr-rating-testing.mjs +384 -0
- package/fesm2022/ngwr-rating-testing.mjs.map +1 -0
- package/fesm2022/ngwr-rating.mjs +40 -5
- package/fesm2022/ngwr-rating.mjs.map +1 -1
- package/fesm2022/ngwr-result.mjs +12 -12
- package/fesm2022/ngwr-rotating-text.mjs +3 -3
- package/fesm2022/ngwr-scroll.mjs +3 -3
- package/fesm2022/ngwr-segmented-testing.mjs +512 -0
- package/fesm2022/ngwr-segmented-testing.mjs.map +1 -0
- package/fesm2022/ngwr-segmented.mjs +3 -3
- package/fesm2022/ngwr-select-testing.mjs +268 -0
- package/fesm2022/ngwr-select-testing.mjs.map +1 -0
- package/fesm2022/ngwr-select.mjs +96 -25
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-shiny-text.mjs +7 -7
- package/fesm2022/ngwr-shiny-text.mjs.map +1 -1
- package/fesm2022/ngwr-sidebar.mjs +67 -14
- package/fesm2022/ngwr-sidebar.mjs.map +1 -1
- package/fesm2022/ngwr-skeleton.mjs +3 -3
- package/fesm2022/ngwr-slider-testing.mjs +478 -0
- package/fesm2022/ngwr-slider-testing.mjs.map +1 -0
- package/fesm2022/ngwr-slider.mjs +59 -15
- package/fesm2022/ngwr-slider.mjs.map +1 -1
- package/fesm2022/ngwr-sparkline.mjs +28 -8
- package/fesm2022/ngwr-sparkline.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +39 -6
- package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
- package/fesm2022/ngwr-spinner.mjs +14 -5
- package/fesm2022/ngwr-spinner.mjs.map +1 -1
- package/fesm2022/ngwr-splash-cursor.mjs +4 -4
- package/fesm2022/ngwr-splash-cursor.mjs.map +1 -1
- package/fesm2022/ngwr-split-text.mjs +4 -4
- package/fesm2022/ngwr-split-text.mjs.map +1 -1
- package/fesm2022/ngwr-splitter.mjs +72 -11
- package/fesm2022/ngwr-splitter.mjs.map +1 -1
- package/fesm2022/ngwr-spotlight-card.mjs +7 -7
- package/fesm2022/ngwr-spotlight-card.mjs.map +1 -1
- package/fesm2022/ngwr-squircle.mjs +6 -6
- package/fesm2022/ngwr-star-border.mjs +4 -4
- package/fesm2022/ngwr-star-border.mjs.map +1 -1
- package/fesm2022/ngwr-statistic.mjs +33 -16
- package/fesm2022/ngwr-statistic.mjs.map +1 -1
- package/fesm2022/ngwr-stepper-testing.mjs +477 -0
- package/fesm2022/ngwr-stepper-testing.mjs.map +1 -0
- package/fesm2022/ngwr-stepper.mjs +6 -6
- package/fesm2022/ngwr-storage.mjs +27 -17
- package/fesm2022/ngwr-storage.mjs.map +1 -1
- package/fesm2022/ngwr-switch-testing.mjs +77 -0
- package/fesm2022/ngwr-switch-testing.mjs.map +1 -0
- package/fesm2022/ngwr-switch.mjs +12 -6
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-table-testing.mjs +580 -0
- package/fesm2022/ngwr-table-testing.mjs.map +1 -0
- package/fesm2022/ngwr-table.mjs +105 -44
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tabs-testing.mjs +617 -0
- package/fesm2022/ngwr-tabs-testing.mjs.map +1 -0
- package/fesm2022/ngwr-tabs.mjs +44 -12
- package/fesm2022/ngwr-tabs.mjs.map +1 -1
- package/fesm2022/ngwr-textarea-testing.mjs +238 -0
- package/fesm2022/ngwr-textarea-testing.mjs.map +1 -0
- package/fesm2022/ngwr-textarea.mjs +35 -7
- package/fesm2022/ngwr-textarea.mjs.map +1 -1
- package/fesm2022/ngwr-theme.mjs +3 -3
- package/fesm2022/ngwr-tilt-card.mjs +7 -7
- package/fesm2022/ngwr-tilt-card.mjs.map +1 -1
- package/fesm2022/ngwr-timeline.mjs +6 -6
- package/fesm2022/ngwr-toast-testing.mjs +101 -0
- package/fesm2022/ngwr-toast-testing.mjs.map +1 -0
- package/fesm2022/ngwr-toast.mjs +55 -21
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-toolbar.mjs +3 -3
- package/fesm2022/ngwr-tour.mjs +67 -15
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-transfer-testing.mjs +538 -0
- package/fesm2022/ngwr-transfer-testing.mjs.map +1 -0
- package/fesm2022/ngwr-transfer.mjs +47 -16
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree-testing.mjs +734 -0
- package/fesm2022/ngwr-tree-testing.mjs.map +1 -0
- package/fesm2022/ngwr-tree.mjs +75 -9
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-typewriter.mjs +7 -5
- package/fesm2022/ngwr-typewriter.mjs.map +1 -1
- package/fesm2022/ngwr-typography.mjs +3 -3
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-virtual-scroll.mjs +33 -7
- package/fesm2022/ngwr-virtual-scroll.mjs.map +1 -1
- package/fesm2022/ngwr-waves.mjs +5 -5
- package/fesm2022/ngwr-waves.mjs.map +1 -1
- package/fesm2022/ngwr-window.mjs +88 -18
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/gauge/styles/_index.scss +1 -1
- package/glitch-text/styles/_index.scss +4 -0
- package/i18n/en.json +56 -0
- package/i18n/ru.json +56 -0
- package/image-cropper/styles/_index.scss +13 -1
- package/input/styles/_index.scss +2 -2
- package/input-number/styles/_index.scss +7 -2
- package/knob/styles/_index.scss +8 -1
- package/layout/styles/_index.scss +3 -3
- package/lightbox/styles/_index.scss +10 -2
- package/line-chart/styles/_index.scss +6 -0
- package/llms-full.txt +151 -4
- package/llms.txt +57 -8
- package/loading-bar/styles/_index.scss +1 -2
- package/markdown/styles/_index.scss +296 -0
- package/marquee/styles/_index.scss +12 -0
- package/mcp/api.js +512 -0
- package/mcp/catalog.js +157 -0
- package/mcp/server.js +273 -0
- package/mcp/tools.js +366 -0
- package/meter-group/styles/_index.scss +1 -1
- package/package.json +186 -35
- package/pagination/styles/_index.scss +6 -6
- package/popover/styles/_index.scss +37 -5
- package/rating/styles/_index.scss +10 -0
- package/schematics/use/symbol-map.json +2 -0
- package/segmented/styles/_index.scss +7 -0
- package/select/styles/_index.scss +29 -9
- package/sidebar/styles/_index.scss +30 -5
- package/slider/styles/_index.scss +15 -0
- package/speed-dial/styles/_index.scss +20 -0
- package/split-text/styles/_index.scss +13 -0
- package/star-border/styles/_index.scss +2 -0
- package/stepper/styles/_index.scss +1 -1
- package/styles/_grid.scss +4 -4
- package/styles.scss +1 -0
- package/switch/styles/_index.scss +5 -3
- package/table/styles/_index.scss +22 -11
- package/tabs/styles/_index.scss +11 -1
- package/textarea/styles/_index.scss +5 -0
- package/theme/styles/_colors.scss +29 -13
- package/theme/styles/_dark.scss +11 -3
- package/theme/styles/_mixins.scss +3 -0
- package/timeline/styles/_index.scss +2 -2
- package/toast/styles/_index.scss +17 -8
- package/toolbar/styles/_index.scss +3 -3
- package/tour/styles/_index.scss +7 -1
- package/tree/styles/_index.scss +5 -3
- package/types/ngwr-action-sheet.d.ts +9 -1
- package/types/ngwr-affix.d.ts +7 -1
- package/types/ngwr-anchor.d.ts +8 -1
- package/types/ngwr-avatar.d.ts +13 -3
- package/types/ngwr-bar-chart.d.ts +16 -0
- package/types/ngwr-burger.d.ts +6 -2
- package/types/ngwr-button-testing.d.ts +85 -0
- package/types/ngwr-button.d.ts +58 -10
- package/types/ngwr-calendar-heatmap.d.ts +16 -2
- package/types/ngwr-calendar.d.ts +37 -1
- package/types/ngwr-carousel-testing.d.ts +257 -0
- package/types/ngwr-carousel.d.ts +20 -4
- package/types/ngwr-cascader-testing.d.ts +392 -0
- package/types/ngwr-checkbox-testing.d.ts +77 -0
- package/types/ngwr-checkbox.d.ts +7 -2
- package/types/ngwr-clipboard.d.ts +8 -1
- package/types/ngwr-collapse-testing.d.ts +290 -0
- package/types/ngwr-color-picker.d.ts +20 -11
- package/types/ngwr-command-palette-testing.d.ts +437 -0
- package/types/ngwr-command-palette.d.ts +25 -2
- package/types/ngwr-compare.d.ts +50 -2
- package/types/ngwr-config.d.ts +176 -0
- package/types/ngwr-context-menu-testing.d.ts +401 -0
- package/types/ngwr-context-menu.d.ts +65 -17
- package/types/ngwr-counter.d.ts +6 -1
- package/types/ngwr-date-adapter-luxon.d.ts +26 -0
- package/types/ngwr-date-picker-testing.d.ts +518 -0
- package/types/ngwr-date-picker.d.ts +128 -8
- package/types/ngwr-dialog-testing.d.ts +79 -0
- package/types/ngwr-dialog.d.ts +13 -0
- package/types/ngwr-directives.d.ts +10 -1
- package/types/ngwr-donut-chart.d.ts +8 -1
- package/types/ngwr-drawer-testing.d.ts +196 -0
- package/types/ngwr-drawer.d.ts +15 -0
- package/types/ngwr-dropdown-testing.d.ts +202 -0
- package/types/ngwr-dropdown.d.ts +7 -1
- package/types/ngwr-empty.d.ts +19 -4
- package/types/ngwr-event-calendar.d.ts +26 -1
- package/types/ngwr-file-upload-testing.d.ts +194 -0
- package/types/ngwr-form-testing.d.ts +379 -0
- package/types/ngwr-form.d.ts +17 -0
- package/types/ngwr-gauge.d.ts +13 -1
- package/types/ngwr-hotkey.d.ts +2 -0
- package/types/ngwr-image-cropper.d.ts +10 -0
- package/types/ngwr-input-number-testing.d.ts +226 -0
- package/types/ngwr-input-number.d.ts +29 -1
- package/types/ngwr-input-otp-testing.d.ts +299 -0
- package/types/ngwr-input-otp.d.ts +23 -2
- package/types/ngwr-input-testing.d.ts +84 -0
- package/types/ngwr-input.d.ts +20 -6
- package/types/ngwr-knob.d.ts +18 -0
- package/types/ngwr-layout.d.ts +1 -0
- package/types/ngwr-lightbox.d.ts +17 -3
- package/types/ngwr-line-chart.d.ts +9 -2
- package/types/ngwr-list.d.ts +7 -2
- package/types/ngwr-loading-bar.d.ts +4 -7
- package/types/ngwr-markdown-testing.d.ts +462 -0
- package/types/ngwr-markdown.d.ts +534 -0
- package/types/ngwr-marquee.d.ts +12 -2
- package/types/ngwr-mention-testing.d.ts +359 -0
- package/types/ngwr-meta.d.ts +4 -2
- package/types/ngwr-meter-group.d.ts +11 -1
- package/types/ngwr-overlay.d.ts +33 -2
- package/types/ngwr-pagination-testing.d.ts +291 -0
- package/types/ngwr-pagination.d.ts +7 -1
- package/types/ngwr-popconfirm-testing.d.ts +235 -0
- package/types/ngwr-popconfirm.d.ts +31 -21
- package/types/ngwr-popover-testing.d.ts +221 -0
- package/types/ngwr-popover.d.ts +19 -2
- package/types/ngwr-pull-to-refresh.d.ts +7 -0
- package/types/ngwr-qr.d.ts +9 -1
- package/types/ngwr-radio-testing.d.ts +296 -0
- package/types/ngwr-radio.d.ts +8 -2
- package/types/ngwr-rating-testing.d.ts +291 -0
- package/types/ngwr-rating.d.ts +23 -0
- package/types/ngwr-segmented-testing.d.ts +401 -0
- package/types/ngwr-select-testing.d.ts +175 -0
- package/types/ngwr-select.d.ts +45 -4
- package/types/ngwr-sidebar.d.ts +17 -2
- package/types/ngwr-slider-testing.d.ts +329 -0
- package/types/ngwr-slider.d.ts +35 -1
- package/types/ngwr-sparkline.d.ts +12 -2
- package/types/ngwr-speed-dial.d.ts +17 -18
- package/types/ngwr-spinner.d.ts +8 -1
- package/types/ngwr-splitter.d.ts +24 -1
- package/types/ngwr-statistic.d.ts +12 -2
- package/types/ngwr-stepper-testing.d.ts +346 -0
- package/types/ngwr-storage.d.ts +10 -1
- package/types/ngwr-switch-testing.d.ts +66 -0
- package/types/ngwr-switch.d.ts +7 -2
- package/types/ngwr-table-testing.d.ts +423 -0
- package/types/ngwr-table.d.ts +42 -0
- package/types/ngwr-tabs-testing.d.ts +470 -0
- package/types/ngwr-tabs.d.ts +9 -0
- package/types/ngwr-textarea-testing.d.ts +184 -0
- package/types/ngwr-textarea.d.ts +7 -2
- package/types/ngwr-toast-testing.d.ts +80 -0
- package/types/ngwr-toast.d.ts +19 -4
- package/types/ngwr-tour.d.ts +27 -0
- package/types/ngwr-transfer-testing.d.ts +444 -0
- package/types/ngwr-transfer.d.ts +16 -1
- package/types/ngwr-tree-testing.d.ts +501 -0
- package/types/ngwr-tree.d.ts +33 -0
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr-virtual-scroll.d.ts +13 -1
- package/types/ngwr-window.d.ts +23 -2
- package/typewriter/styles/_index.scss +1 -1
- package/typography/styles/_index.scss +1 -1
- package/window/styles/_index.scss +32 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngwr-mention-testing.mjs","sources":["../../../projects/lib/mention/testing/wr-mention-option-harness.ts","../../../projects/lib/mention/testing/wr-mention-harness.ts","../../../projects/lib/mention/testing/ngwr-mention-testing.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrMentionOptionHarnessFilters } from './interfaces';\n\n/**\n * Test harness for one suggestion inside a `[wrMention]` panel.\n *\n * Reach these through {@link WrMentionHarness.getOptions}, never off the document:\n * the panel is a portal in the shared overlay container, so a bare query answers\n * with whichever mention field opened first.\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrMentionOptionHarness extends ComponentHarness {\n /** One `<li role=\"option\">` in the panel's listbox. */\n static hostSelector = '.wr-mention-panel__option';\n\n /** Build a predicate that narrows the query. */\n static with(options: WrMentionOptionHarnessFilters = {}): HarnessPredicate<WrMentionOptionHarness> {\n return new HarnessPredicate(WrMentionOptionHarness, options)\n .addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text))\n .addOption('active', options.active, async (harness, active) => (await harness.isActive()) === active);\n }\n\n /** The suggestion's label — whatever `displayWith` returned for the item. */\n async getText(): Promise<string> {\n return (await this.host()).text();\n }\n\n /**\n * Whether the cursor is on this suggestion.\n *\n * Read from `aria-selected` rather than from the `--active` modifier class. The\n * two are set from the same index, so they agree — but the ARIA state is what a\n * screen reader is told, and the class is only what the highlight is painted\n * with.\n */\n async isActive(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-selected')) === 'true';\n }\n\n /**\n * The suggestion's id — the value the field names in `aria-activedescendant`.\n *\n * The only link between the two DOM trees: the panel is in the overlay\n * container, not inside the field, so this id is how the reference reaches it\n * at all.\n */\n async getId(): Promise<string | null> {\n return (await this.host()).getAttribute('id');\n }\n\n /**\n * Pick this suggestion with the mouse.\n *\n * Needs no layout, so it works here: the panel commits on `mousedown` —\n * deliberately, so the field never loses focus and the caret stays put — and\n * the CDK's no-arg click dispatches `mousedown` at the head of its sequence\n * without any hit test.\n */\n async click(): Promise<void> {\n return (await this.host()).click();\n }\n\n /**\n * Move the pointer onto this suggestion, which makes it the active one.\n *\n * Hover and the arrow keys drive the same single cursor, so a spec can assert\n * the mouse path through {@link WrMentionHarness.getActiveOptionLabel} exactly\n * as it does the keyboard one.\n */\n async hover(): Promise<void> {\n return (await this.host()).hover();\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport {\n ComponentHarness,\n type HarnessLoader,\n HarnessPredicate,\n TestKey,\n type TestElement,\n} from '@angular/cdk/testing';\n\nimport type { WrMentionHarnessFilters, WrMentionOptionHarnessFilters } from './interfaces';\nimport { WrMentionOptionHarness } from './wr-mention-option-harness';\n\n/** How long {@link WrMentionHarness.blur} waits for the deferred close, in ms. Generous next to the 120ms grace period. */\nconst CLOSE_TIMEOUT = 1000;\n\n/** How often it re-checks, in ms. */\nconst POLL_STEP = 10;\n\n/**\n * The real `setTimeout`, captured at module load — before a spec can install fake\n * timers.\n *\n * {@link WrMentionHarness.blur} has to let REAL time pass: the close on blur is a\n * plain `setTimeout` inside the directive, and under zoneless change detection\n * `whenStable()` resolves without waiting for a macrotask. Reading a faked global\n * instead would mean the sleep never fires and the harness hangs where it should\n * fail with the message it prepared.\n */\nconst realSetTimeout = globalThis.setTimeout;\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise(resolve => {\n realSetTimeout(resolve, ms);\n });\n}\n\n/**\n * Test harness for `[wrMention]` — the field, and the suggestion panel it opens\n * at the caret.\n *\n * The harness matches the FIELD, because that is the only part of a mention in the\n * fixture: the panel is a `ComponentPortal` in the shared overlay container, a\n * sibling of the whole app. Suggestions are read through the document root, scoped\n * by the id the field publishes as `aria-controls` — which is what keeps two\n * mention fields on one page from answering with each other's suggestions.\n *\n * **The field is not a combobox, and it has no `aria-expanded`.** Both are\n * deliberate (the source spells out why: it holds prose, `role=\"combobox\"` is\n * disallowed on `<textarea>` and would drop `aria-multiline`, and `aria-expanded`\n * is not a supported state of `role=\"textbox\"`), and both shape this harness.\n * `aria-controls` is STATIC — it names the listbox even while there is no listbox —\n * so {@link isOpen} asks whether the listbox EXISTS instead of reading a state\n * flag, and \"a list appeared\" reaches a screen reader through the live region that\n * {@link getStatusMessage} reads.\n *\n * **The panel's POSITION is not testable in jsdom, so nothing here reports it.**\n * `caret.ts` places the panel by measuring a mirror `<div>` with\n * `getBoundingClientRect`, and jsdom has no layout: every rect is zeros, so the\n * measurement collapses to the origin. The overlay still lands on finite numbers —\n * `line-height` computes to `normal` there, so `caret.ts` falls back to\n * `font-size * 1.2` and the pane is offset by that alone (a measured\n * `margin-top: 23.2px`, `margin-left: 0px` on a default fixture) — which is\n * precisely the problem: every one of them is an artefact of the environment\n * rather than a fact about the component. Assert placement in a real browser.\n *\n * @example\n * ```ts\n * const mention = await loader.getHarness(WrMentionHarness);\n *\n * await mention.type('hey @al');\n * expect(await mention.getOptionLabels()).toEqual(['Alan Turing', 'Linus Torvalds']);\n *\n * await mention.commit();\n * expect(await mention.getValue()).toBe('hey @Alan Turing ');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrMentionHarness extends ComponentHarness {\n /** The directive's host. Both tags, since the directive drives either one. */\n static hostSelector = 'input[wrMention], textarea[wrMention]';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrMentionHarnessFilters = {}): HarnessPredicate<WrMentionHarness> {\n return new HarnessPredicate(WrMentionHarness, options)\n .addOption('value', options.value, (harness, value) => HarnessPredicate.stringMatches(harness.getValue(), value))\n .addOption('placeholder', options.placeholder, (harness, placeholder) =>\n HarnessPredicate.stringMatches(harness.getPlaceholder(), placeholder)\n )\n .addOption('open', options.open, async (harness, open) => (await harness.isOpen()) === open);\n }\n\n /** The field's whole text, mention fragments and prose alike. */\n async getValue(): Promise<string> {\n return (await this.host()).getProperty<string>('value');\n }\n\n /** The field's placeholder, or `''` when it has none. */\n async getPlaceholder(): Promise<string> {\n return (await this.host()).getProperty<string>('placeholder');\n }\n\n /**\n * Type into the field one keystroke at a time, APPENDING to whatever is there.\n *\n * The realistic path, and the one that exercises detection the way a person\n * does: the directive re-reads the text before the caret on every `input`, so\n * `type('hey @al')` opens the panel on the `@` and then narrows it twice.\n *\n * Focuses the field, which BLURS whatever was focused before — and a blurred\n * mention field closes its own panel. Use {@link setValue} when a spec needs two\n * fields suggesting at the same time.\n */\n async type(text: string): Promise<void> {\n return (await this.host()).sendKeys(text);\n }\n\n /**\n * Replace the field's whole text and let the directive detect once.\n *\n * The `input` event is dispatched by hand rather than through keystrokes so the\n * field is never focused — which is the only way to get two mention panels open\n * at once, since focusing one field blurs the other and blur closes its panel.\n * The caret lands at the end of the new text, where detection looks.\n */\n async setValue(text: string): Promise<void> {\n const host = await this.host();\n await host.setInputValue(text);\n await host.dispatchEvent('input');\n }\n\n /** Empty the field. The panel goes with it — there is no trigger char left to detect. */\n async clear(): Promise<void> {\n return (await this.host()).clear();\n }\n\n /**\n * Click the field.\n *\n * Re-opens the suggestions when the caret is still sitting inside a mention —\n * the directive re-detects on click, which is how a user who pressed Escape (or\n * clicked away and back) gets the panel again without retyping. Needs no layout:\n * the CDK dispatches the event on the element rather than hit-testing a point.\n */\n async click(): Promise<void> {\n return (await this.host()).click();\n }\n\n /**\n * Whether the panel is offering suggestions.\n *\n * Asks whether this field's listbox exists, because the field publishes no\n * open/closed state to read: `aria-expanded` is not a supported state of\n * `role=\"textbox\"` (axe rates it a critical violation), and `aria-controls` is\n * static here, so its presence says nothing.\n */\n async isOpen(): Promise<boolean> {\n return (await this.listboxOrNull()) !== null;\n }\n\n /**\n * The field's `aria-autocomplete` — `'list'`, permanently.\n *\n * A capability, not a state: ARIA says authors should not toggle it to signal\n * that suggestions are showing, and being static is what makes the feature\n * discoverable on focus, before a trigger char is ever typed. {@link isOpen}\n * answers the state.\n */\n async getAutocomplete(): Promise<string | null> {\n return (await this.host()).getAttribute('aria-autocomplete');\n }\n\n /**\n * The role the field PROMISES its popup will announce, from `aria-haspopup` —\n * `'listbox'`. Required alongside `aria-autocomplete=\"list\"`, and it has to name\n * the popup's real role, which {@link getListboxRole} reads back off the panel.\n */\n async getPopupRole(): Promise<string | null> {\n return (await this.host()).getAttribute('aria-haspopup');\n }\n\n /** The role the open panel announces — `'listbox'`. Throws while the panel is closed. */\n async getListboxRole(): Promise<string | null> {\n return (await this.listbox()).getAttribute('role');\n }\n\n /**\n * The panel's accessible name.\n *\n * ARIA requires a `role=\"listbox\"` to have one, and a consumer never renders the\n * panel themselves — so the directive supplies it from the i18n catalog\n * (`mention.listbox`).\n */\n async getListboxLabel(): Promise<string | null> {\n return (await this.listbox()).getAttribute('aria-label');\n }\n\n /**\n * The suggestions on offer, in DOM order.\n *\n * The whole list a user can reach, not a window onto a longer one: the directive\n * slices the matches at `maxResults` (8 by default) before rendering, which is\n * why this panel needs no virtualisation.\n *\n * Throws while the panel is closed — the options do not exist anywhere until the\n * portal is attached, and an empty array reads like a panel that rendered\n * nothing.\n */\n async getOptions(filters: WrMentionOptionHarnessFilters = {}): Promise<WrMentionOptionHarness[]> {\n const loader = await this.listboxLoader();\n return loader.getAllHarnesses(WrMentionOptionHarness.with(filters));\n }\n\n /** The labels of the suggestions on offer, in DOM order. */\n async getOptionLabels(): Promise<string[]> {\n const options = await this.getOptions();\n return Promise.all(options.map(option => option.getText()));\n }\n\n /**\n * The id the field names in `aria-activedescendant`, or `null` when it names\n * nothing.\n *\n * The strict half of the field's two references. `aria-controls` is allowed to\n * dangle (see {@link isOpen}); this one is not — naming an element that is not\n * in the document is an author error no browser reports, it simply stops\n * announcing options. So `null` is the CORRECT answer while the panel is closed,\n * and worth asserting there.\n */\n async getActiveOptionId(): Promise<string | null> {\n return (await this.host()).getAttribute('aria-activedescendant');\n }\n\n /**\n * The label a screen reader announces as the active suggestion.\n *\n * Resolved through `aria-activedescendant` the way an assistive technology\n * would, rather than by hunting for the active class — which is why it throws on\n * a reference that resolves to nothing instead of quietly reporting what the\n * class says.\n */\n async getActiveOptionLabel(): Promise<string> {\n const active = await this.activeOption('getActiveOptionLabel');\n return active.text();\n }\n\n /**\n * Where the active suggestion sits in {@link getOptions}, 0-based.\n *\n * Matched by id rather than counted by class, so the answer is the one\n * `aria-activedescendant` actually points at.\n */\n async getActiveOptionIndex(): Promise<number> {\n const id = await this.requireActiveOptionId('getActiveOptionIndex');\n const options = await this.getOptions();\n\n for (let index = 0; index < options.length; index++) {\n if ((await options[index].getId()) === id) return index;\n }\n\n throw new Error(\n `WrMentionHarness.getActiveOptionIndex(): aria-activedescendant names \"${id}\", which is not one of ` +\n `the ${options.length} suggestions on offer.`\n );\n }\n\n /**\n * Move the cursor down one suggestion, wrapping past the last back to the first.\n *\n * ArrowDown — and `aria-activedescendant` is the whole navigation model here,\n * because the options are never focused: focus stays in the field so the user can\n * keep typing the query.\n *\n * Throws while the panel is closed, where ArrowDown belongs to the field.\n */\n async nextOption(): Promise<void> {\n await this.requireOpen('nextOption');\n return (await this.host()).sendKeys(TestKey.DOWN_ARROW);\n }\n\n /** Move the cursor up one suggestion, wrapping past the first round to the last. */\n async previousOption(): Promise<void> {\n await this.requireOpen('previousOption');\n return (await this.host()).sendKeys(TestKey.UP_ARROW);\n }\n\n /**\n * Insert the active suggestion with Enter.\n *\n * The trigger char and the query are replaced by `valueWith(item, trigger)`\n * (`@Label` by default) plus a trailing space, the caret lands after that space,\n * the panel closes and `(wrMentionSelected)` fires with the item, the trigger\n * char and the query.\n *\n * Throws while the panel is closed — Enter is the field's own key there (a\n * newline in a `<textarea>`), and swallowing it would be the bug.\n */\n async commit(): Promise<void> {\n await this.requireOpen('commit');\n return (await this.host()).sendKeys(TestKey.ENTER);\n }\n\n /**\n * Insert the active suggestion with Tab instead.\n *\n * The same commit: the directive takes Tab as a second confirm key and\n * `preventDefault`s it, so focus stays in the field rather than leaving for the\n * next control.\n */\n async commitWithTab(): Promise<void> {\n await this.requireOpen('commitWithTab');\n return (await this.host()).sendKeys(TestKey.TAB);\n }\n\n /**\n * Pick the first suggestion matching the filters, with the mouse.\n *\n * Opens nothing by itself — type a trigger char first. Names what the panel does\n * offer when nothing matches, since a silent no-op here surfaces as an\n * unexplained unchanged field further down the spec.\n */\n async pick(filters: WrMentionOptionHarnessFilters): Promise<void> {\n const [option] = await this.getOptions(filters);\n if (!option) {\n const offered = await this.getOptionLabels();\n throw new Error(\n `WrMentionHarness.pick(): no suggestion matched ${JSON.stringify(filters)}. ` +\n `The panel offers: ${offered.join(', ')}.`\n );\n }\n\n return option.click();\n }\n\n /**\n * Dismiss the panel with Escape, leaving the typed text — trigger char and\n * query included — exactly as it is. A closed panel is left alone.\n *\n * Sends the WHOLE keystroke, keydown and keyup, as a real Escape is. That\n * matters here: the caret has not moved, so a keyup the directive re-detected on\n * would reopen the panel this just closed, and a harness that dispatched only\n * the keydown would report a dismissal the user never got.\n */\n async dismiss(): Promise<void> {\n if (!(await this.isOpen())) return;\n return (await this.host()).sendKeys(TestKey.ESCAPE);\n }\n\n /**\n * Blur the field and wait for the panel to go.\n *\n * The close is deferred by 120ms so a `mousedown` on a suggestion lands first,\n * and that is a real `setTimeout`: under zoneless change detection nothing\n * flushes it for us, so this waits out REAL time. A spec on fake timers should\n * drive its own clock and read {@link isOpen} instead of calling this.\n */\n async blur(timeout = CLOSE_TIMEOUT): Promise<void> {\n await (await this.host()).blur();\n\n for (let waited = 0; waited <= timeout; waited += POLL_STEP) {\n if (!(await this.isOpen())) return;\n\n await sleep(POLL_STEP);\n await this.forceStabilize();\n }\n\n throw new Error(\n `WrMentionHarness.blur(): the panel is still showing ${timeout}ms after the blur. The close is ` +\n 'deferred so that a click on a suggestion lands first, and this wait uses real time — a spec on ' +\n 'fake timers has to advance the clock itself and read isOpen().'\n );\n }\n\n /**\n * What the live region currently says.\n *\n * This is the announcement channel the field has INSTEAD of ARIA state, and\n * three things reach a screen reader only through it: how many suggestions\n * appeared, that NOTHING matched — the panel closes in that case, so there is no\n * DOM left to inspect and no state on the field to read — and what was inserted\n * on commit.\n *\n * Throws when more than one mention field is mounted. The region is parked on\n * `<body>` rather than in the panel (which is disposed on every keystroke that\n * leaves a mention, and a live region has to pre-exist its own text to be\n * announced at all), and it carries no id tying it to a field — so with two\n * fields around, the harness genuinely cannot tell which region is this one's.\n * Answering with whichever came first would be worse than refusing: assert\n * announcements in a fixture holding a single mention field.\n */\n async getStatusMessage(): Promise<string> {\n const regions = await this.documentRootLocatorFactory().locatorForAll('.wr-mention__status')();\n\n if (regions.length === 0) {\n throw new Error(\n 'WrMentionHarness.getStatusMessage(): no mention live region is in the document. The directive ' +\n 'appends it to <body> in the browser only, so there is none under SSR.'\n );\n }\n if (regions.length > 1) {\n throw new Error(\n `WrMentionHarness.getStatusMessage(): ${regions.length} mention live regions are in the document ` +\n 'and none of them names the field it belongs to, so this cannot say which one is yours. Assert ' +\n 'the announcement in a fixture with a single mention field.'\n );\n }\n\n return regions[0].text();\n }\n\n /** Move keyboard focus to the field. Focusing alone opens nothing — the panel needs a trigger char. */\n async focus(): Promise<void> {\n return (await this.host()).focus();\n }\n\n /** Whether the field holds keyboard focus. It keeps it while the panel is open, by design. */\n async isFocused(): Promise<boolean> {\n return (await this.host()).isFocused();\n }\n\n /**\n * A loader scoped to THIS field's listbox.\n *\n * Scoped by the id the field publishes as `aria-controls`, never by\n * `.wr-mention-panel`: the overlay container is shared by every mention on the\n * page, so a class query would answer with whichever field opened first.\n */\n private async listboxLoader(): Promise<HarnessLoader> {\n // Resolve the element first, so a closed panel fails with the message below\n // rather than with the CDK's generic \"expected to find element\" error.\n await this.listbox();\n return this.documentRootLocatorFactory().harnessLoaderFor(`#${await this.listboxId()}`);\n }\n\n /** This field's listbox in the overlay. Throws when the panel is closed. */\n private async listbox(): Promise<TestElement> {\n const listbox = await this.listboxOrNull();\n if (!listbox) {\n throw new Error(\n 'WrMentionHarness: no suggestions are showing, so there is nothing inside the panel to read. It ' +\n 'exists only while the caret sits after a trigger char that matched something — type() one in ' +\n 'first. (The field publishes aria-controls whether or not the panel is up, so that attribute is ' +\n 'not the check.)'\n );\n }\n return listbox;\n }\n\n /** This field's listbox, or `null` when the panel is closed. */\n private async listboxOrNull(): Promise<TestElement | null> {\n return this.documentRootLocatorFactory().locatorForOptional(`#${await this.listboxId()}`)();\n }\n\n /** The id the field names in `aria-controls`, which its listbox carries. */\n private async listboxId(): Promise<string> {\n const id = await (await this.host()).getAttribute('aria-controls');\n if (!id) {\n throw new Error(\n 'WrMentionHarness: this field publishes no aria-controls. That is a static host binding on ' +\n '[wrMention] — rendered even under SSR — so the element matched here is probably not a mention ' +\n 'field at all.'\n );\n }\n return id;\n }\n\n /** The element `aria-activedescendant` points at, or a targeted failure. */\n private async activeOption(method: string): Promise<TestElement> {\n const id = await this.requireActiveOptionId(method);\n const active = await this.documentRootLocatorFactory().locatorForOptional(`#${id}`)();\n\n if (!active) {\n throw new Error(\n `WrMentionHarness.${method}(): aria-activedescendant names \"${id}\", which is not in the document. ` +\n 'A dangling reference stops a screen reader announcing options and no browser reports it, so it ' +\n 'is a real failure rather than a harness one.'\n );\n }\n return active;\n }\n\n /** The active option's id, or a targeted failure. */\n private async requireActiveOptionId(method: string): Promise<string> {\n const id = await this.getActiveOptionId();\n if (!id) {\n throw new Error(\n `WrMentionHarness.${method}(): the field names no active suggestion. That is the correct state ` +\n 'while the panel is closed — check isOpen() first.'\n );\n }\n return id;\n }\n\n /** Refuse a keystroke that would mean something else entirely with the panel closed. */\n private async requireOpen(method: string): Promise<void> {\n if (await this.isOpen()) return;\n\n throw new Error(\n `WrMentionHarness.${method}(): no suggestions are showing, so this key belongs to the field itself ` +\n '— Enter is a newline, Tab leaves for the next control, and the arrows move the caret. Type a ' +\n 'trigger char first.'\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAMH;;;;;;;;AAQG;AACG,MAAO,sBAAuB,SAAQ,gBAAgB,CAAA;;AAE1D,IAAA,OAAO,YAAY,GAAG,2BAA2B;;AAGjD,IAAA,OAAO,IAAI,CAAC,OAAA,GAAyC,EAAE,EAAA;AACrD,QAAA,OAAO,IAAI,gBAAgB,CAAC,sBAAsB,EAAE,OAAO;aACxD,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC;aAC1G,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,OAAO,EAAE,MAAM,KAAK,CAAC,MAAM,OAAO,CAAC,QAAQ,EAAE,MAAM,MAAM,CAAC;IAC1G;;AAGA,IAAA,MAAM,OAAO,GAAA;QACX,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE;IACnC;AAEA;;;;;;;AAOG;AACH,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,OAA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AAK,CACb,CAAA,iBAAA,EAAoB,MAAM,CAAA,oEAAA,CAAsE;AAC9F,gBAAA,mDAAmD,CACtD;QACH;AACA,QAAA,OAAO,EAAE;IACX;;IAGQ,MAAM,WAAW,CAAC,MAAc,EAAA;AACtC,QAAA,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE;YAAE;AAEzB,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,iBAAA,EAAoB,MAAM,CAAA,wEAAA,CAA0E;YAClG,+FAA+F;AAC/F,YAAA,qBAAqB,CACxB;IACH;;;AC5fF;;AAEG;;;;"}
|
|
@@ -159,10 +159,10 @@ class WrMentionPanel {
|
|
|
159
159
|
event.preventDefault();
|
|
160
160
|
this.picked.emit(item);
|
|
161
161
|
}
|
|
162
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.
|
|
163
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.
|
|
162
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMentionPanel, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
163
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: WrMentionPanel, isStandalone: true, selector: "wr-mention-panel", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, activeIndex: { classPropertyName: "activeIndex", publicName: "activeIndex", isSignal: true, isRequired: false, transformFunction: null }, displayWith: { classPropertyName: "displayWith", publicName: "displayWith", isSignal: true, isRequired: false, transformFunction: null }, listboxId: { classPropertyName: "listboxId", publicName: "listboxId", isSignal: true, isRequired: false, transformFunction: null }, listLabel: { classPropertyName: "listLabel", publicName: "listLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { picked: "picked", hovered: "hovered" }, host: { classAttribute: "wr-mention-panel" }, ngImport: i0, template: "<!--\n No empty branch: `activate()` calls `close()` and returns before `open()` when\n nothing matches, so the panel is never rendered with zero items. The \"No\n matches\" `<div>` that used to live here was unreachable \u2014 and a hard-coded\n English string besides. The zero-match case is announced through the\n directive's live region instead.\n-->\n<ul class=\"wr-mention-panel__list\" role=\"listbox\" [attr.id]=\"listboxId()\" [attr.aria-label]=\"listLabel()\">\n @for (item of items(); track $index) {\n <li\n class=\"wr-mention-panel__option\"\n role=\"option\"\n [attr.id]=\"optionId($index)\"\n [class.wr-mention-panel__option--active]=\"$index === activeIndex()\"\n [attr.aria-selected]=\"$index === activeIndex()\"\n (mouseenter)=\"hovered.emit($index)\"\n (mousedown)=\"onPick(item, $event)\"\n >\n {{ displayWith()(item) }}\n </li>\n }\n</ul>\n", encapsulation: i0.ViewEncapsulation.None });
|
|
164
164
|
}
|
|
165
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.
|
|
165
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMentionPanel, decorators: [{
|
|
166
166
|
type: Component,
|
|
167
167
|
args: [{ selector: 'wr-mention-panel', encapsulation: ViewEncapsulation.None, host: { class: 'wr-mention-panel' }, template: "<!--\n No empty branch: `activate()` calls `close()` and returns before `open()` when\n nothing matches, so the panel is never rendered with zero items. The \"No\n matches\" `<div>` that used to live here was unreachable \u2014 and a hard-coded\n English string besides. The zero-match case is announced through the\n directive's live region instead.\n-->\n<ul class=\"wr-mention-panel__list\" role=\"listbox\" [attr.id]=\"listboxId()\" [attr.aria-label]=\"listLabel()\">\n @for (item of items(); track $index) {\n <li\n class=\"wr-mention-panel__option\"\n role=\"option\"\n [attr.id]=\"optionId($index)\"\n [class.wr-mention-panel__option--active]=\"$index === activeIndex()\"\n [attr.aria-selected]=\"$index === activeIndex()\"\n (mouseenter)=\"hovered.emit($index)\"\n (mousedown)=\"onPick(item, $event)\"\n >\n {{ displayWith()(item) }}\n </li>\n }\n</ul>\n" }]
|
|
168
168
|
}], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], activeIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeIndex", required: false }] }], displayWith: [{ type: i0.Input, args: [{ isSignal: true, alias: "displayWith", required: false }] }], listboxId: [{ type: i0.Input, args: [{ isSignal: true, alias: "listboxId", required: false }] }], listLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "listLabel", required: false }] }], picked: [{ type: i0.Output, args: ["picked"] }], hovered: [{ type: i0.Output, args: ["hovered"] }] } });
|
|
@@ -299,8 +299,17 @@ class WrMention {
|
|
|
299
299
|
}
|
|
300
300
|
/** @internal */
|
|
301
301
|
onCaretMove(event) {
|
|
302
|
-
|
|
302
|
+
// Every key `onKeydown` already consumed, Escape included: its keyup would
|
|
303
|
+
// re-detect at a caret that is still sitting inside the mention and reopen the
|
|
304
|
+
// panel Escape had just dismissed. A synthetic keydown-only Escape hides that
|
|
305
|
+
// — the real gesture is a pair, and the second half undid the first.
|
|
306
|
+
if (event.key === 'ArrowUp' ||
|
|
307
|
+
event.key === 'ArrowDown' ||
|
|
308
|
+
event.key === 'Enter' ||
|
|
309
|
+
event.key === 'Tab' ||
|
|
310
|
+
event.key === 'Escape') {
|
|
303
311
|
return;
|
|
312
|
+
}
|
|
304
313
|
this.detect();
|
|
305
314
|
}
|
|
306
315
|
/** @internal */
|
|
@@ -479,10 +488,10 @@ class WrMention {
|
|
|
479
488
|
this.close();
|
|
480
489
|
this.announce(this.insertedText({ label }));
|
|
481
490
|
}
|
|
482
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.
|
|
483
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.
|
|
491
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMention, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
492
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.1", type: WrMention, isStandalone: true, selector: "[wrMention]", inputs: { wrMentionItems: { classPropertyName: "wrMentionItems", publicName: "wrMentionItems", isSignal: true, isRequired: false, transformFunction: null }, triggers: { classPropertyName: "triggers", publicName: "triggers", isSignal: true, isRequired: false, transformFunction: null }, displayWith: { classPropertyName: "displayWith", publicName: "displayWith", isSignal: true, isRequired: false, transformFunction: null }, valueWith: { classPropertyName: "valueWith", publicName: "valueWith", isSignal: true, isRequired: false, transformFunction: null }, filterWith: { classPropertyName: "filterWith", publicName: "filterWith", isSignal: true, isRequired: false, transformFunction: null }, maxResults: { classPropertyName: "maxResults", publicName: "maxResults", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { wrMentionSelected: "wrMentionSelected" }, host: { attributes: { "aria-autocomplete": "list", "aria-haspopup": "listbox" }, listeners: { "input": "onInput()", "click": "onClick()", "keyup": "onCaretMove($event)", "keydown": "onKeydown($event)", "blur": "onBlur()" }, properties: { "attr.aria-controls": "listboxId", "attr.aria-activedescendant": "activeOptionId()" } }, ngImport: i0 });
|
|
484
493
|
}
|
|
485
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.
|
|
494
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMention, decorators: [{
|
|
486
495
|
type: Directive,
|
|
487
496
|
args: [{
|
|
488
497
|
selector: '[wrMention]',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-mention.mjs","sources":["../../../projects/lib/mention/caret.ts","../../../projects/lib/mention/mention-panel.ts","../../../projects/lib/mention/mention-panel.html","../../../projects/lib/mention/mention.ts","../../../projects/lib/mention/ngwr-mention.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\n/**\n * CSS properties whose values must be copied onto the mirror to match layout.\n *\n * `as const satisfies` keeps each name checked against `CSSStyleDeclaration`\n * while narrowing the element type to these string-valued literals — the wider\n * `keyof CSSStyleDeclaration` also spans its methods (`setProperty`, `item`, …),\n * which makes the indexed read below look like an unbound method.\n */\nconst MIRROR_PROPS = [\n 'boxSizing',\n 'width',\n 'height',\n 'overflowX',\n 'overflowY',\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'fontStyle',\n 'fontVariant',\n 'fontWeight',\n 'fontStretch',\n 'fontSize',\n 'fontSizeAdjust',\n 'lineHeight',\n 'fontFamily',\n 'textAlign',\n 'textTransform',\n 'textIndent',\n 'textDecoration',\n 'letterSpacing',\n 'wordSpacing',\n 'tabSize',\n 'whiteSpace',\n 'wordWrap',\n] as const satisfies readonly (keyof CSSStyleDeclaration)[];\n\n/**\n * Compute the viewport coordinates of a textarea / input caret at a given\n * `position`. Uses the \"mirror div\" technique — a hidden div with the\n * same styling holds the text up to the caret, and we read the bounding\n * rect of a probe span placed at the boundary.\n *\n * Returns viewport-relative `{ top, left }` — pass straight to a CDK\n * Overlay anchored at that point.\n */\nexport function getCaretCoordinates(\n input: HTMLTextAreaElement | HTMLInputElement,\n position: number\n): { top: number; left: number; lineHeight: number } {\n const doc = input.ownerDocument;\n const style = getComputedStyle(input);\n const mirror = doc.createElement('div');\n\n for (const prop of MIRROR_PROPS) {\n mirror.style[prop] = style[prop];\n }\n mirror.style.position = 'absolute';\n mirror.style.visibility = 'hidden';\n mirror.style.top = '0';\n mirror.style.left = '0';\n mirror.style.whiteSpace = 'pre-wrap';\n mirror.style.wordWrap = 'break-word';\n\n // <input> is single-line — force whitespace behaviour so coords are sane.\n if (input.tagName === 'INPUT') {\n mirror.style.whiteSpace = 'pre';\n mirror.style.height = 'auto';\n mirror.style.width = 'auto';\n mirror.style.overflow = 'hidden';\n }\n\n const before = input.value.substring(0, position);\n mirror.textContent = before;\n\n const probe = doc.createElement('span');\n // Single character so the span has measurable size even at the end.\n probe.textContent = input.value.substring(position) || '.';\n mirror.appendChild(probe);\n\n doc.body.appendChild(mirror);\n const probeRect = probe.getBoundingClientRect();\n const mirrorRect = mirror.getBoundingClientRect();\n const lineHeight = parseFloat(style.lineHeight) || parseFloat(style.fontSize) * 1.2;\n doc.body.removeChild(mirror);\n\n const inputRect = input.getBoundingClientRect();\n return {\n top: inputRect.top + (probeRect.top - mirrorRect.top) - input.scrollTop,\n left: inputRect.left + (probeRect.left - mirrorRect.left) - input.scrollLeft,\n lineHeight,\n };\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, input, output } from '@angular/core';\n\nimport type { WrMentionItem } from './interfaces';\n\n/**\n * The id of the option at `index`, given the listbox's own id.\n *\n * Lives here, and is used from both sides, because this format is a contract\n * between two files: the panel stamps it onto each `<li>`, and the directive\n * names one of them in `aria-activedescendant`. Written out twice, the two would\n * drift and the reference would silently dangle — and a dangling\n * `aria-activedescendant` is not an error the browser reports, it just stops\n * announcing options.\n *\n * @internal\n */\nexport function wrMentionOptionId(listboxId: string, index: number): string {\n return `${listboxId}-opt-${index}`;\n}\n\n/**\n * Overlay panel rendered by {@link WrMention}. Not intended for\n * direct use — the directive instantiates it via a ComponentPortal.\n */\n@Component({\n selector: 'wr-mention-panel',\n templateUrl: './mention-panel.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-mention-panel' },\n})\nexport class WrMentionPanel {\n readonly items = input<readonly WrMentionItem[]>([]);\n readonly activeIndex = input(0);\n readonly displayWith = input<(item: WrMentionItem) => string>(item => item.label);\n\n /**\n * Id of the `<ul role=\"listbox\">`, minted by the directive and pointed at by\n * its `aria-controls`. Owned there rather than here because the panel is\n * disposed and rebuilt whenever the caret leaves a mention, while the\n * attribute on the host has to stay put.\n *\n * Plain `input('')`, never `input.required` — a ComponentPortal-created\n * component throws on the first change detection if a required input is unset.\n */\n readonly listboxId = input('');\n\n /** Accessible name for the listbox. ARIA requires one; the directive supplies it from the catalog. */\n readonly listLabel = input('');\n\n protected optionId(index: number): string {\n return wrMentionOptionId(this.listboxId(), index);\n }\n\n /** Emitted when the user picks an item (click). */\n readonly picked = output<WrMentionItem>();\n\n /** Emitted on mouseenter — used by the directive to track hover. */\n readonly hovered = output<number>();\n\n protected onPick(item: WrMentionItem, event: MouseEvent): void {\n // mousedown semantics — keep focus on the input.\n event.preventDefault();\n this.picked.emit(item);\n }\n}\n","<!--\n No empty branch: `activate()` calls `close()` and returns before `open()` when\n nothing matches, so the panel is never rendered with zero items. The \"No\n matches\" `<div>` that used to live here was unreachable — and a hard-coded\n English string besides. The zero-match case is announced through the\n directive's live region instead.\n-->\n<ul class=\"wr-mention-panel__list\" role=\"listbox\" [attr.id]=\"listboxId()\" [attr.aria-label]=\"listLabel()\">\n @for (item of items(); track $index) {\n <li\n class=\"wr-mention-panel__option\"\n role=\"option\"\n [attr.id]=\"optionId($index)\"\n [class.wr-mention-panel__option--active]=\"$index === activeIndex()\"\n [attr.aria-selected]=\"$index === activeIndex()\"\n (mouseenter)=\"hovered.emit($index)\"\n (mousedown)=\"onPick(item, $event)\"\n >\n {{ displayWith()(item) }}\n </li>\n }\n</ul>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { ComponentPortal } from '@angular/cdk/portal';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n type ComponentRef,\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n computed,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\n\nimport { readI18nText, useI18nFormatter } from 'ngwr/i18n';\nimport { WR_OVERLAY } from 'ngwr/overlay';\n\nimport { getCaretCoordinates } from './caret';\nimport type { WrMentionCommit, WrMentionItem } from './interfaces';\nimport { WrMentionPanel, wrMentionOptionId } from './mention-panel';\n\ninterface ActiveState {\n trigger: string;\n query: string;\n startIndex: number;\n}\n\n/**\n * Deterministic under prerender, unlike `randomId()` — `aria-controls` is a\n * static host binding, so it renders on the server too, and a random value would\n * differ between that render and the hydrated client.\n */\nlet mentionUid = 0;\n\n/**\n * `@`-style mention picker for `<textarea>` and `<input>`. Listens for\n * trigger characters (default `'@'`); when typed at a word boundary, an\n * overlay panel opens at the caret and shows filtered options. Pick with\n * Enter / Tab / click — the trigger + query is replaced with the inserted\n * value plus a trailing space.\n *\n * @example\n * ```html\n * <textarea\n * wrMention\n * [wrMentionItems]=\"users\"\n * [displayWith]=\"userLabel\"\n * (wrMentionSelected)=\"onMention($event)\"\n * ></textarea>\n * ```\n *\n * @see https://ngwr.dev/reference/components/mention\n */\n@Directive({\n selector: '[wrMention]',\n host: {\n '(input)': 'onInput()',\n '(click)': 'onClick()',\n '(keyup)': 'onCaretMove($event)',\n '(keydown)': 'onKeydown($event)',\n '(blur)': 'onBlur()',\n\n // The host keeps its implicit `role=\"textbox\"`. It is NOT a combobox: this\n // field holds prose and the mention is one fragment inside it, not the\n // field's value. `role=\"combobox\"` is also flatly disallowed on `<textarea>`\n // by ARIA in HTML (axe: `aria-allowed-role`), and it would drop\n // `aria-multiline`, which combobox does not support — so a screen reader\n // would stop reporting the field as multi-line for the whole editing\n // session, not just while the popup is open.\n //\n // Static, because `aria-autocomplete` describes a permanent capability of\n // the field; ARIA says authors SHOULD NOT toggle it to signal that\n // suggestions are currently showing. Being static is also what makes the\n // feature discoverable — it is announced on focus, before the user types a\n // trigger char.\n 'aria-autocomplete': 'list',\n // Required alongside `aria-autocomplete=\"list\"`, and must name the popup's\n // role. Measured clean on a textbox with axe-core 4.13.\n 'aria-haspopup': 'listbox',\n // Also static, and deliberately left pointing at an id that only exists\n // while the panel is open: gating it would mean gating `aria-autocomplete`\n // too. An unresolved `aria-controls` is a manual-review note in axe, never a\n // violation — unlike `aria-activedescendant`, which is an author error.\n //\n // This is the attribute that legalises the whole design: for a textbox\n // controlling a popup, `aria-activedescendant` is allowed to name an element\n // owned by the *controlled* element, which is how the reference reaches into\n // the CDK overlay's separate DOM subtree at all.\n '[attr.aria-controls]': 'listboxId',\n '[attr.aria-activedescendant]': 'activeOptionId()',\n\n // No `aria-expanded`. It is not a supported state of `role=\"textbox\"` —\n // axe rates it a *critical* `aria-allowed-attr` violation — so the\n // \"a list appeared\" signal cannot be an ARIA state here. That is what the\n // live region below is for; it is load-bearing, not decoration.\n },\n})\nexport class WrMention<T extends WrMentionItem = WrMentionItem> {\n /** Items to filter against the typed query. */\n readonly wrMentionItems = input<readonly T[]>([]);\n\n /** Trigger characters that open the panel. @default ['@'] */\n readonly triggers = input<readonly string[]>(['@']);\n\n /** Maps an item to its display label. @default `item.label` */\n readonly displayWith = input<(item: T) => string>((item: T) => item.label);\n\n /**\n * Returns the text to insert into the textarea on commit. Receives the\n * picked item and the trigger char. @default `${trigger}${displayWith(item)}`\n */\n readonly valueWith = input<((item: T, trigger: string) => string) | null>(null);\n\n /** Custom filter. @default case-insensitive `includes` over `displayWith(item)`. */\n readonly filterWith = input<((query: string, item: T) => boolean) | null>(null);\n\n /** Maximum number of items shown in the panel. @default 8 */\n readonly maxResults = input(8, { transform: (v: unknown): number => Math.max(1, coerceNumberProperty(v, 8)) });\n\n /** Emits the selected item, trigger, and query whenever the user commits. */\n readonly wrMentionSelected = output<WrMentionCommit<T>>();\n\n private readonly host = inject<ElementRef<HTMLTextAreaElement | HTMLInputElement>>(ElementRef);\n private readonly overlay = inject(WR_OVERLAY);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly destroyRef = inject(DestroyRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n private overlayRef: OverlayRef | null = null;\n private panelRef: ComponentRef<WrMentionPanel> | null = null;\n private state: ActiveState | null = null;\n private readonly activeIndex = signal(0);\n private readonly filteredItems = signal<readonly T[]>([]);\n private readonly isOpen = signal(false);\n\n /** @internal — read by the `aria-controls` host binding. */\n protected readonly listboxId = `wr-mention-listbox-${++mentionUid}`;\n\n private readonly listLabel = readI18nText('mention.listbox', 'Mentions');\n private readonly availableText = useI18nFormatter('mention.available', 'Matches available: {{count}}');\n private readonly insertedText = useI18nFormatter('mention.inserted', 'Inserted: {{label}}');\n\n /**\n * `aria-activedescendant`, or `null`.\n *\n * Gated hard on `isOpen()`, which is only set once the panel's options are\n * actually in the DOM. An id that resolves to nothing is an author error, and\n * the failure mode is silent: the browser does not complain, it simply stops\n * firing the event that makes a screen reader speak the option. Same\n * discipline `tree.ts` uses for its virtualized rows.\n */\n protected readonly activeOptionId = computed<string | null>(() => {\n if (!this.isOpen()) return null;\n const index = this.activeIndex();\n return index >= 0 && index < this.filteredItems().length ? wrMentionOptionId(this.listboxId, index) : null;\n });\n\n /**\n * Polite live region, parked on `<body>`.\n *\n * Not inside the panel: `close()` disposes the overlay on every keystroke that\n * leaves a mention, so a region living there would be recreated constantly —\n * and a live region has to be in the DOM *before* its text changes to be\n * announced at all. It also could not announce the two cases that matter most,\n * since in both the panel is already gone: \"nothing matched\" and \"inserted X\".\n *\n * Not a sibling of the host either — that would land inside the consumer's\n * markup and start matching their `+`, `~` and `:nth-child()` selectors.\n */\n private liveRegion: HTMLElement | null = null;\n\n constructor() {\n if (this.isBrowser) {\n const doc = this.host.nativeElement.ownerDocument;\n const region = doc.createElement('div');\n region.className = 'wr-mention__status';\n region.setAttribute('role', 'status');\n doc.body.appendChild(region);\n this.liveRegion = region;\n }\n\n this.destroyRef.onDestroy(() => {\n this.close();\n this.liveRegion?.remove();\n this.liveRegion = null;\n });\n }\n\n private announce(message: string): void {\n if (this.liveRegion) this.liveRegion.textContent = message;\n }\n\n // Host listeners\n\n /** @internal */\n protected onInput(): void {\n this.detect();\n }\n\n /** @internal */\n protected onClick(): void {\n this.detect();\n }\n\n /** @internal */\n protected onCaretMove(event: KeyboardEvent): void {\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'Enter' || event.key === 'Tab') return;\n this.detect();\n }\n\n /** @internal */\n protected onKeydown(event: KeyboardEvent): void {\n if (!this.state) return;\n const list = this.filteredItems();\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n if (list.length > 0) this.setActive((this.activeIndex() + 1) % list.length);\n break;\n case 'ArrowUp':\n event.preventDefault();\n if (list.length > 0) this.setActive((this.activeIndex() - 1 + list.length) % list.length);\n break;\n case 'Enter':\n case 'Tab': {\n const item = list[this.activeIndex()];\n if (item) {\n event.preventDefault();\n this.commit(item);\n }\n break;\n }\n case 'Escape':\n event.preventDefault();\n this.close();\n break;\n default:\n break;\n }\n }\n\n /** @internal */\n protected onBlur(): void {\n // Defer so option mousedown lands first.\n setTimeout(() => this.close(), 120);\n }\n\n // Detection\n\n private detect(): void {\n const el = this.host.nativeElement;\n const caret = el.selectionStart ?? 0;\n const text = el.value.substring(0, caret);\n const triggers = this.triggers();\n\n // Walk back from the caret looking for a trigger char with whitespace\n // (or start-of-string) immediately before it. Stop on whitespace.\n let i = caret;\n while (i > 0) {\n const ch = text[i - 1];\n if (triggers.includes(ch)) {\n const before = i - 2 >= 0 ? text[i - 2] : '';\n if (i - 2 < 0 || /\\s/.test(before)) {\n const query = text.substring(i);\n this.activate(ch, query, i - 1);\n return;\n }\n break;\n }\n if (/\\s/.test(ch)) break;\n i--;\n }\n this.close();\n }\n\n private activate(trigger: string, query: string, startIndex: number): void {\n this.state = { trigger, query, startIndex };\n const previousCount = this.filteredItems().length;\n const filtered = this.filter(query).slice(0, this.maxResults());\n this.filteredItems.set(filtered);\n if (filtered.length === 0) {\n // Announce *after* closing: `close()` clears the region, so announcing\n // first would wipe the message before a screen reader reached it.\n this.close();\n this.announce(this.availableText({ count: 0 }));\n return;\n }\n this.setActive(Math.min(this.activeIndex(), filtered.length - 1));\n this.open();\n // Only when the size actually changes. Re-announcing the same count on every\n // keystroke would talk over the per-option speech from activedescendant.\n if (filtered.length !== previousCount) this.announce(this.availableText({ count: filtered.length }));\n }\n\n private filter(query: string): readonly T[] {\n const items = this.wrMentionItems();\n const custom = this.filterWith();\n const display = this.displayWith();\n if (!query) return items;\n if (custom) return items.filter(item => custom(query, item));\n const q = query.toLowerCase();\n return items.filter(item => display(item).toLowerCase().includes(q));\n }\n\n private setActive(i: number): void {\n this.activeIndex.set(i);\n this.panelRef?.setInput('activeIndex', i);\n }\n\n // Overlay\n\n private open(): void {\n const el = this.host.nativeElement;\n const caret = el.selectionStart ?? 0;\n const { top, left, lineHeight } = getCaretCoordinates(el, caret);\n const x = left;\n const y = top + lineHeight + 4;\n\n if (!this.overlayRef) {\n this.overlayRef = this.overlay.create({\n positionStrategy: this.overlay.position().global().left(`${x}px`).top(`${y}px`),\n scrollStrategy: this.scrollStrategies.reposition(),\n panelClass: 'wr-mention-overlay',\n });\n\n const portal = new ComponentPortal(WrMentionPanel);\n const ref = this.overlayRef.attach(portal);\n this.panelRef = ref;\n ref.setInput('displayWith', this.displayWith());\n ref.setInput('listboxId', this.listboxId);\n ref.setInput('listLabel', this.listLabel);\n ref.instance.picked.subscribe(item => this.commit(item as T));\n ref.instance.hovered.subscribe(i => this.setActive(i));\n } else {\n this.overlayRef.updatePositionStrategy(this.overlay.position().global().left(`${x}px`).top(`${y}px`));\n }\n\n this.panelRef?.setInput('items', this.filteredItems());\n this.panelRef?.setInput('activeIndex', this.activeIndex());\n\n // Render the panel's own view NOW, before `aria-activedescendant` is allowed\n // to name one of its options. `attach()` inserts the host element but leaves\n // it empty — the panel is a separate root view, so on the first open the\n // `<li>` being referenced does not exist anywhere in the document yet.\n // Waiting for the next tick would leave a window where the reference dangles\n // and the announcement is lost with no error anywhere.\n this.panelRef?.changeDetectorRef.detectChanges();\n this.isOpen.set(true);\n }\n\n private close(): void {\n if (this.overlayRef) {\n this.overlayRef.dispose();\n this.overlayRef = null;\n this.panelRef = null;\n }\n this.isOpen.set(false);\n this.state = null;\n this.activeIndex.set(0);\n this.filteredItems.set([]);\n this.announce('');\n }\n\n private commit(item: T): void {\n // Snapshot the state up front. `dispatchEvent` below re-enters this directive\n // synchronously: the listener runs `detect()`, and because assigning\n // `el.value` has already parked the caret at the end of the text — past the\n // space this method appends — `detect()` finds no trigger and calls\n // `close()`, which nulls `this.state`. Reading `this.state` after that line\n // threw, so `wrMentionSelected` never fired for anyone.\n const state = this.state;\n if (!state) return;\n\n const el = this.host.nativeElement;\n const value = el.value;\n const caret = el.selectionStart ?? value.length;\n const valueFn = this.valueWith();\n const label = this.displayWith()(item);\n const inserted = valueFn ? valueFn(item, state.trigger) : `${state.trigger}${label}`;\n const replacement = `${inserted} `;\n const before = value.substring(0, state.startIndex);\n const after = value.substring(caret);\n const next = before + replacement + after;\n\n el.value = next;\n el.dispatchEvent(new Event('input', { bubbles: true }));\n const nextCaret = (before + replacement).length;\n el.setSelectionRange(nextCaret, nextCaret);\n this.wrMentionSelected.emit({ item, trigger: state.trigger, query: state.query });\n\n // Announce after `close()`, never before — it clears the live region.\n // Committing is otherwise silent: the panel simply vanishes.\n this.close();\n this.announce(this.insertedText({ label }));\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;AAKG;AAEH;;;;;;;AAOG;AACH,MAAM,YAAY,GAAG;IACnB,WAAW;IACX,OAAO;IACP,QAAQ;IACR,WAAW;IACX,WAAW;IACX,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;IACjB,YAAY;IACZ,cAAc;IACd,eAAe;IACf,aAAa;IACb,WAAW;IACX,aAAa;IACb,YAAY;IACZ,aAAa;IACb,UAAU;IACV,gBAAgB;IAChB,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,eAAe;IACf,YAAY;IACZ,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,SAAS;IACT,YAAY;IACZ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AA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,iBAAA,EAAA,mBAAA,EAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,mBAAA,EAAA,MAAA,EAAA,eAAA,EAAA,SAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,WAAA,EAAA,OAAA,EAAA,WAAA,EAAA,OAAA,EAAA,qBAAA,EAAA,SAAA,EAAA,mBAAA,EAAA,MAAA,EAAA,UAAA,EAAA,EAAA,UAAA,EAAA,EAAA,oBAAA,EAAA,WAAA,EAAA,4BAAA,EAAA,kBAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAT,SAAS,EAAA,UAAA,EAAA,CAAA;kBA5CrB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,IAAI,EAAE;AACJ,wBAAA,SAAS,EAAE,WAAW;AACtB,wBAAA,SAAS,EAAE,WAAW;AACtB,wBAAA,SAAS,EAAE,qBAAqB;AAChC,wBAAA,WAAW,EAAE,mBAAmB;AAChC,wBAAA,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;AAepB,wBAAA,mBAAmB,EAAE,MAAM;;;AAG3B,wBAAA,eAAe,EAAE,SAAS;;;;;;;;;;AAU1B,wBAAA,sBAAsB,EAAE,WAAW;AACnC,wBAAA,8BAA8B,EAAE,kBAAkB;;;;;AAMnD,qBAAA;AACF,iBAAA;;;AC1GD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngwr-mention.mjs","sources":["../../../projects/lib/mention/caret.ts","../../../projects/lib/mention/mention-panel.ts","../../../projects/lib/mention/mention-panel.html","../../../projects/lib/mention/mention.ts","../../../projects/lib/mention/ngwr-mention.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\n/**\n * CSS properties whose values must be copied onto the mirror to match layout.\n *\n * `as const satisfies` keeps each name checked against `CSSStyleDeclaration`\n * while narrowing the element type to these string-valued literals — the wider\n * `keyof CSSStyleDeclaration` also spans its methods (`setProperty`, `item`, …),\n * which makes the indexed read below look like an unbound method.\n */\nconst MIRROR_PROPS = [\n 'boxSizing',\n 'width',\n 'height',\n 'overflowX',\n 'overflowY',\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'fontStyle',\n 'fontVariant',\n 'fontWeight',\n 'fontStretch',\n 'fontSize',\n 'fontSizeAdjust',\n 'lineHeight',\n 'fontFamily',\n 'textAlign',\n 'textTransform',\n 'textIndent',\n 'textDecoration',\n 'letterSpacing',\n 'wordSpacing',\n 'tabSize',\n 'whiteSpace',\n 'wordWrap',\n] as const satisfies readonly (keyof CSSStyleDeclaration)[];\n\n/**\n * Compute the viewport coordinates of a textarea / input caret at a given\n * `position`. Uses the \"mirror div\" technique — a hidden div with the\n * same styling holds the text up to the caret, and we read the bounding\n * rect of a probe span placed at the boundary.\n *\n * Returns viewport-relative `{ top, left }` — pass straight to a CDK\n * Overlay anchored at that point.\n */\nexport function getCaretCoordinates(\n input: HTMLTextAreaElement | HTMLInputElement,\n position: number\n): { top: number; left: number; lineHeight: number } {\n const doc = input.ownerDocument;\n const style = getComputedStyle(input);\n const mirror = doc.createElement('div');\n\n for (const prop of MIRROR_PROPS) {\n mirror.style[prop] = style[prop];\n }\n mirror.style.position = 'absolute';\n mirror.style.visibility = 'hidden';\n mirror.style.top = '0';\n mirror.style.left = '0';\n mirror.style.whiteSpace = 'pre-wrap';\n mirror.style.wordWrap = 'break-word';\n\n // <input> is single-line — force whitespace behaviour so coords are sane.\n if (input.tagName === 'INPUT') {\n mirror.style.whiteSpace = 'pre';\n mirror.style.height = 'auto';\n mirror.style.width = 'auto';\n mirror.style.overflow = 'hidden';\n }\n\n const before = input.value.substring(0, position);\n mirror.textContent = before;\n\n const probe = doc.createElement('span');\n // Single character so the span has measurable size even at the end.\n probe.textContent = input.value.substring(position) || '.';\n mirror.appendChild(probe);\n\n doc.body.appendChild(mirror);\n const probeRect = probe.getBoundingClientRect();\n const mirrorRect = mirror.getBoundingClientRect();\n const lineHeight = parseFloat(style.lineHeight) || parseFloat(style.fontSize) * 1.2;\n doc.body.removeChild(mirror);\n\n const inputRect = input.getBoundingClientRect();\n return {\n top: inputRect.top + (probeRect.top - mirrorRect.top) - input.scrollTop,\n left: inputRect.left + (probeRect.left - mirrorRect.left) - input.scrollLeft,\n lineHeight,\n };\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, input, output } from '@angular/core';\n\nimport type { WrMentionItem } from './interfaces';\n\n/**\n * The id of the option at `index`, given the listbox's own id.\n *\n * Lives here, and is used from both sides, because this format is a contract\n * between two files: the panel stamps it onto each `<li>`, and the directive\n * names one of them in `aria-activedescendant`. Written out twice, the two would\n * drift and the reference would silently dangle — and a dangling\n * `aria-activedescendant` is not an error the browser reports, it just stops\n * announcing options.\n *\n * @internal\n */\nexport function wrMentionOptionId(listboxId: string, index: number): string {\n return `${listboxId}-opt-${index}`;\n}\n\n/**\n * Overlay panel rendered by {@link WrMention}. Not intended for\n * direct use — the directive instantiates it via a ComponentPortal.\n */\n@Component({\n selector: 'wr-mention-panel',\n templateUrl: './mention-panel.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-mention-panel' },\n})\nexport class WrMentionPanel {\n readonly items = input<readonly WrMentionItem[]>([]);\n readonly activeIndex = input(0);\n readonly displayWith = input<(item: WrMentionItem) => string>(item => item.label);\n\n /**\n * Id of the `<ul role=\"listbox\">`, minted by the directive and pointed at by\n * its `aria-controls`. Owned there rather than here because the panel is\n * disposed and rebuilt whenever the caret leaves a mention, while the\n * attribute on the host has to stay put.\n *\n * Plain `input('')`, never `input.required` — a ComponentPortal-created\n * component throws on the first change detection if a required input is unset.\n */\n readonly listboxId = input('');\n\n /** Accessible name for the listbox. ARIA requires one; the directive supplies it from the catalog. */\n readonly listLabel = input('');\n\n protected optionId(index: number): string {\n return wrMentionOptionId(this.listboxId(), index);\n }\n\n /** Emitted when the user picks an item (click). */\n readonly picked = output<WrMentionItem>();\n\n /** Emitted on mouseenter — used by the directive to track hover. */\n readonly hovered = output<number>();\n\n protected onPick(item: WrMentionItem, event: MouseEvent): void {\n // mousedown semantics — keep focus on the input.\n event.preventDefault();\n this.picked.emit(item);\n }\n}\n","<!--\n No empty branch: `activate()` calls `close()` and returns before `open()` when\n nothing matches, so the panel is never rendered with zero items. The \"No\n matches\" `<div>` that used to live here was unreachable — and a hard-coded\n English string besides. The zero-match case is announced through the\n directive's live region instead.\n-->\n<ul class=\"wr-mention-panel__list\" role=\"listbox\" [attr.id]=\"listboxId()\" [attr.aria-label]=\"listLabel()\">\n @for (item of items(); track $index) {\n <li\n class=\"wr-mention-panel__option\"\n role=\"option\"\n [attr.id]=\"optionId($index)\"\n [class.wr-mention-panel__option--active]=\"$index === activeIndex()\"\n [attr.aria-selected]=\"$index === activeIndex()\"\n (mouseenter)=\"hovered.emit($index)\"\n (mousedown)=\"onPick(item, $event)\"\n >\n {{ displayWith()(item) }}\n </li>\n }\n</ul>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { ComponentPortal } from '@angular/cdk/portal';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n type ComponentRef,\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n computed,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\n\nimport { readI18nText, useI18nFormatter } from 'ngwr/i18n';\nimport { WR_OVERLAY } from 'ngwr/overlay';\n\nimport { getCaretCoordinates } from './caret';\nimport type { WrMentionCommit, WrMentionItem } from './interfaces';\nimport { WrMentionPanel, wrMentionOptionId } from './mention-panel';\n\ninterface ActiveState {\n trigger: string;\n query: string;\n startIndex: number;\n}\n\n/**\n * Deterministic under prerender, unlike `randomId()` — `aria-controls` is a\n * static host binding, so it renders on the server too, and a random value would\n * differ between that render and the hydrated client.\n */\nlet mentionUid = 0;\n\n/**\n * `@`-style mention picker for `<textarea>` and `<input>`. Listens for\n * trigger characters (default `'@'`); when typed at a word boundary, an\n * overlay panel opens at the caret and shows filtered options. Pick with\n * Enter / Tab / click — the trigger + query is replaced with the inserted\n * value plus a trailing space.\n *\n * @example\n * ```html\n * <textarea\n * wrMention\n * [wrMentionItems]=\"users\"\n * [displayWith]=\"userLabel\"\n * (wrMentionSelected)=\"onMention($event)\"\n * ></textarea>\n * ```\n *\n * @see https://ngwr.dev/reference/components/mention\n */\n@Directive({\n selector: '[wrMention]',\n host: {\n '(input)': 'onInput()',\n '(click)': 'onClick()',\n '(keyup)': 'onCaretMove($event)',\n '(keydown)': 'onKeydown($event)',\n '(blur)': 'onBlur()',\n\n // The host keeps its implicit `role=\"textbox\"`. It is NOT a combobox: this\n // field holds prose and the mention is one fragment inside it, not the\n // field's value. `role=\"combobox\"` is also flatly disallowed on `<textarea>`\n // by ARIA in HTML (axe: `aria-allowed-role`), and it would drop\n // `aria-multiline`, which combobox does not support — so a screen reader\n // would stop reporting the field as multi-line for the whole editing\n // session, not just while the popup is open.\n //\n // Static, because `aria-autocomplete` describes a permanent capability of\n // the field; ARIA says authors SHOULD NOT toggle it to signal that\n // suggestions are currently showing. Being static is also what makes the\n // feature discoverable — it is announced on focus, before the user types a\n // trigger char.\n 'aria-autocomplete': 'list',\n // Required alongside `aria-autocomplete=\"list\"`, and must name the popup's\n // role. Measured clean on a textbox with axe-core 4.13.\n 'aria-haspopup': 'listbox',\n // Also static, and deliberately left pointing at an id that only exists\n // while the panel is open: gating it would mean gating `aria-autocomplete`\n // too. An unresolved `aria-controls` is a manual-review note in axe, never a\n // violation — unlike `aria-activedescendant`, which is an author error.\n //\n // This is the attribute that legalises the whole design: for a textbox\n // controlling a popup, `aria-activedescendant` is allowed to name an element\n // owned by the *controlled* element, which is how the reference reaches into\n // the CDK overlay's separate DOM subtree at all.\n '[attr.aria-controls]': 'listboxId',\n '[attr.aria-activedescendant]': 'activeOptionId()',\n\n // No `aria-expanded`. It is not a supported state of `role=\"textbox\"` —\n // axe rates it a *critical* `aria-allowed-attr` violation — so the\n // \"a list appeared\" signal cannot be an ARIA state here. That is what the\n // live region below is for; it is load-bearing, not decoration.\n },\n})\nexport class WrMention<T extends WrMentionItem = WrMentionItem> {\n /** Items to filter against the typed query. */\n readonly wrMentionItems = input<readonly T[]>([]);\n\n /** Trigger characters that open the panel. @default ['@'] */\n readonly triggers = input<readonly string[]>(['@']);\n\n /** Maps an item to its display label. @default `item.label` */\n readonly displayWith = input<(item: T) => string>((item: T) => item.label);\n\n /**\n * Returns the text to insert into the textarea on commit. Receives the\n * picked item and the trigger char. @default `${trigger}${displayWith(item)}`\n */\n readonly valueWith = input<((item: T, trigger: string) => string) | null>(null);\n\n /** Custom filter. @default case-insensitive `includes` over `displayWith(item)`. */\n readonly filterWith = input<((query: string, item: T) => boolean) | null>(null);\n\n /** Maximum number of items shown in the panel. @default 8 */\n readonly maxResults = input(8, { transform: (v: unknown): number => Math.max(1, coerceNumberProperty(v, 8)) });\n\n /** Emits the selected item, trigger, and query whenever the user commits. */\n readonly wrMentionSelected = output<WrMentionCommit<T>>();\n\n private readonly host = inject<ElementRef<HTMLTextAreaElement | HTMLInputElement>>(ElementRef);\n private readonly overlay = inject(WR_OVERLAY);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly destroyRef = inject(DestroyRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n private overlayRef: OverlayRef | null = null;\n private panelRef: ComponentRef<WrMentionPanel> | null = null;\n private state: ActiveState | null = null;\n private readonly activeIndex = signal(0);\n private readonly filteredItems = signal<readonly T[]>([]);\n private readonly isOpen = signal(false);\n\n /** @internal — read by the `aria-controls` host binding. */\n protected readonly listboxId = `wr-mention-listbox-${++mentionUid}`;\n\n private readonly listLabel = readI18nText('mention.listbox', 'Mentions');\n private readonly availableText = useI18nFormatter('mention.available', 'Matches available: {{count}}');\n private readonly insertedText = useI18nFormatter('mention.inserted', 'Inserted: {{label}}');\n\n /**\n * `aria-activedescendant`, or `null`.\n *\n * Gated hard on `isOpen()`, which is only set once the panel's options are\n * actually in the DOM. An id that resolves to nothing is an author error, and\n * the failure mode is silent: the browser does not complain, it simply stops\n * firing the event that makes a screen reader speak the option. Same\n * discipline `tree.ts` uses for its virtualized rows.\n */\n protected readonly activeOptionId = computed<string | null>(() => {\n if (!this.isOpen()) return null;\n const index = this.activeIndex();\n return index >= 0 && index < this.filteredItems().length ? wrMentionOptionId(this.listboxId, index) : null;\n });\n\n /**\n * Polite live region, parked on `<body>`.\n *\n * Not inside the panel: `close()` disposes the overlay on every keystroke that\n * leaves a mention, so a region living there would be recreated constantly —\n * and a live region has to be in the DOM *before* its text changes to be\n * announced at all. It also could not announce the two cases that matter most,\n * since in both the panel is already gone: \"nothing matched\" and \"inserted X\".\n *\n * Not a sibling of the host either — that would land inside the consumer's\n * markup and start matching their `+`, `~` and `:nth-child()` selectors.\n */\n private liveRegion: HTMLElement | null = null;\n\n constructor() {\n if (this.isBrowser) {\n const doc = this.host.nativeElement.ownerDocument;\n const region = doc.createElement('div');\n region.className = 'wr-mention__status';\n region.setAttribute('role', 'status');\n doc.body.appendChild(region);\n this.liveRegion = region;\n }\n\n this.destroyRef.onDestroy(() => {\n this.close();\n this.liveRegion?.remove();\n this.liveRegion = null;\n });\n }\n\n private announce(message: string): void {\n if (this.liveRegion) this.liveRegion.textContent = message;\n }\n\n // Host listeners\n\n /** @internal */\n protected onInput(): void {\n this.detect();\n }\n\n /** @internal */\n protected onClick(): void {\n this.detect();\n }\n\n /** @internal */\n protected onCaretMove(event: KeyboardEvent): void {\n // Every key `onKeydown` already consumed, Escape included: its keyup would\n // re-detect at a caret that is still sitting inside the mention and reopen the\n // panel Escape had just dismissed. A synthetic keydown-only Escape hides that\n // — the real gesture is a pair, and the second half undid the first.\n if (\n event.key === 'ArrowUp' ||\n event.key === 'ArrowDown' ||\n event.key === 'Enter' ||\n event.key === 'Tab' ||\n event.key === 'Escape'\n ) {\n return;\n }\n this.detect();\n }\n\n /** @internal */\n protected onKeydown(event: KeyboardEvent): void {\n if (!this.state) return;\n const list = this.filteredItems();\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n if (list.length > 0) this.setActive((this.activeIndex() + 1) % list.length);\n break;\n case 'ArrowUp':\n event.preventDefault();\n if (list.length > 0) this.setActive((this.activeIndex() - 1 + list.length) % list.length);\n break;\n case 'Enter':\n case 'Tab': {\n const item = list[this.activeIndex()];\n if (item) {\n event.preventDefault();\n this.commit(item);\n }\n break;\n }\n case 'Escape':\n event.preventDefault();\n this.close();\n break;\n default:\n break;\n }\n }\n\n /** @internal */\n protected onBlur(): void {\n // Defer so option mousedown lands first.\n setTimeout(() => this.close(), 120);\n }\n\n // Detection\n\n private detect(): void {\n const el = this.host.nativeElement;\n const caret = el.selectionStart ?? 0;\n const text = el.value.substring(0, caret);\n const triggers = this.triggers();\n\n // Walk back from the caret looking for a trigger char with whitespace\n // (or start-of-string) immediately before it. Stop on whitespace.\n let i = caret;\n while (i > 0) {\n const ch = text[i - 1];\n if (triggers.includes(ch)) {\n const before = i - 2 >= 0 ? text[i - 2] : '';\n if (i - 2 < 0 || /\\s/.test(before)) {\n const query = text.substring(i);\n this.activate(ch, query, i - 1);\n return;\n }\n break;\n }\n if (/\\s/.test(ch)) break;\n i--;\n }\n this.close();\n }\n\n private activate(trigger: string, query: string, startIndex: number): void {\n this.state = { trigger, query, startIndex };\n const previousCount = this.filteredItems().length;\n const filtered = this.filter(query).slice(0, this.maxResults());\n this.filteredItems.set(filtered);\n if (filtered.length === 0) {\n // Announce *after* closing: `close()` clears the region, so announcing\n // first would wipe the message before a screen reader reached it.\n this.close();\n this.announce(this.availableText({ count: 0 }));\n return;\n }\n this.setActive(Math.min(this.activeIndex(), filtered.length - 1));\n this.open();\n // Only when the size actually changes. Re-announcing the same count on every\n // keystroke would talk over the per-option speech from activedescendant.\n if (filtered.length !== previousCount) this.announce(this.availableText({ count: filtered.length }));\n }\n\n private filter(query: string): readonly T[] {\n const items = this.wrMentionItems();\n const custom = this.filterWith();\n const display = this.displayWith();\n if (!query) return items;\n if (custom) return items.filter(item => custom(query, item));\n const q = query.toLowerCase();\n return items.filter(item => display(item).toLowerCase().includes(q));\n }\n\n private setActive(i: number): void {\n this.activeIndex.set(i);\n this.panelRef?.setInput('activeIndex', i);\n }\n\n // Overlay\n\n private open(): void {\n const el = this.host.nativeElement;\n const caret = el.selectionStart ?? 0;\n const { top, left, lineHeight } = getCaretCoordinates(el, caret);\n const x = left;\n const y = top + lineHeight + 4;\n\n if (!this.overlayRef) {\n this.overlayRef = this.overlay.create({\n positionStrategy: this.overlay.position().global().left(`${x}px`).top(`${y}px`),\n scrollStrategy: this.scrollStrategies.reposition(),\n panelClass: 'wr-mention-overlay',\n });\n\n const portal = new ComponentPortal(WrMentionPanel);\n const ref = this.overlayRef.attach(portal);\n this.panelRef = ref;\n ref.setInput('displayWith', this.displayWith());\n ref.setInput('listboxId', this.listboxId);\n ref.setInput('listLabel', this.listLabel);\n ref.instance.picked.subscribe(item => this.commit(item as T));\n ref.instance.hovered.subscribe(i => this.setActive(i));\n } else {\n this.overlayRef.updatePositionStrategy(this.overlay.position().global().left(`${x}px`).top(`${y}px`));\n }\n\n this.panelRef?.setInput('items', this.filteredItems());\n this.panelRef?.setInput('activeIndex', this.activeIndex());\n\n // Render the panel's own view NOW, before `aria-activedescendant` is allowed\n // to name one of its options. `attach()` inserts the host element but leaves\n // it empty — the panel is a separate root view, so on the first open the\n // `<li>` being referenced does not exist anywhere in the document yet.\n // Waiting for the next tick would leave a window where the reference dangles\n // and the announcement is lost with no error anywhere.\n this.panelRef?.changeDetectorRef.detectChanges();\n this.isOpen.set(true);\n }\n\n private close(): void {\n if (this.overlayRef) {\n this.overlayRef.dispose();\n this.overlayRef = null;\n this.panelRef = null;\n }\n this.isOpen.set(false);\n this.state = null;\n this.activeIndex.set(0);\n this.filteredItems.set([]);\n this.announce('');\n }\n\n private commit(item: T): void {\n // Snapshot the state up front. `dispatchEvent` below re-enters this directive\n // synchronously: the listener runs `detect()`, and because assigning\n // `el.value` has already parked the caret at the end of the text — past the\n // space this method appends — `detect()` finds no trigger and calls\n // `close()`, which nulls `this.state`. Reading `this.state` after that line\n // threw, so `wrMentionSelected` never fired for anyone.\n const state = this.state;\n if (!state) return;\n\n const el = this.host.nativeElement;\n const value = el.value;\n const caret = el.selectionStart ?? value.length;\n const valueFn = this.valueWith();\n const label = this.displayWith()(item);\n const inserted = valueFn ? valueFn(item, state.trigger) : `${state.trigger}${label}`;\n const replacement = `${inserted} `;\n const before = value.substring(0, state.startIndex);\n const after = value.substring(caret);\n const next = before + replacement + after;\n\n el.value = next;\n el.dispatchEvent(new Event('input', { bubbles: true }));\n const nextCaret = (before + replacement).length;\n el.setSelectionRange(nextCaret, nextCaret);\n this.wrMentionSelected.emit({ item, trigger: state.trigger, query: state.query });\n\n // Announce after `close()`, never before — it clears the live region.\n // Committing is otherwise silent: the panel simply vanishes.\n this.close();\n this.announce(this.insertedText({ label }));\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;AAKG;AAEH;;;;;;;AAOG;AACH,MAAM,YAAY,GAAG;IACnB,WAAW;IACX,OAAO;IACP,QAAQ;IACR,WAAW;IACX,WAAW;IACX,gBAAgB;IAChB,kBAAkB;IAClB,m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;AACnC,wBAAA,8BAA8B,EAAE,kBAAkB;;;;;AAMnD,qBAAA;AACF,iBAAA;;;AC1GD;;AAEG;;;;"}
|
package/fesm2022/ngwr-meta.mjs
CHANGED
|
@@ -38,8 +38,10 @@ function merge(base, top) {
|
|
|
38
38
|
* Layers merge via shallow merge for scalars and a one-level deep merge
|
|
39
39
|
* for `og` / `twitter` groups.
|
|
40
40
|
*
|
|
41
|
-
* The
|
|
42
|
-
*
|
|
41
|
+
* The title and the canonical link are diffed against the last applied
|
|
42
|
+
* snapshot and only rewritten when they actually change; the `<meta>` tags
|
|
43
|
+
* are re-resolved by selector on every apply, so an existing tag is updated
|
|
44
|
+
* in place rather than duplicated.
|
|
43
45
|
*
|
|
44
46
|
* @example
|
|
45
47
|
* ```ts
|
|
@@ -85,9 +87,13 @@ class WrMeta {
|
|
|
85
87
|
}
|
|
86
88
|
/** Push a new layer. Returns a handle whose `.pop()` removes it. */
|
|
87
89
|
push(config) {
|
|
88
|
-
|
|
90
|
+
// Copied so the layer has an identity of its own: the handle finds it by
|
|
91
|
+
// reference, and pushing one shared config object twice would otherwise
|
|
92
|
+
// give two layers the same identity — the first handle to pop would take
|
|
93
|
+
// the second one's layer with it.
|
|
94
|
+
const target = { ...config };
|
|
95
|
+
this.stack.update(stack => [...stack, target]);
|
|
89
96
|
this.apply();
|
|
90
|
-
const target = config;
|
|
91
97
|
return {
|
|
92
98
|
pop: () => {
|
|
93
99
|
this.stack.update(stack => {
|
|
@@ -125,7 +131,9 @@ class WrMeta {
|
|
|
125
131
|
bind(factory) {
|
|
126
132
|
let current = null;
|
|
127
133
|
const ref = effect(() => {
|
|
128
|
-
|
|
134
|
+
// Copied for the same reason as in `push`: the layer is located by
|
|
135
|
+
// reference, so it must not share one with anybody else's.
|
|
136
|
+
const next = { ...factory() };
|
|
129
137
|
// Recompute is reactive; the stack write + DOM apply are not, so
|
|
130
138
|
// the effect only re-runs on `factory`'s own dependencies.
|
|
131
139
|
untracked(() => {
|
|
@@ -239,10 +247,10 @@ class WrMeta {
|
|
|
239
247
|
link.remove();
|
|
240
248
|
}
|
|
241
249
|
}
|
|
242
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.
|
|
243
|
-
static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.
|
|
250
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMeta, deps: [], target: i0.ɵɵFactoryTarget.Service });
|
|
251
|
+
static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.1", ngImport: i0, type: WrMeta });
|
|
244
252
|
}
|
|
245
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.
|
|
253
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMeta, decorators: [{
|
|
246
254
|
type: Service
|
|
247
255
|
}], ctorParameters: () => [] });
|
|
248
256
|
|
|
@@ -272,15 +280,22 @@ class WrMetaBinding {
|
|
|
272
280
|
constructor() {
|
|
273
281
|
effect(() => {
|
|
274
282
|
const next = this.wrMeta();
|
|
275
|
-
|
|
276
|
-
|
|
283
|
+
// Only the INPUT is read reactively. `push` / `pop` write the service's
|
|
284
|
+
// layer stack and then re-apply, and applying reads that same stack through
|
|
285
|
+
// `resolved()` — so without this the effect depends on a signal it writes
|
|
286
|
+
// and re-runs forever. `WrMeta.bind()` guards the identical pair the same
|
|
287
|
+
// way; this directive was missing it.
|
|
288
|
+
untracked(() => {
|
|
289
|
+
this.handle?.pop();
|
|
290
|
+
this.handle = this.metaService.push(next);
|
|
291
|
+
});
|
|
277
292
|
});
|
|
278
293
|
inject(DestroyRef).onDestroy(() => this.handle?.pop());
|
|
279
294
|
}
|
|
280
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.
|
|
281
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.
|
|
295
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMetaBinding, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
296
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.1", type: WrMetaBinding, isStandalone: true, selector: "[wrMeta]", inputs: { wrMeta: { classPropertyName: "wrMeta", publicName: "wrMeta", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
282
297
|
}
|
|
283
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.
|
|
298
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMetaBinding, decorators: [{
|
|
284
299
|
type: Directive,
|
|
285
300
|
args: [{ selector: '[wrMeta]' }]
|
|
286
301
|
}], ctorParameters: () => [], propDecorators: { wrMeta: [{ type: i0.Input, args: [{ isSignal: true, alias: "wrMeta", required: true }] }] } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-meta.mjs","sources":["../../../projects/lib/meta/tokens.ts","../../../projects/lib/meta/wr-meta.ts","../../../projects/lib/meta/wr-meta-binding.ts","../../../projects/lib/meta/provide-wr-meta.ts","../../../projects/lib/meta/ngwr-meta.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrMetaConfig } from './interfaces';\n\n/** App-wide defaults registered via {@link provideWrMeta}. */\nexport const WR_META_DEFAULTS = new InjectionToken<WrMetaConfig>('WR_META_DEFAULTS', {\n factory: (): WrMetaConfig => ({}),\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DOCUMENT } from '@angular/common';\nimport { Injector, Service, computed, effect, inject, signal, untracked } from '@angular/core';\nimport { Meta, Title } from '@angular/platform-browser';\n\nimport type { WrMetaConfig, WrMetaHandle } from './interfaces';\nimport { WR_META_DEFAULTS } from './tokens';\n\n/** Deep-merge two `WrMetaConfig` layers — later wins for scalars + nested groups. */\nfunction merge(base: WrMetaConfig, top: WrMetaConfig): WrMetaConfig {\n return {\n ...base,\n ...top,\n og: { ...base.og, ...top.og },\n twitter: { ...base.twitter, ...top.twitter },\n };\n}\n\n/**\n * Centralised `<head>` metadata manager — title, description, keywords,\n * canonical, Open Graph and Twitter Card tags.\n *\n * Stack-based: `push(config)` adds a layer (returned handle pops it),\n * `set(config)` replaces the current top, `reset()` clears all overrides.\n * Layers merge via shallow merge for scalars and a one-level deep merge\n * for `og` / `twitter` groups.\n *\n * The resolved metadata is applied diff-style — only changed tags are\n * touched in the DOM, so reads of `document.head` stay cheap.\n *\n * @example\n * ```ts\n * const meta = inject(WrMeta);\n * meta.set({ title: 'Pricing', description: 'Plans for every team.' });\n *\n * // From a route component — auto-pop on destroy via the directive:\n * <div [wrMeta]=\"{ title: 'Pricing' }\">\n * ```\n *\n * @see https://ngwr.dev/reference/services/meta\n */\n@Service()\nexport class WrMeta {\n private readonly title = inject(Title);\n private readonly meta = inject(Meta);\n private readonly doc = inject(DOCUMENT);\n private readonly defaults = inject(WR_META_DEFAULTS);\n private readonly injector = inject(Injector);\n\n /** Stack of meta layers. Bottom = defaults, top = currently applied. */\n private readonly stack = signal<readonly WrMetaConfig[]>([this.defaults]);\n\n /** Resolved (merged) metadata at the top of the stack. */\n readonly resolved = computed(() => this.stack().reduce((acc, layer) => merge(acc, layer), {} as WrMetaConfig));\n\n /** Last applied snapshot — used to diff against the next resolution. */\n private applied: WrMetaConfig = {};\n\n constructor() {\n // Apply defaults immediately on construction.\n this.apply();\n }\n\n /** Snapshot of the resolved metadata currently in the DOM. */\n current(): Readonly<WrMetaConfig> {\n return this.applied;\n }\n\n /** Replace the top layer (or create one if only defaults are present). */\n set(config: WrMetaConfig): void {\n this.stack.update(stack => {\n if (stack.length <= 1) return [...stack, config];\n return [...stack.slice(0, -1), config];\n });\n this.apply();\n }\n\n /** Push a new layer. Returns a handle whose `.pop()` removes it. */\n push(config: WrMetaConfig): WrMetaHandle {\n this.stack.update(stack => [...stack, config]);\n this.apply();\n const target = config;\n return {\n pop: () => {\n this.stack.update(stack => {\n const idx = stack.lastIndexOf(target);\n if (idx <= 0) return stack;\n return [...stack.slice(0, idx), ...stack.slice(idx + 1)];\n });\n this.apply();\n },\n };\n }\n\n /**\n * Reactive layer. Runs `factory` inside an effect and re-applies the\n * resolved metadata whenever any signal it reads changes — so a title\n * (or any field) built from {@link WrI18n}'s `t()` updates live on\n * locale switch, with no manual re-`set()`.\n *\n * Returns a handle whose `.pop()` removes the layer and stops the effect.\n * Safe to call outside an injection context.\n *\n * @example Locale-aware title\n * ```ts\n * const meta = inject(WrMeta);\n * const i18n = inject(WrI18n);\n *\n * // `i18n.t(...)` tracks the active locale, so the title re-renders\n * // every time `i18n.use(...)` switches languages.\n * meta.bind(() => ({\n * title: i18n.t('home.title'),\n * description: i18n.t('home.description'),\n * }));\n * ```\n */\n bind(factory: () => WrMetaConfig): WrMetaHandle {\n let current: WrMetaConfig | null = null;\n\n const ref = effect(\n () => {\n const next = factory();\n // Recompute is reactive; the stack write + DOM apply are not, so\n // the effect only re-runs on `factory`'s own dependencies.\n untracked(() => {\n this.stack.update(stack => {\n if (current === null) return [...stack, next];\n const idx = stack.lastIndexOf(current);\n return idx < 0 ? [...stack, next] : [...stack.slice(0, idx), next, ...stack.slice(idx + 1)];\n });\n current = next;\n this.apply();\n });\n },\n { injector: this.injector }\n );\n\n return {\n pop: () => {\n ref.destroy();\n if (current === null) return;\n const target = current;\n current = null;\n this.stack.update(stack => {\n const idx = stack.lastIndexOf(target);\n if (idx <= 0) return stack;\n return [...stack.slice(0, idx), ...stack.slice(idx + 1)];\n });\n this.apply();\n },\n };\n }\n\n /** Pop the most recently pushed layer (defaults remain). */\n pop(): void {\n this.stack.update(stack => (stack.length <= 1 ? stack : stack.slice(0, -1)));\n this.apply();\n }\n\n /** Clear all overrides, restore the defaults registered via `provideWrMeta`. */\n reset(): void {\n this.stack.set([this.defaults]);\n this.apply();\n }\n\n // Internals\n\n private apply(): void {\n const next = this.resolved();\n this.diffTitle(next);\n this.diffMeta(next);\n this.diffLink(next);\n this.applied = next;\n }\n\n private diffTitle(next: WrMetaConfig): void {\n if (next.title === this.applied.title && next.titleTemplate === this.applied.titleTemplate) return;\n if (next.title) {\n // `{{ title }}` reads like Angular; `%s` stays for printf fans.\n const formatted = next.titleTemplate\n ? next.titleTemplate.replace(/\\{\\{\\s*title\\s*\\}\\}/g, next.title).replace('%s', next.title)\n : next.title;\n this.title.setTitle(formatted);\n } else if (this.applied.title) {\n this.title.setTitle('');\n }\n }\n\n private diffMeta(next: WrMetaConfig): void {\n this.updateName('description', next.description);\n this.updateName('keywords', next.keywords?.join(', '));\n this.updateName('theme-color', next.themeColor);\n\n // Open Graph.\n this.updateProp('og:title', next.og?.title ?? next.title);\n this.updateProp('og:description', next.og?.description ?? next.description);\n this.updateProp('og:image', next.og?.image);\n this.updateProp('og:url', next.og?.url ?? next.canonical);\n this.updateProp('og:type', next.og?.type);\n this.updateProp('og:site_name', next.og?.siteName);\n\n // Twitter.\n this.updateName('twitter:card', next.twitter?.card);\n this.updateName('twitter:title', next.twitter?.title ?? next.title);\n this.updateName('twitter:description', next.twitter?.description ?? next.description);\n this.updateName('twitter:image', next.twitter?.image ?? next.og?.image);\n this.updateName('twitter:creator', next.twitter?.creator);\n }\n\n private updateName(name: string, content: string | undefined): void {\n if (content) {\n this.meta.updateTag({ name, content }, `name='${name}'`);\n } else {\n this.meta.removeTag(`name='${name}'`);\n }\n }\n\n private updateProp(property: string, content: string | undefined): void {\n if (content) {\n this.meta.updateTag({ property, content }, `property='${property}'`);\n } else {\n this.meta.removeTag(`property='${property}'`);\n }\n }\n\n private diffLink(next: WrMetaConfig): void {\n if (next.canonical === this.applied.canonical) return;\n const head = this.doc.head;\n let link = head.querySelector<HTMLLinkElement>(\"link[rel='canonical']\");\n if (next.canonical) {\n if (!link) {\n link = this.doc.createElement('link');\n link.setAttribute('rel', 'canonical');\n head.appendChild(link);\n }\n link.setAttribute('href', next.canonical);\n } else if (link) {\n link.remove();\n }\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DestroyRef, Directive, effect, inject, input } from '@angular/core';\n\nimport type { WrMetaConfig, WrMetaHandle } from './interfaces';\nimport { WrMeta } from './wr-meta';\n\n/**\n * Declarative wrapper around {@link WrMeta}.\n *\n * - Pushes the bound config on init.\n * - Re-pushes (replacing) when the config reference changes.\n * - Pops the layer on destroy — perfect for route-level meta overrides.\n *\n * @example\n * ```html\n * <div [wrMeta]=\"{ title: 'Pricing', description: 'Plans for every team.' }\">\n * ```\n */\n@Directive({ selector: '[wrMeta]' })\nexport class WrMetaBinding {\n readonly wrMeta = input.required<WrMetaConfig>();\n\n private readonly metaService = inject(WrMeta);\n private handle: WrMetaHandle | null = null;\n\n constructor() {\n effect(() => {\n const next = this.wrMeta();\n this.handle?.pop();\n this.handle = this.metaService.push(next);\n });\n inject(DestroyRef).onDestroy(() => this.handle?.pop());\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\nimport type { WrMetaConfig } from './interfaces';\nimport { WR_META_DEFAULTS } from './tokens';\n\n/**\n * Register app-wide defaults for {@link WrMeta}. Use to set a\n * consistent baseline `title` / `titleTemplate` / `og` / `twitter` for every\n * route — individual routes / components can override via\n * `metaService.push(...)` or the `[wrMeta]` directive.\n *\n * @example\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideWrMeta({\n * titleTemplate: '{{ title }} · NGWR',\n * description: 'Angular UI components library',\n * og: { siteName: 'NGWR', type: 'website' },\n * twitter: { card: 'summary_large_image', creator: '@thekhegay' },\n * }),\n * ],\n * });\n * ```\n */\nexport function provideWrMeta(defaults: WrMetaConfig = {}): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: WR_META_DEFAULTS, useValue: defaults }]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AAMH;MACa,gBAAgB,GAAG,IAAI,cAAc,CAAe,kBAAkB,EAAE;AACnF,IAAA,OAAO,EAAE,OAAqB,EAAE,CAAC;AAClC,CAAA;;ACdD;;;;;AAKG;AASH;AACA,SAAS,KAAK,CAAC,IAAkB,EAAE,GAAiB,EAAA;IAClD,OAAO;AACL,QAAA,GAAG,IAAI;AACP,QAAA,GAAG,GAAG;QACN,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,GAAG,CAAC,EAAE,EAAE;QAC7B,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE;KAC7C;AACH;AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;MAEU,MAAM,CAAA;AACA,IAAA,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AACrB,IAAA,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;AACnB,IAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;AACtB,IAAA,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACnC,IAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;;AAG3B,IAAA,KAAK,GAAG,MAAM,CAA0B,CAAC,IAAI,CAAC,QAAQ,CAAC;8EAAC;;AAGhE,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,IAAI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AAA,EAAA,MAAA,EAAA,EAAA,iBAAA,EAAA,QAAA,EAAA,UAAA,EAAA,QAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBADzB,SAAS;mBAAC,EAAE,QAAQ,EAAE,UAAU,EAAE;;;ACxBnC;;;;;AAKG;AAOH;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,aAAa,CAAC,QAAA,GAAyB,EAAE,EAAA;AACvD,IAAA,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;AACtF;;AClCA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngwr-meta.mjs","sources":["../../../projects/lib/meta/tokens.ts","../../../projects/lib/meta/wr-meta.ts","../../../projects/lib/meta/wr-meta-binding.ts","../../../projects/lib/meta/provide-wr-meta.ts","../../../projects/lib/meta/ngwr-meta.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrMetaConfig } from './interfaces';\n\n/** App-wide defaults registered via {@link provideWrMeta}. */\nexport const WR_META_DEFAULTS = new InjectionToken<WrMetaConfig>('WR_META_DEFAULTS', {\n factory: (): WrMetaConfig => ({}),\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DOCUMENT } from '@angular/common';\nimport { Injector, Service, computed, effect, inject, signal, untracked } from '@angular/core';\nimport { Meta, Title } from '@angular/platform-browser';\n\nimport type { WrMetaConfig, WrMetaHandle } from './interfaces';\nimport { WR_META_DEFAULTS } from './tokens';\n\n/** Deep-merge two `WrMetaConfig` layers — later wins for scalars + nested groups. */\nfunction merge(base: WrMetaConfig, top: WrMetaConfig): WrMetaConfig {\n return {\n ...base,\n ...top,\n og: { ...base.og, ...top.og },\n twitter: { ...base.twitter, ...top.twitter },\n };\n}\n\n/**\n * Centralised `<head>` metadata manager — title, description, keywords,\n * canonical, Open Graph and Twitter Card tags.\n *\n * Stack-based: `push(config)` adds a layer (returned handle pops it),\n * `set(config)` replaces the current top, `reset()` clears all overrides.\n * Layers merge via shallow merge for scalars and a one-level deep merge\n * for `og` / `twitter` groups.\n *\n * The title and the canonical link are diffed against the last applied\n * snapshot and only rewritten when they actually change; the `<meta>` tags\n * are re-resolved by selector on every apply, so an existing tag is updated\n * in place rather than duplicated.\n *\n * @example\n * ```ts\n * const meta = inject(WrMeta);\n * meta.set({ title: 'Pricing', description: 'Plans for every team.' });\n *\n * // From a route component — auto-pop on destroy via the directive:\n * <div [wrMeta]=\"{ title: 'Pricing' }\">\n * ```\n *\n * @see https://ngwr.dev/reference/services/meta\n */\n@Service()\nexport class WrMeta {\n private readonly title = inject(Title);\n private readonly meta = inject(Meta);\n private readonly doc = inject(DOCUMENT);\n private readonly defaults = inject(WR_META_DEFAULTS);\n private readonly injector = inject(Injector);\n\n /** Stack of meta layers. Bottom = defaults, top = currently applied. */\n private readonly stack = signal<readonly WrMetaConfig[]>([this.defaults]);\n\n /** Resolved (merged) metadata at the top of the stack. */\n readonly resolved = computed(() => this.stack().reduce((acc, layer) => merge(acc, layer), {} as WrMetaConfig));\n\n /** Last applied snapshot — used to diff against the next resolution. */\n private applied: WrMetaConfig = {};\n\n constructor() {\n // Apply defaults immediately on construction.\n this.apply();\n }\n\n /** Snapshot of the resolved metadata currently in the DOM. */\n current(): Readonly<WrMetaConfig> {\n return this.applied;\n }\n\n /** Replace the top layer (or create one if only defaults are present). */\n set(config: WrMetaConfig): void {\n this.stack.update(stack => {\n if (stack.length <= 1) return [...stack, config];\n return [...stack.slice(0, -1), config];\n });\n this.apply();\n }\n\n /** Push a new layer. Returns a handle whose `.pop()` removes it. */\n push(config: WrMetaConfig): WrMetaHandle {\n // Copied so the layer has an identity of its own: the handle finds it by\n // reference, and pushing one shared config object twice would otherwise\n // give two layers the same identity — the first handle to pop would take\n // the second one's layer with it.\n const target: WrMetaConfig = { ...config };\n this.stack.update(stack => [...stack, target]);\n this.apply();\n return {\n pop: () => {\n this.stack.update(stack => {\n const idx = stack.lastIndexOf(target);\n if (idx <= 0) return stack;\n return [...stack.slice(0, idx), ...stack.slice(idx + 1)];\n });\n this.apply();\n },\n };\n }\n\n /**\n * Reactive layer. Runs `factory` inside an effect and re-applies the\n * resolved metadata whenever any signal it reads changes — so a title\n * (or any field) built from {@link WrI18n}'s `t()` updates live on\n * locale switch, with no manual re-`set()`.\n *\n * Returns a handle whose `.pop()` removes the layer and stops the effect.\n * Safe to call outside an injection context.\n *\n * @example Locale-aware title\n * ```ts\n * const meta = inject(WrMeta);\n * const i18n = inject(WrI18n);\n *\n * // `i18n.t(...)` tracks the active locale, so the title re-renders\n * // every time `i18n.use(...)` switches languages.\n * meta.bind(() => ({\n * title: i18n.t('home.title'),\n * description: i18n.t('home.description'),\n * }));\n * ```\n */\n bind(factory: () => WrMetaConfig): WrMetaHandle {\n let current: WrMetaConfig | null = null;\n\n const ref = effect(\n () => {\n // Copied for the same reason as in `push`: the layer is located by\n // reference, so it must not share one with anybody else's.\n const next: WrMetaConfig = { ...factory() };\n // Recompute is reactive; the stack write + DOM apply are not, so\n // the effect only re-runs on `factory`'s own dependencies.\n untracked(() => {\n this.stack.update(stack => {\n if (current === null) return [...stack, next];\n const idx = stack.lastIndexOf(current);\n return idx < 0 ? [...stack, next] : [...stack.slice(0, idx), next, ...stack.slice(idx + 1)];\n });\n current = next;\n this.apply();\n });\n },\n { injector: this.injector }\n );\n\n return {\n pop: () => {\n ref.destroy();\n if (current === null) return;\n const target = current;\n current = null;\n this.stack.update(stack => {\n const idx = stack.lastIndexOf(target);\n if (idx <= 0) return stack;\n return [...stack.slice(0, idx), ...stack.slice(idx + 1)];\n });\n this.apply();\n },\n };\n }\n\n /** Pop the most recently pushed layer (defaults remain). */\n pop(): void {\n this.stack.update(stack => (stack.length <= 1 ? stack : stack.slice(0, -1)));\n this.apply();\n }\n\n /** Clear all overrides, restore the defaults registered via `provideWrMeta`. */\n reset(): void {\n this.stack.set([this.defaults]);\n this.apply();\n }\n\n // Internals\n\n private apply(): void {\n const next = this.resolved();\n this.diffTitle(next);\n this.diffMeta(next);\n this.diffLink(next);\n this.applied = next;\n }\n\n private diffTitle(next: WrMetaConfig): void {\n if (next.title === this.applied.title && next.titleTemplate === this.applied.titleTemplate) return;\n if (next.title) {\n // `{{ title }}` reads like Angular; `%s` stays for printf fans.\n const formatted = next.titleTemplate\n ? next.titleTemplate.replace(/\\{\\{\\s*title\\s*\\}\\}/g, next.title).replace('%s', next.title)\n : next.title;\n this.title.setTitle(formatted);\n } else if (this.applied.title) {\n this.title.setTitle('');\n }\n }\n\n private diffMeta(next: WrMetaConfig): void {\n this.updateName('description', next.description);\n this.updateName('keywords', next.keywords?.join(', '));\n this.updateName('theme-color', next.themeColor);\n\n // Open Graph.\n this.updateProp('og:title', next.og?.title ?? next.title);\n this.updateProp('og:description', next.og?.description ?? next.description);\n this.updateProp('og:image', next.og?.image);\n this.updateProp('og:url', next.og?.url ?? next.canonical);\n this.updateProp('og:type', next.og?.type);\n this.updateProp('og:site_name', next.og?.siteName);\n\n // Twitter.\n this.updateName('twitter:card', next.twitter?.card);\n this.updateName('twitter:title', next.twitter?.title ?? next.title);\n this.updateName('twitter:description', next.twitter?.description ?? next.description);\n this.updateName('twitter:image', next.twitter?.image ?? next.og?.image);\n this.updateName('twitter:creator', next.twitter?.creator);\n }\n\n private updateName(name: string, content: string | undefined): void {\n if (content) {\n this.meta.updateTag({ name, content }, `name='${name}'`);\n } else {\n this.meta.removeTag(`name='${name}'`);\n }\n }\n\n private updateProp(property: string, content: string | undefined): void {\n if (content) {\n this.meta.updateTag({ property, content }, `property='${property}'`);\n } else {\n this.meta.removeTag(`property='${property}'`);\n }\n }\n\n private diffLink(next: WrMetaConfig): void {\n if (next.canonical === this.applied.canonical) return;\n const head = this.doc.head;\n let link = head.querySelector<HTMLLinkElement>(\"link[rel='canonical']\");\n if (next.canonical) {\n if (!link) {\n link = this.doc.createElement('link');\n link.setAttribute('rel', 'canonical');\n head.appendChild(link);\n }\n link.setAttribute('href', next.canonical);\n } else if (link) {\n link.remove();\n }\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DestroyRef, Directive, effect, inject, input, untracked } from '@angular/core';\n\nimport type { WrMetaConfig, WrMetaHandle } from './interfaces';\nimport { WrMeta } from './wr-meta';\n\n/**\n * Declarative wrapper around {@link WrMeta}.\n *\n * - Pushes the bound config on init.\n * - Re-pushes (replacing) when the config reference changes.\n * - Pops the layer on destroy — perfect for route-level meta overrides.\n *\n * @example\n * ```html\n * <div [wrMeta]=\"{ title: 'Pricing', description: 'Plans for every team.' }\">\n * ```\n */\n@Directive({ selector: '[wrMeta]' })\nexport class WrMetaBinding {\n readonly wrMeta = input.required<WrMetaConfig>();\n\n private readonly metaService = inject(WrMeta);\n private handle: WrMetaHandle | null = null;\n\n constructor() {\n effect(() => {\n const next = this.wrMeta();\n // Only the INPUT is read reactively. `push` / `pop` write the service's\n // layer stack and then re-apply, and applying reads that same stack through\n // `resolved()` — so without this the effect depends on a signal it writes\n // and re-runs forever. `WrMeta.bind()` guards the identical pair the same\n // way; this directive was missing it.\n untracked(() => {\n this.handle?.pop();\n this.handle = this.metaService.push(next);\n });\n });\n inject(DestroyRef).onDestroy(() => this.handle?.pop());\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\nimport type { WrMetaConfig } from './interfaces';\nimport { WR_META_DEFAULTS } from './tokens';\n\n/**\n * Register app-wide defaults for {@link WrMeta}. Use to set a\n * consistent baseline `title` / `titleTemplate` / `og` / `twitter` for every\n * route — individual routes / components can override via\n * `metaService.push(...)` or the `[wrMeta]` directive.\n *\n * @example\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideWrMeta({\n * titleTemplate: '{{ title }} · NGWR',\n * description: 'Angular UI components library',\n * og: { siteName: 'NGWR', type: 'website' },\n * twitter: { card: 'summary_large_image', creator: '@thekhegay' },\n * }),\n * ],\n * });\n * ```\n */\nexport function provideWrMeta(defaults: WrMetaConfig = {}): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: WR_META_DEFAULTS, useValue: defaults }]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AAMH;MACa,gBAAgB,GAAG,IAAI,cAAc,CAAe,kBAAkB,EAAE;AACnF,IAAA,OAAO,EAAE,OAAqB,EAAE,CAAC;AAClC,CAAA;;ACdD;;;;;AAKG;AASH;AACA,SAAS,KAAK,CAAC,IAAkB,EAAE,GAAiB,EAAA;IAClD,OAAO;AACL,QAAA,GAAG,IAAI;AACP,QAAA,GAAG,GAAG;QACN,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,GAAG,CAAC,EAAE,EAAE;QAC7B,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE;KAC7C;AACH;AAEA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;MAEU,MAAM,CAAA;AACA,IAAA,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AACrB,IAAA,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;AACnB,IAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;AACtB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AAI,CAAC;AAC3C,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;AACF,QAAA,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC;IACxD;uGApBW,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAb,aAAa,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,UAAA,EAAA,MAAA,EAAA,EAAA,MAAA,EAAA,EAAA,iBAAA,EAAA,QAAA,EAAA,UAAA,EAAA,QAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBADzB,SAAS;mBAAC,EAAE,QAAQ,EAAE,UAAU,EAAE;;;ACxBnC;;;;;AAKG;AAOH;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,aAAa,CAAC,QAAA,GAAyB,EAAE,EAAA;AACvD,IAAA,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;AACtF;;AClCA;;AAEG;;;;"}
|
|
@@ -45,33 +45,47 @@ class WrMeterGroup {
|
|
|
45
45
|
max = input(0, { ...(ngDevMode ? { debugName: "max" } : /* istanbul ignore next */ {}), transform: (v) => Math.max(0, coerceNumberProperty(v, 0)) });
|
|
46
46
|
/** Show the labelled legend under the bar. @default true */
|
|
47
47
|
showLegend = input(true, { ...(ngDevMode ? { debugName: "showLegend" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
|
|
48
|
-
/** Show each segment's
|
|
48
|
+
/** Show each segment's value in the legend, next to its label. @default true */
|
|
49
49
|
showValues = input(true, { ...(ngDevMode ? { debugName: "showValues" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
|
|
50
|
+
/**
|
|
51
|
+
* A segment's contribution, floored at `0` and with anything non-finite read
|
|
52
|
+
* as `0`. One `NaN` used to poison the whole bar: the sum is `NaN` as soon as
|
|
53
|
+
* one value is, so the total fell back to `1` and every OTHER segment was
|
|
54
|
+
* asked for a width of `value * 100`%, while `aria-valuenow` announced `NaN`.
|
|
55
|
+
*/
|
|
56
|
+
static amount(raw) {
|
|
57
|
+
return Number.isFinite(raw) ? Math.max(0, raw) : 0;
|
|
58
|
+
}
|
|
50
59
|
resolvedMax = computed(() => {
|
|
51
60
|
const explicit = this.max();
|
|
52
61
|
if (explicit > 0)
|
|
53
62
|
return explicit;
|
|
54
|
-
const sum = this.segments().reduce((acc, s) => acc +
|
|
63
|
+
const sum = this.segments().reduce((acc, s) => acc + WrMeterGroup.amount(s.value), 0);
|
|
55
64
|
return sum > 0 ? sum : 1;
|
|
56
65
|
}, /* @ts-ignore */
|
|
57
66
|
...(ngDevMode ? [{ debugName: "resolvedMax" }] : /* istanbul ignore next */ []));
|
|
58
67
|
/**
|
|
59
68
|
* Sum of the segments, for `aria-valuenow`. `role="progressbar"` without it
|
|
60
69
|
* announces no value at all, so the bar was invisible to assistive tech.
|
|
70
|
+
*
|
|
71
|
+
* Capped at the total, because segments summing past an explicit `max` used
|
|
72
|
+
* to announce a value outside the range they were announced against.
|
|
61
73
|
*/
|
|
62
|
-
totalValue = computed(() => this.segments().reduce((acc, s) => acc +
|
|
74
|
+
totalValue = computed(() => Math.min(this.resolvedMax(), this.segments().reduce((acc, s) => acc + WrMeterGroup.amount(s.value), 0)), /* @ts-ignore */
|
|
63
75
|
...(ngDevMode ? [{ debugName: "totalValue" }] : /* istanbul ignore next */ []));
|
|
64
76
|
slices = computed(() => this.segments().map((segment, i) => ({
|
|
65
77
|
label: segment.label,
|
|
66
|
-
value
|
|
78
|
+
// The legend keeps a negative value visible — it is data the caller gave
|
|
79
|
+
// us — but not a non-finite one, which reads as the literal text `NaN`.
|
|
80
|
+
value: Number.isFinite(segment.value) ? segment.value : 0,
|
|
67
81
|
color: segment.color ?? FALLBACK_COLORS[i % FALLBACK_COLORS.length],
|
|
68
|
-
percent: (
|
|
82
|
+
percent: (WrMeterGroup.amount(segment.value) / this.resolvedMax()) * 100,
|
|
69
83
|
})), /* @ts-ignore */
|
|
70
84
|
...(ngDevMode ? [{ debugName: "slices" }] : /* istanbul ignore next */ []));
|
|
71
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.
|
|
72
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.
|
|
85
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMeterGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
86
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: WrMeterGroup, isStandalone: true, selector: "wr-meter-group", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, segments: { classPropertyName: "segments", publicName: "segments", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, showValues: { classPropertyName: "showValues", publicName: "showValues", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "wr-meter-group" }, ngImport: i0, template: "<div\n class=\"wr-meter-group__bar\"\n role=\"progressbar\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"resolvedMax()\"\n [attr.aria-valuenow]=\"totalValue()\"\n>\n @for (slice of slices(); track $index) {\n <span\n class=\"wr-meter-group__slice\"\n [title]=\"slice.label\"\n [style.width.%]=\"slice.percent\"\n [style.background]=\"slice.color\"\n ></span>\n }\n</div>\n\n@if (showLegend() && slices().length > 0) {\n <ul class=\"wr-meter-group__legend\">\n @for (slice of slices(); track $index) {\n <li class=\"wr-meter-group__legend-item\">\n <span class=\"wr-meter-group__swatch\" aria-hidden=\"true\" [style.background]=\"slice.color\"></span>\n <span class=\"wr-meter-group__legend-label\">{{ slice.label }}</span>\n @if (showValues()) {\n <span class=\"wr-meter-group__legend-value\">{{ slice.value }}</span>\n }\n </li>\n }\n </ul>\n}\n", encapsulation: i0.ViewEncapsulation.None });
|
|
73
87
|
}
|
|
74
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.
|
|
88
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrMeterGroup, decorators: [{
|
|
75
89
|
type: Component,
|
|
76
90
|
args: [{ selector: 'wr-meter-group', encapsulation: ViewEncapsulation.None, host: { class: 'wr-meter-group' }, template: "<div\n class=\"wr-meter-group__bar\"\n role=\"progressbar\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"resolvedMax()\"\n [attr.aria-valuenow]=\"totalValue()\"\n>\n @for (slice of slices(); track $index) {\n <span\n class=\"wr-meter-group__slice\"\n [title]=\"slice.label\"\n [style.width.%]=\"slice.percent\"\n [style.background]=\"slice.color\"\n ></span>\n }\n</div>\n\n@if (showLegend() && slices().length > 0) {\n <ul class=\"wr-meter-group__legend\">\n @for (slice of slices(); track $index) {\n <li class=\"wr-meter-group__legend-item\">\n <span class=\"wr-meter-group__swatch\" aria-hidden=\"true\" [style.background]=\"slice.color\"></span>\n <span class=\"wr-meter-group__legend-label\">{{ slice.label }}</span>\n @if (showValues()) {\n <span class=\"wr-meter-group__legend-value\">{{ slice.value }}</span>\n }\n </li>\n }\n </ul>\n}\n" }]
|
|
77
91
|
}], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], segments: [{ type: i0.Input, args: [{ isSignal: true, alias: "segments", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], showLegend: [{ type: i0.Input, args: [{ isSignal: true, alias: "showLegend", required: false }] }], showValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "showValues", required: false }] }] } });
|