ngwr 16.2.0 → 16.4.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/badge/styles/_tag.scss +73 -1
- package/calendar/styles/_index.scss +22 -0
- package/carousel/styles/_index.scss +53 -1
- package/cascader/styles/_rules.scss +7 -0
- package/color-picker/styles/_index.scss +21 -0
- package/date-picker/styles/_index.scss +19 -0
- package/dropdown/styles/_index.scss +13 -19
- package/fesm2022/ngwr-affix.mjs +3 -3
- package/fesm2022/ngwr-alert-testing.mjs +70 -0
- package/fesm2022/ngwr-alert-testing.mjs.map +1 -0
- package/fesm2022/ngwr-alert.mjs +3 -3
- package/fesm2022/ngwr-anchor.mjs +17 -6
- package/fesm2022/ngwr-anchor.mjs.map +1 -1
- package/fesm2022/ngwr-animations-aurora.mjs +3 -3
- package/fesm2022/ngwr-animations-blur-reveal.mjs +3 -3
- package/fesm2022/ngwr-animations-click-sparks.mjs +3 -3
- package/fesm2022/ngwr-animations-confetti.mjs +3 -3
- package/fesm2022/ngwr-animations-decode.mjs +3 -3
- package/fesm2022/ngwr-animations-destruct.mjs +3 -3
- package/fesm2022/ngwr-animations-dot-grid.mjs +3 -3
- package/fesm2022/ngwr-animations-falling-letters.mjs +3 -3
- package/fesm2022/ngwr-animations-flow-lines.mjs +3 -3
- package/fesm2022/ngwr-animations-fluid-cursor.mjs +3 -3
- package/fesm2022/ngwr-animations-glitch.mjs +3 -3
- package/fesm2022/ngwr-animations-glow-border.mjs +3 -3
- package/fesm2022/ngwr-animations-gradient-flow.mjs +3 -3
- package/fesm2022/ngwr-animations-marquee.mjs +3 -3
- package/fesm2022/ngwr-animations-orbit.mjs +3 -3
- package/fesm2022/ngwr-animations-reveal.mjs +3 -3
- package/fesm2022/ngwr-animations-ripple-grid.mjs +3 -3
- package/fesm2022/ngwr-animations-rotate-reveal.mjs +3 -3
- package/fesm2022/ngwr-animations-shimmer.mjs +3 -3
- package/fesm2022/ngwr-animations-spotlight.mjs +3 -3
- package/fesm2022/ngwr-animations-thread-lines.mjs +3 -3
- package/fesm2022/ngwr-animations-tilt.mjs +3 -3
- package/fesm2022/ngwr-animations-typewriter.mjs +3 -3
- package/fesm2022/ngwr-avatar.mjs +3 -3
- package/fesm2022/ngwr-back-top.mjs +3 -3
- package/fesm2022/ngwr-badge.mjs +129 -11
- package/fesm2022/ngwr-badge.mjs.map +1 -1
- package/fesm2022/ngwr-breadcrumbs-testing.mjs +83 -0
- package/fesm2022/ngwr-breadcrumbs-testing.mjs.map +1 -0
- package/fesm2022/ngwr-breadcrumbs.mjs +8 -8
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-burger-testing.mjs +45 -0
- package/fesm2022/ngwr-burger-testing.mjs.map +1 -0
- package/fesm2022/ngwr-burger.mjs +3 -3
- package/fesm2022/ngwr-button.mjs +6 -6
- package/fesm2022/ngwr-calendar-testing.mjs +18 -0
- package/fesm2022/ngwr-calendar-testing.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +500 -73
- package/fesm2022/ngwr-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-card.mjs +9 -9
- package/fesm2022/ngwr-carousel-testing.mjs +24 -1
- package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
- package/fesm2022/ngwr-carousel.mjs +73 -10
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +45 -37
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart.mjs +5 -4
- package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-bullet-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +3 -3
- package/fesm2022/ngwr-charts-candlestick-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-chart-legend.mjs +26 -11
- package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
- package/fesm2022/ngwr-charts-core.mjs +3 -3
- package/fesm2022/ngwr-charts-donut-chart.mjs +5 -4
- package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-gauge.mjs +3 -3
- package/fesm2022/ngwr-charts-heatmap-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-line-chart-testing.mjs +3 -2
- package/fesm2022/ngwr-charts-line-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart.mjs +17 -7
- package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group.mjs +5 -4
- package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart.mjs +5 -4
- package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart.mjs +5 -4
- package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-sparkline.mjs +3 -3
- package/fesm2022/ngwr-charts-treemap-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-waterfall-chart.mjs +3 -3
- package/fesm2022/ngwr-checkbox.mjs +6 -6
- package/fesm2022/ngwr-clipboard.mjs +3 -3
- package/fesm2022/ngwr-collapse.mjs +9 -9
- package/fesm2022/ngwr-color-picker-testing.mjs +11 -1
- package/fesm2022/ngwr-color-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +153 -37
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-command-palette.mjs +3 -3
- package/fesm2022/ngwr-comment.mjs +10 -6
- package/fesm2022/ngwr-comment.mjs.map +1 -1
- package/fesm2022/ngwr-compare-testing.mjs +84 -0
- package/fesm2022/ngwr-compare-testing.mjs.map +1 -0
- package/fesm2022/ngwr-compare.mjs +3 -3
- package/fesm2022/ngwr-context-menu.mjs +28 -13
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-cookie.mjs +3 -3
- package/fesm2022/ngwr-copy-value.mjs +3 -3
- package/fesm2022/ngwr-counter.mjs +6 -6
- package/fesm2022/ngwr-date-picker-testing.mjs +30 -4
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +342 -69
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp.mjs +3 -3
- package/fesm2022/ngwr-date.mjs +59 -8
- package/fesm2022/ngwr-date.mjs.map +1 -1
- package/fesm2022/ngwr-density.mjs +6 -6
- package/fesm2022/ngwr-descriptions.mjs +6 -6
- package/fesm2022/ngwr-dialog.mjs +18 -18
- package/fesm2022/ngwr-directives.mjs +15 -15
- package/fesm2022/ngwr-divider.mjs +3 -3
- package/fesm2022/ngwr-drawer.mjs +51 -29
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown-testing.mjs +11 -3
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +70 -99
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +4 -3
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-empty.mjs +3 -3
- package/fesm2022/ngwr-event-calendar.mjs +186 -33
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload-testing.mjs +34 -2
- package/fesm2022/ngwr-file-upload-testing.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +279 -16
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +9 -9
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-graph-testing.mjs +30 -0
- package/fesm2022/ngwr-graph-testing.mjs.map +1 -1
- package/fesm2022/ngwr-graph.mjs +664 -43
- package/fesm2022/ngwr-graph.mjs.map +1 -1
- package/fesm2022/ngwr-hotkey.mjs +6 -6
- package/fesm2022/ngwr-i18n-ar.mjs +27 -8
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +27 -8
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +27 -8
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +27 -8
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +27 -8
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +27 -8
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +27 -8
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +27 -8
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +27 -8
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +27 -8
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +27 -8
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +27 -8
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +27 -8
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +27 -8
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +27 -8
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +27 -8
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +27 -8
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +27 -8
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +27 -8
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +27 -8
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +27 -8
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +27 -8
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +9 -9
- package/fesm2022/ngwr-icon.mjs +6 -6
- package/fesm2022/ngwr-image-cropper.mjs +3 -3
- package/fesm2022/ngwr-input-number-testing.mjs +11 -0
- package/fesm2022/ngwr-input-number-testing.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +68 -7
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +23 -3
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input-testing.mjs +24 -1
- package/fesm2022/ngwr-input-testing.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +152 -36
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-keyboard.mjs +3 -3
- package/fesm2022/ngwr-knob.mjs +3 -3
- package/fesm2022/ngwr-layout.mjs +15 -15
- package/fesm2022/ngwr-lightbox.mjs +8 -8
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +8 -8
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-load-state.mjs +15 -15
- package/fesm2022/ngwr-loading-bar.mjs +6 -6
- package/fesm2022/ngwr-mention.mjs +6 -6
- package/fesm2022/ngwr-meta.mjs +6 -6
- package/fesm2022/ngwr-overlay.mjs +175 -13
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-page-header.mjs +3 -3
- package/fesm2022/ngwr-pagination.mjs +6 -3
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +31 -29
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-platform.mjs +9 -9
- package/fesm2022/ngwr-popconfirm-testing.mjs +5 -2
- package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm.mjs +44 -63
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover-testing.mjs +7 -1
- package/fesm2022/ngwr-popover-testing.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +58 -156
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-progress.mjs +50 -9
- package/fesm2022/ngwr-progress.mjs.map +1 -1
- package/fesm2022/ngwr-pull-to-refresh-testing.mjs +57 -0
- package/fesm2022/ngwr-pull-to-refresh-testing.mjs.map +1 -0
- package/fesm2022/ngwr-pull-to-refresh.mjs +3 -3
- package/fesm2022/ngwr-qr.mjs +3 -3
- package/fesm2022/ngwr-radio.mjs +6 -6
- package/fesm2022/ngwr-rating.mjs +3 -3
- package/fesm2022/ngwr-resizable-testing.mjs +113 -0
- package/fesm2022/ngwr-resizable-testing.mjs.map +1 -0
- package/fesm2022/ngwr-resizable.mjs +3 -3
- package/fesm2022/ngwr-result.mjs +12 -12
- package/fesm2022/ngwr-schema-form-testing.mjs +336 -0
- package/fesm2022/ngwr-schema-form-testing.mjs.map +1 -0
- package/fesm2022/ngwr-schema-form.mjs +416 -19
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-scroll.mjs +3 -3
- package/fesm2022/ngwr-segmented.mjs +3 -3
- package/fesm2022/ngwr-select-testing.mjs +19 -0
- package/fesm2022/ngwr-select-testing.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +361 -84
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-sidebar-testing.mjs +176 -0
- package/fesm2022/ngwr-sidebar-testing.mjs.map +1 -0
- package/fesm2022/ngwr-sidebar.mjs +3 -3
- package/fesm2022/ngwr-skeleton.mjs +3 -3
- package/fesm2022/ngwr-slider-testing.mjs +6 -0
- package/fesm2022/ngwr-slider-testing.mjs.map +1 -1
- package/fesm2022/ngwr-slider.mjs +21 -3
- package/fesm2022/ngwr-slider.mjs.map +1 -1
- package/fesm2022/ngwr-sortable-list.mjs +29 -12
- package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +3 -3
- package/fesm2022/ngwr-spinner.mjs +3 -3
- package/fesm2022/ngwr-splitter.mjs +3 -3
- package/fesm2022/ngwr-statistic.mjs +9 -9
- package/fesm2022/ngwr-stepper.mjs +42 -11
- package/fesm2022/ngwr-stepper.mjs.map +1 -1
- package/fesm2022/ngwr-storage.mjs +3 -3
- package/fesm2022/ngwr-switch.mjs +3 -3
- package/fesm2022/ngwr-table-testing.mjs +157 -3
- package/fesm2022/ngwr-table-testing.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +1051 -74
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tabs-router.mjs +3 -3
- package/fesm2022/ngwr-tabs-testing.mjs +1 -1
- package/fesm2022/ngwr-tabs-testing.mjs.map +1 -1
- package/fesm2022/ngwr-tabs.mjs +15 -10
- package/fesm2022/ngwr-tabs.mjs.map +1 -1
- package/fesm2022/ngwr-textarea-testing.mjs +11 -0
- package/fesm2022/ngwr-textarea-testing.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +128 -16
- package/fesm2022/ngwr-textarea.mjs.map +1 -1
- package/fesm2022/ngwr-theme.mjs +3 -3
- package/fesm2022/ngwr-timeline.mjs +6 -6
- package/fesm2022/ngwr-toast.mjs +40 -19
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-toolbar.mjs +3 -3
- package/fesm2022/ngwr-tour-testing.mjs +13 -1
- package/fesm2022/ngwr-tour-testing.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +19 -15
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-transfer-testing.mjs +6 -0
- package/fesm2022/ngwr-transfer-testing.mjs.map +1 -1
- package/fesm2022/ngwr-transfer.mjs +24 -5
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree-testing.mjs +62 -2
- package/fesm2022/ngwr-tree-testing.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +978 -79
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-typography.mjs +3 -3
- package/fesm2022/ngwr-utils-router.mjs +3 -3
- package/fesm2022/ngwr-utils.mjs +97 -1
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-virtual-scroll.mjs +3 -3
- package/fesm2022/ngwr-window.mjs +33 -22
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/file-upload/styles/_index.scss +156 -0
- package/graph/styles/_index.scss +87 -0
- package/i18n/ar.json +29 -8
- package/i18n/cs.json +29 -8
- package/i18n/de.json +29 -8
- package/i18n/en.json +29 -8
- package/i18n/es.json +29 -8
- package/i18n/fr.json +29 -8
- package/i18n/he.json +29 -8
- package/i18n/hi.json +29 -8
- package/i18n/id.json +29 -8
- package/i18n/it.json +29 -8
- package/i18n/ja.json +29 -8
- package/i18n/ko.json +29 -8
- package/i18n/nl.json +29 -8
- package/i18n/pl.json +29 -8
- package/i18n/pt.json +29 -8
- package/i18n/ru.json +29 -8
- package/i18n/sv.json +29 -8
- package/i18n/tr.json +29 -8
- package/i18n/uk.json +29 -8
- package/i18n/vi.json +29 -8
- package/i18n/zh-TW.json +29 -8
- package/i18n/zh.json +29 -8
- package/input/styles/_index.scss +68 -1
- package/input-otp/styles/_index.scss +14 -0
- package/llms-full.txt +53 -21
- package/llms.txt +57 -24
- package/overlay/styles/_arrow.scss +4 -4
- package/package.json +33 -1
- package/popconfirm/styles/_index.scss +3 -11
- package/progress/styles/_index.scss +32 -0
- package/schema-form/styles/_index.scss +78 -0
- package/schematics/collection.json +5 -0
- package/schematics/eject/index.js +158 -0
- package/schematics/eject/schema.js +8 -0
- package/schematics/eject/schema.json +24 -0
- package/schematics/eject/source.js +295 -0
- package/schematics/use/rule.js +2 -0
- package/schematics/use/symbol-map.json +5 -0
- package/select/styles/_index.scss +127 -22
- package/skills/ngwr/SKILL.md +31 -4
- package/skills/ngwr/references/catalog.md +9 -1
- package/slider/styles/_index.scss +22 -0
- package/table/styles/_index.scss +191 -3
- package/textarea/styles/_index.scss +80 -0
- package/theme/styles/_focus.scss +16 -1
- package/theme/styles/_motion.scss +5 -0
- package/transfer/styles/_index.scss +84 -0
- package/tree/styles/_index.scss +138 -5
- package/types/ngwr-alert-testing.d.ts +88 -0
- package/types/ngwr-badge.d.ts +72 -2
- package/types/ngwr-breadcrumbs-testing.d.ts +92 -0
- package/types/ngwr-burger-testing.d.ts +51 -0
- package/types/ngwr-calendar-testing.d.ts +18 -6
- package/types/ngwr-calendar.d.ts +272 -22
- package/types/ngwr-carousel-testing.d.ts +27 -6
- package/types/ngwr-carousel.d.ts +42 -6
- package/types/ngwr-cascader.d.ts +13 -6
- package/types/ngwr-charts-chart-legend.d.ts +9 -4
- package/types/ngwr-charts-line-chart-testing.d.ts +4 -1
- package/types/ngwr-charts-line-chart.d.ts +7 -4
- package/types/ngwr-color-picker-testing.d.ts +15 -4
- package/types/ngwr-color-picker.d.ts +76 -6
- package/types/ngwr-compare-testing.d.ts +72 -0
- package/types/ngwr-context-menu.d.ts +2 -0
- package/types/ngwr-date-picker-testing.d.ts +23 -8
- package/types/ngwr-date-picker.d.ts +100 -9
- package/types/ngwr-date.d.ts +71 -1
- package/types/ngwr-drawer.d.ts +9 -0
- package/types/ngwr-dropdown-testing.d.ts +20 -0
- package/types/ngwr-dropdown.d.ts +26 -6
- package/types/ngwr-event-calendar.d.ts +66 -8
- package/types/ngwr-file-upload-testing.d.ts +31 -2
- package/types/ngwr-file-upload.d.ts +156 -3
- package/types/ngwr-form.d.ts +47 -3
- package/types/ngwr-graph-testing.d.ts +36 -3
- package/types/ngwr-graph.d.ts +309 -13
- package/types/ngwr-input-number-testing.d.ts +10 -0
- package/types/ngwr-input-number.d.ts +30 -1
- package/types/ngwr-input-otp.d.ts +10 -0
- package/types/ngwr-input-testing.d.ts +30 -0
- package/types/ngwr-input.d.ts +54 -3
- package/types/ngwr-overlay.d.ts +84 -5
- package/types/ngwr-pipes.d.ts +2 -1
- package/types/ngwr-popconfirm-testing.d.ts +12 -3
- package/types/ngwr-popconfirm.d.ts +28 -3
- package/types/ngwr-popover-testing.d.ts +19 -2
- package/types/ngwr-popover.d.ts +22 -2
- package/types/ngwr-progress.d.ts +29 -1
- package/types/ngwr-pull-to-refresh-testing.d.ts +83 -0
- package/types/ngwr-resizable-testing.d.ts +116 -0
- package/types/ngwr-schema-form-testing.d.ts +260 -0
- package/types/ngwr-schema-form.d.ts +76 -6
- package/types/ngwr-select-testing.d.ts +20 -0
- package/types/ngwr-select.d.ts +149 -11
- package/types/ngwr-sidebar-testing.d.ts +176 -0
- package/types/ngwr-slider-testing.d.ts +3 -1
- package/types/ngwr-slider.d.ts +21 -1
- package/types/ngwr-sortable-list.d.ts +6 -0
- package/types/ngwr-stepper.d.ts +20 -11
- package/types/ngwr-table-testing.d.ts +122 -7
- package/types/ngwr-table.d.ts +572 -50
- package/types/ngwr-tabs-testing.d.ts +14 -17
- package/types/ngwr-tabs.d.ts +6 -0
- package/types/ngwr-textarea-testing.d.ts +10 -0
- package/types/ngwr-textarea.d.ts +48 -2
- package/types/ngwr-toast.d.ts +8 -1
- package/types/ngwr-tour-testing.d.ts +10 -0
- package/types/ngwr-tour.d.ts +11 -2
- package/types/ngwr-transfer-testing.d.ts +3 -0
- package/types/ngwr-transfer.d.ts +24 -1
- package/types/ngwr-tree-testing.d.ts +65 -1
- package/types/ngwr-tree.d.ts +335 -12
- package/types/ngwr-utils.d.ts +107 -1
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr-window.d.ts +7 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-input-otp.mjs","names":[],"sources":["../../../projects/lib/input-otp/input-otp.ts","../../../projects/lib/input-otp/input-otp.html"],"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 { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n Injector,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n type ElementRef,\n untracked,\n viewChildren,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\nimport { wrIsComposing, wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrInputOtpMode, WrInputOtpSize } from './types';\n\n/**\n * Fixed-length one-time-code input. Renders one `<input>` per character,\n * auto-advances focus on typing, handles paste of a full code, and supports\n * masking like a password field.\n *\n * A signal-forms native control: it implements `FormValueControl<string>`, so\n * `[formField]` binds straight to its `value` model — no\n * `ControlValueAccessor` in between. `[(value)]` works standalone. Emits\n * `completed` whenever the code changes while all cells are filled (useful for\n * auto-submission).\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-input-otp [formField]=\"form.code\" length=\"6\" (completed)=\"verify($event)\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-input-otp [(value)]=\"code\" length=\"6\" (completed)=\"verify($event)\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/input-otp\n */\n@Component({\n selector: 'wr-input-otp',\n templateUrl: './input-otp.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-input-otp',\n '[class]': 'classes()',\n role: 'group',\n '[attr.aria-label]': 'groupName()',\n '[attr.aria-labelledby]': 'labelledBy()',\n },\n})\nexport class WrInputOtp implements FormValueControl<string> {\n private readonly dir = inject(Directionality, { optional: true });\n private readonly injector = inject(Injector);\n\n /** Accessible name of the whole strip. Falls back to `inputOtp.label`. */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'inputOtp.label', 'Verification code');\n\n /** Number of cells to render. Clamped to `[1, 20]`. @default 6 */\n readonly length = input(6, {\n transform: (v: unknown): number => Math.max(1, Math.min(20, coerceNumberProperty(v, 6))),\n });\n\n /** Character set per cell. @default 'numeric' */\n readonly mode = input<WrInputOtpMode>('numeric');\n\n /**\n * Control size — shares the `--wr-control-*` contract. A box carries no size\n * of its own: the host modifier sets `--wr-input-otp-size` / `-font` /\n * `-radius` / `-gap` and every box reads them from the cascade, so one value\n * sizes the whole strip however many boxes `length` renders. @default 'md'\n */\n readonly size = input<WrInputOtpSize>('md');\n\n /** Mask the typed characters like a password. @default false */\n readonly mask = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Disable interaction. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse edits while every box stays focusable and the code still submits.\n * Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * Each box is a real text input, so this is the native `readonly` attribute —\n * arrow keys, Home / End and selection keep working, which is the whole\n * difference from `disabled`. Paste is cancelled too, since a `paste` still\n * reaches a read-only input even though typing does not.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The surrounding `<wr-form-field>`'s error state — bound per BOX rather than\n * on the `role=\"group\"` host, because the box is what takes focus and a reader\n * queries the focused element.\n *\n * @internal\n */\n protected readonly fieldAria = useFormFieldAria();\n\n /**\n * The field's label names the strip, when there is one.\n *\n * The host is a `role=\"group\"`, which `<wr-form-field>`'s `<label for>` cannot\n * reach — `for` binds only to a labelable element — so a field wrapping this\n * rendered a label that named nothing and the strip announced its own generic\n * default instead. An explicit `ariaLabel` still wins over both.\n */\n protected readonly labelledBy = computed(() => (this.ariaLabel() ? null : this.fieldAria.labelledBy()));\n\n /** `null` while the field's label carries the name, or the two are announced together. */\n protected readonly groupName = computed(() => (this.labelledBy() ? null : this.resolvedAriaLabel()));\n\n /** Character shown in empty cells. @default '•' */\n readonly placeholder = input<string>('•');\n\n /** The entered code. Bound by `[formField]`, or two-way via `[(value)]`. */\n readonly value = model<string>('');\n\n /**\n * Fires on every change made while every cell holds a character — so\n * correcting a digit of an already-complete code emits again. Not latched on\n * the incomplete-to-complete transition: a host auto-submitting on it has to\n * guard its own re-entry, and gets the corrected code for free.\n */\n readonly completed = output<string>();\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n protected readonly cells = signal<readonly string[]>(Array.from({ length: 6 }, () => ''));\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-input-otp--${size}`);\n if (this.disabled()) parts.push('wr-input-otp--disabled');\n else if (this.readonly()) parts.push('wr-input-otp--readonly');\n return parts.join(' ');\n });\n\n protected readonly cellType = computed<'password' | 'text'>(() => (this.mask() ? 'password' : 'text'));\n protected readonly cellInputMode = computed(() => (this.mode() === 'numeric' ? 'numeric' : 'text'));\n\n private readonly digitLabel = useI18nFormatter('inputOtp.digit', 'Digit {{index}}');\n private readonly characterLabel = useI18nFormatter('inputOtp.character', 'Character {{index}}');\n\n protected readonly cellRefs = viewChildren<ElementRef<HTMLInputElement>>('cell');\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input-otp');\n // Resize the cell array whenever `length` changes — preserves existing\n // values, and tells the model about the ones it dropped.\n //\n // The write-back is the half that was missing. Shrinking `length` trimmed\n // the cells and left `value` holding the longer string: six boxes with\n // `123456` typed in, `length` set to 4, four boxes showing `1234` and a\n // form still submitting `123456` — a code the user could not see and had\n // no way to correct, since nothing resynced until the next keystroke. The\n // other effect cannot cover it: it tracks `value` alone and reads `length`\n // inside `untracked`, so a `length` change never re-runs it.\n effect(() => {\n const len = this.length();\n const current = untracked(() => this.cells());\n if (current.length === len) return;\n const next = Array.from({ length: len }, (_, i) => current[i] ?? '');\n this.cells.set(next);\n\n // ONLY when the resize threw characters away. Emitting on every resize\n // clobbers the first render — the array is sized before the `value`\n // effect has split an incoming code into it, so an empty `next` would\n // write `''` over the value the host just set.\n const dropped = current.slice(len).join('');\n if (dropped !== '') this.emitChange();\n });\n\n // Split an external `value` write back into cells (mirrors the old\n // writeValue). Skipped when the value is merely the echo of an in-cell\n // edit, so re-splitting can never shift or clobber what the user typed.\n effect(() => {\n // Coerce null/undefined to '' — a classic-forms binding can write null,\n // which the old `writeValue(v: string | null)` accepted too.\n const v = this.value() ?? '';\n untracked(() => {\n if (this.cells().join('') === v) return;\n const len = this.length();\n const raw = v.slice(0, len);\n const next = Array.from({ length: len }, (_, i) => this.sanitiseChar(raw[i] ?? ''));\n this.cells.set(next);\n });\n });\n }\n\n /**\n * Focus the strip — what Signal Forms calls to focus this control, from\n * `focusBoundControl()`. The host is a `role=\"group\"` with no tab stop of its\n * own, so the call goes to a box: the first EMPTY one, where the next\n * character belongs, or the first box once the code is complete, its\n * character selected so a keystroke replaces it.\n */\n focus(options?: FocusOptions): void {\n const empty = this.cells().indexOf('');\n this.focusCell(empty === -1 ? 0 : empty, options);\n }\n\n // Template handlers\n\n protected onInput(event: Event, index: number): void {\n // An input method leaves its half-built reading in the box and only replaces\n // it on `compositionend`. Sanitising that intermediate text writes `''` back\n // into the field the IME is still composing in, which aborts the conversion\n // outright — so the box is left alone until the text is real.\n if ((event as InputEvent).isComposing) return;\n this.commitCell(event.target as HTMLInputElement, index);\n }\n\n /** @see onInput — this is where an IME's text finally arrives. */\n protected onCompositionEnd(event: CompositionEvent, index: number): void {\n this.commitCell(event.target as HTMLInputElement, index);\n }\n\n private commitCell(target: HTMLInputElement, index: number): void {\n if (this.readonly()) {\n // A read-only input refuses typed characters on its own; this covers the\n // synthetic writes a script (or a spec) can still make.\n target.value = this.cells()[index] ?? '';\n return;\n }\n // The character just typed is the one before the caret, not the last one in the\n // box: typing into a filled box puts the new character beside the old, and where\n // depends on the caret — WebKit put it in FRONT, so `slice(-1)` kept the old one.\n const caret = target.selectionStart;\n const typed = caret ? target.value.slice(caret - 1, caret) : target.value.slice(-1);\n const char = this.sanitiseChar(typed);\n target.value = char;\n this.update(index, char);\n if (char) this.focusCell(index + 1);\n }\n\n protected onKeyDown(event: KeyboardEvent, index: number): void {\n // Backspace and the arrows move the caret between boxes; while a conversion\n // is open they belong to the candidate window, and moving focus out of the\n // composing box discards it.\n if (wrIsComposing(event)) return;\n\n const target = event.target as HTMLInputElement;\n switch (this.inlineKey(event.key)) {\n case 'Backspace':\n if (this.readonly()) {\n // Backspace on an empty box is an EDIT (it clears the previous one),\n // so it goes; the pure navigation keys below stay.\n event.preventDefault();\n break;\n }\n if (target.value === '') {\n event.preventDefault();\n this.update(index - 1, '');\n this.focusCell(index - 1);\n }\n break;\n case 'ArrowLeft':\n event.preventDefault();\n this.focusCell(index - 1);\n break;\n case 'ArrowRight':\n event.preventDefault();\n this.focusCell(index + 1);\n break;\n case 'Home':\n event.preventDefault();\n this.focusCell(0);\n break;\n case 'End':\n event.preventDefault();\n this.focusCell(this.length() - 1);\n break;\n }\n }\n\n protected onPaste(event: ClipboardEvent): void {\n event.preventDefault();\n if (this.readonly()) return;\n const text = event.clipboardData?.getData('text') ?? '';\n const chars = text\n .split('')\n .map(c => this.sanitiseChar(c))\n .filter(c => c.length > 0);\n if (chars.length === 0) return;\n const trimmed = chars.slice(0, this.length());\n const next = Array.from({ length: this.length() }, (_, i) => trimmed[i] ?? '');\n this.cells.set(next);\n this.emitChange();\n // `afterNextRender`, not a straight call. `focusCell` ends in `select()`, and\n // under zoneless CD the DOM still holds the PREVIOUS value at this point —\n // change detection runs in a macrotask. So the selection was made over an\n // empty box and the caret ended up after the character instead of over it:\n // measured, the landing box read `3` with the selection at `1-1`. With\n // `maxlength=\"1\"` and one character already in the box, the very next\n // keystroke was then refused, so a user who pasted a code and typed to\n // correct its last digit got nothing.\n //\n // Only the paste path needs this. Arrow keys move between boxes whose values\n // are not changing, so a synchronous select there is over settled DOM.\n afterNextRender(() => this.focusCell(Math.min(trimmed.length, this.length() - 1)), {\n injector: this.injector,\n });\n }\n\n /**\n * A click selects the box's character, the way Tab into it already does, so the\n * next keystroke replaces it. Left with the caret beside it, `maxlength=\"1\"` made\n * the browser refuse the keystroke outright — the box kept its digit and nothing\n * said why. On `click` rather than `focus`, because the browser places the caret\n * at the pointer after focusing, which would undo a select made on focus.\n */\n protected onClick(event: MouseEvent): void {\n (event.target as HTMLInputElement).select();\n }\n\n protected onBlur(): void {\n this.touch.emit();\n }\n\n protected trackIndex(index: number): number {\n return index;\n }\n\n /**\n * A box's accessible name. It projects no text and carries no label of its own,\n * so this string IS the name a screen reader reads for it.\n *\n * Keyed off `mode`, not fixed: `sanitiseChar` passes any letter through in\n * `alphanumeric` and `text`, so the old literal announced \"Digit 3\" over a box\n * holding `A` — wrong in a way translating it would not have fixed.\n */\n protected cellLabel(index: number): string {\n const params = { index: index + 1 };\n return this.mode() === 'numeric' ? this.digitLabel(params) : this.characterLabel(params);\n }\n\n // Internals\n\n private update(index: number, char: string): void {\n if (index < 0 || index >= this.length()) return;\n const next = [...this.cells()];\n next[index] = char;\n this.cells.set(next);\n this.emitChange();\n }\n\n private emitChange(): void {\n const code = this.cells().join('');\n this.value.set(code);\n if (code.length === this.length() && code.split('').every(c => c.length === 1)) {\n this.completed.emit(code);\n }\n }\n\n private focusCell(i: number, options?: FocusOptions): void {\n if (i < 0 || i >= this.length()) return;\n const el = this.cellRefs()[i]?.nativeElement;\n if (!el) return;\n el.focus(options);\n el.select();\n }\n\n /** Drop a character that doesn't match the configured mode. */\n private sanitiseChar(c: string): string {\n if (!c) return '';\n const one = c.slice(0, 1);\n switch (this.mode()) {\n case 'numeric':\n return /\\d/.test(one) ? one : '';\n case 'alphanumeric':\n return /[a-zA-Z0-9]/.test(one) ? one : '';\n case 'text':\n default:\n return one;\n }\n }\n\n /**\n * The key as the strip SEES it.\n *\n * The boxes run along the inline axis, so under `dir=\"rtl\"` the box to the\n * visual right of the caret is the PREVIOUS one. Home/End stay semantic (first\n * and last box), and Backspace is not a direction at all.\n */\n private inlineKey(key: string): string {\n if (this.dir?.value !== 'rtl') return key;\n if (key === 'ArrowRight') return 'ArrowLeft';\n if (key === 'ArrowLeft') return 'ArrowRight';\n return key;\n }\n}\n","@for (cell of cells(); track trackIndex($index)) {\n <input\n #cell\n class=\"wr-input-otp__cell\"\n [type]=\"cellType()\"\n [attr.inputmode]=\"cellInputMode()\"\n maxlength=\"1\"\n autocomplete=\"one-time-code\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n [value]=\"cell\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"cellLabel($index)\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (input)=\"onInput($event, $index)\"\n (keydown)=\"onKeyDown($event, $index)\"\n (compositionend)=\"onCompositionEnd($event, $index)\"\n (paste)=\"onPaste($event)\"\n (click)=\"onClick($event)\"\n (blur)=\"onBlur()\"\n />\n}\n"],"mappings":";;;;;;;;;;;;;AAmEA,IAAa,aAAb,MAAa,WAAU;CACJ,MAAM,OAAO,gBAAgB,EAAE,UAAU,KAAI,CAAE;CAC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GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,WAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,QAAM,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-input-otp.mjs","names":[],"sources":["../../../projects/lib/input-otp/input-otp.ts","../../../projects/lib/input-otp/input-otp.html"],"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 { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n Injector,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n type ElementRef,\n untracked,\n viewChildren,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\nimport { wrIsComposing, wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrInputOtpMode, WrInputOtpSize } from './types';\n\n/**\n * Fixed-length one-time-code input. Renders one `<input>` per character,\n * auto-advances focus on typing, handles paste of a full code, and supports\n * masking like a password field.\n *\n * A signal-forms native control: it implements `FormValueControl<string>`, so\n * `[formField]` binds straight to its `value` model — no\n * `ControlValueAccessor` in between. `[(value)]` works standalone. Emits\n * `completed` whenever the code changes while all cells are filled (useful for\n * auto-submission).\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-input-otp [formField]=\"form.code\" length=\"6\" (completed)=\"verify($event)\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-input-otp [(value)]=\"code\" length=\"6\" (completed)=\"verify($event)\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/input-otp\n */\n@Component({\n selector: 'wr-input-otp',\n templateUrl: './input-otp.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-input-otp',\n '[class]': 'classes()',\n role: 'group',\n '[attr.aria-label]': 'groupName()',\n '[attr.aria-labelledby]': 'labelledBy()',\n },\n})\nexport class WrInputOtp implements FormValueControl<string> {\n private readonly dir = inject(Directionality, { optional: true });\n private readonly injector = inject(Injector);\n\n /** Accessible name of the whole strip. Falls back to `inputOtp.label`. */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'inputOtp.label', 'Verification code');\n\n /** Number of cells to render. Clamped to `[1, 20]`. @default 6 */\n readonly length = input(6, {\n transform: (v: unknown): number => Math.max(1, Math.min(20, coerceNumberProperty(v, 6))),\n });\n\n /** Character set per cell. @default 'numeric' */\n readonly mode = input<WrInputOtpMode>('numeric');\n\n /**\n * Control size — shares the `--wr-control-*` contract. A box carries no size\n * of its own: the host modifier sets `--wr-input-otp-size` / `-font` /\n * `-radius` / `-gap` and every box reads them from the cascade, so one value\n * sizes the whole strip however many boxes `length` renders. @default 'md'\n */\n readonly size = input<WrInputOtpSize>('md');\n\n /**\n * Pill-shaped corners. Every box takes them, so a square box draws a circle.\n * @default false\n */\n readonly rounded = input(false, { transform: coerceBooleanProperty });\n\n /** Mask the typed characters like a password. @default false */\n readonly mask = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Disable interaction. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse edits while every box stays focusable and the code still submits.\n * Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * Each box is a real text input, so this is the native `readonly` attribute —\n * arrow keys, Home / End and selection keep working, which is the whole\n * difference from `disabled`. Paste is cancelled too, since a `paste` still\n * reaches a read-only input even though typing does not.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The surrounding `<wr-form-field>`'s error state — bound per BOX rather than\n * on the `role=\"group\"` host, because the box is what takes focus and a reader\n * queries the focused element.\n *\n * @internal\n */\n protected readonly fieldAria = useFormFieldAria();\n\n /**\n * The field's label names the strip, when there is one.\n *\n * The host is a `role=\"group\"`, which `<wr-form-field>`'s `<label for>` cannot\n * reach — `for` binds only to a labelable element — so a field wrapping this\n * rendered a label that named nothing and the strip announced its own generic\n * default instead. An explicit `ariaLabel` still wins over both.\n */\n protected readonly labelledBy = computed(() => (this.ariaLabel() ? null : this.fieldAria.labelledBy()));\n\n /** `null` while the field's label carries the name, or the two are announced together. */\n protected readonly groupName = computed(() => (this.labelledBy() ? null : this.resolvedAriaLabel()));\n\n /** Character shown in empty cells. @default '•' */\n readonly placeholder = input<string>('•');\n\n /** The entered code. Bound by `[formField]`, or two-way via `[(value)]`. */\n readonly value = model<string>('');\n\n /**\n * Fires on every change made while every cell holds a character — so\n * correcting a digit of an already-complete code emits again. Not latched on\n * the incomplete-to-complete transition: a host auto-submitting on it has to\n * guard its own re-entry, and gets the corrected code for free.\n */\n readonly completed = output<string>();\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n protected readonly cells = signal<readonly string[]>(Array.from({ length: 6 }, () => ''));\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-input-otp--${size}`);\n if (this.rounded()) parts.push('wr-input-otp--rounded');\n if (this.disabled()) parts.push('wr-input-otp--disabled');\n else if (this.readonly()) parts.push('wr-input-otp--readonly');\n return parts.join(' ');\n });\n\n protected readonly cellType = computed<'password' | 'text'>(() => (this.mask() ? 'password' : 'text'));\n protected readonly cellInputMode = computed(() => (this.mode() === 'numeric' ? 'numeric' : 'text'));\n\n private readonly digitLabel = useI18nFormatter('inputOtp.digit', 'Digit {{index}}');\n private readonly characterLabel = useI18nFormatter('inputOtp.character', 'Character {{index}}');\n\n protected readonly cellRefs = viewChildren<ElementRef<HTMLInputElement>>('cell');\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input-otp');\n // Resize the cell array whenever `length` changes — preserves existing\n // values, and tells the model about the ones it dropped.\n //\n // The write-back is the half that was missing. Shrinking `length` trimmed\n // the cells and left `value` holding the longer string: six boxes with\n // `123456` typed in, `length` set to 4, four boxes showing `1234` and a\n // form still submitting `123456` — a code the user could not see and had\n // no way to correct, since nothing resynced until the next keystroke. The\n // other effect cannot cover it: it tracks `value` alone and reads `length`\n // inside `untracked`, so a `length` change never re-runs it.\n effect(() => {\n const len = this.length();\n const current = untracked(() => this.cells());\n if (current.length === len) return;\n const next = Array.from({ length: len }, (_, i) => current[i] ?? '');\n this.cells.set(next);\n\n // ONLY when the resize threw characters away. Emitting on every resize\n // clobbers the first render — the array is sized before the `value`\n // effect has split an incoming code into it, so an empty `next` would\n // write `''` over the value the host just set.\n const dropped = current.slice(len).join('');\n if (dropped !== '') this.emitChange();\n });\n\n // Split an external `value` write back into cells (mirrors the old\n // writeValue). Skipped when the value is merely the echo of an in-cell\n // edit, so re-splitting can never shift or clobber what the user typed.\n effect(() => {\n // Coerce null/undefined to '' — a classic-forms binding can write null,\n // which the old `writeValue(v: string | null)` accepted too.\n const v = this.value() ?? '';\n untracked(() => {\n if (this.cells().join('') === v) return;\n const len = this.length();\n const raw = v.slice(0, len);\n const next = Array.from({ length: len }, (_, i) => this.sanitiseChar(raw[i] ?? ''));\n this.cells.set(next);\n });\n });\n }\n\n /**\n * Focus the strip — what Signal Forms calls to focus this control, from\n * `focusBoundControl()`. The host is a `role=\"group\"` with no tab stop of its\n * own, so the call goes to a box: the first EMPTY one, where the next\n * character belongs, or the first box once the code is complete, its\n * character selected so a keystroke replaces it.\n */\n focus(options?: FocusOptions): void {\n const empty = this.cells().indexOf('');\n this.focusCell(empty === -1 ? 0 : empty, options);\n }\n\n // Template handlers\n\n protected onInput(event: Event, index: number): void {\n // An input method leaves its half-built reading in the box and only replaces\n // it on `compositionend`. Sanitising that intermediate text writes `''` back\n // into the field the IME is still composing in, which aborts the conversion\n // outright — so the box is left alone until the text is real.\n if ((event as InputEvent).isComposing) return;\n this.commitCell(event.target as HTMLInputElement, index);\n }\n\n /** @see onInput — this is where an IME's text finally arrives. */\n protected onCompositionEnd(event: CompositionEvent, index: number): void {\n this.commitCell(event.target as HTMLInputElement, index);\n }\n\n private commitCell(target: HTMLInputElement, index: number): void {\n if (this.readonly()) {\n // A read-only input refuses typed characters on its own; this covers the\n // synthetic writes a script (or a spec) can still make.\n target.value = this.cells()[index] ?? '';\n return;\n }\n // The character just typed is the one before the caret, not the last one in the\n // box: typing into a filled box puts the new character beside the old, and where\n // depends on the caret — WebKit put it in FRONT, so `slice(-1)` kept the old one.\n const caret = target.selectionStart;\n const typed = caret ? target.value.slice(caret - 1, caret) : target.value.slice(-1);\n const char = this.sanitiseChar(typed);\n target.value = char;\n this.update(index, char);\n if (char) this.focusCell(index + 1);\n }\n\n protected onKeyDown(event: KeyboardEvent, index: number): void {\n // Backspace and the arrows move the caret between boxes; while a conversion\n // is open they belong to the candidate window, and moving focus out of the\n // composing box discards it.\n if (wrIsComposing(event)) return;\n\n const target = event.target as HTMLInputElement;\n switch (this.inlineKey(event.key)) {\n case 'Backspace':\n if (this.readonly()) {\n // Backspace on an empty box is an EDIT (it clears the previous one),\n // so it goes; the pure navigation keys below stay.\n event.preventDefault();\n break;\n }\n if (target.value === '') {\n event.preventDefault();\n this.update(index - 1, '');\n this.focusCell(index - 1);\n }\n break;\n case 'ArrowLeft':\n event.preventDefault();\n this.focusCell(index - 1);\n break;\n case 'ArrowRight':\n event.preventDefault();\n this.focusCell(index + 1);\n break;\n case 'Home':\n event.preventDefault();\n this.focusCell(0);\n break;\n case 'End':\n event.preventDefault();\n this.focusCell(this.length() - 1);\n break;\n }\n }\n\n protected onPaste(event: ClipboardEvent): void {\n event.preventDefault();\n if (this.readonly()) return;\n const text = event.clipboardData?.getData('text') ?? '';\n const chars = text\n .split('')\n .map(c => this.sanitiseChar(c))\n .filter(c => c.length > 0);\n if (chars.length === 0) return;\n const trimmed = chars.slice(0, this.length());\n const next = Array.from({ length: this.length() }, (_, i) => trimmed[i] ?? '');\n this.cells.set(next);\n this.emitChange();\n // `afterNextRender`, not a straight call. `focusCell` ends in `select()`, and\n // under zoneless CD the DOM still holds the PREVIOUS value at this point —\n // change detection runs in a macrotask. So the selection was made over an\n // empty box and the caret ended up after the character instead of over it:\n // measured, the landing box read `3` with the selection at `1-1`. With\n // `maxlength=\"1\"` and one character already in the box, the very next\n // keystroke was then refused, so a user who pasted a code and typed to\n // correct its last digit got nothing.\n //\n // Only the paste path needs this. Arrow keys move between boxes whose values\n // are not changing, so a synchronous select there is over settled DOM.\n afterNextRender(() => this.focusCell(Math.min(trimmed.length, this.length() - 1)), {\n injector: this.injector,\n });\n }\n\n /**\n * A click selects the box's character, the way Tab into it already does, so the\n * next keystroke replaces it. Left with the caret beside it, `maxlength=\"1\"` made\n * the browser refuse the keystroke outright — the box kept its digit and nothing\n * said why. On `click` rather than `focus`, because the browser places the caret\n * at the pointer after focusing, which would undo a select made on focus.\n */\n protected onClick(event: MouseEvent): void {\n (event.target as HTMLInputElement).select();\n }\n\n protected onBlur(): void {\n this.touch.emit();\n }\n\n protected trackIndex(index: number): number {\n return index;\n }\n\n /**\n * A box's accessible name. It projects no text and carries no label of its own,\n * so this string IS the name a screen reader reads for it.\n *\n * Keyed off `mode`, not fixed: `sanitiseChar` passes any letter through in\n * `alphanumeric` and `text`, so the old literal announced \"Digit 3\" over a box\n * holding `A` — wrong in a way translating it would not have fixed.\n */\n protected cellLabel(index: number): string {\n const params = { index: index + 1 };\n return this.mode() === 'numeric' ? this.digitLabel(params) : this.characterLabel(params);\n }\n\n // Internals\n\n private update(index: number, char: string): void {\n if (index < 0 || index >= this.length()) return;\n const next = [...this.cells()];\n next[index] = char;\n this.cells.set(next);\n this.emitChange();\n }\n\n private emitChange(): void {\n const code = this.cells().join('');\n this.value.set(code);\n if (code.length === this.length() && code.split('').every(c => c.length === 1)) {\n this.completed.emit(code);\n }\n }\n\n private focusCell(i: number, options?: FocusOptions): void {\n if (i < 0 || i >= this.length()) return;\n const el = this.cellRefs()[i]?.nativeElement;\n if (!el) return;\n el.focus(options);\n el.select();\n }\n\n /** Drop a character that doesn't match the configured mode. */\n private sanitiseChar(c: string): string {\n if (!c) return '';\n const one = c.slice(0, 1);\n switch (this.mode()) {\n case 'numeric':\n return /\\d/.test(one) ? one : '';\n case 'alphanumeric':\n return /[a-zA-Z0-9]/.test(one) ? one : '';\n case 'text':\n default:\n return one;\n }\n }\n\n /**\n * The key as the strip SEES it.\n *\n * The boxes run along the inline axis, so under `dir=\"rtl\"` the box to the\n * visual right of the caret is the PREVIOUS one. Home/End stay semantic (first\n * and last box), and Backspace is not a direction at all.\n */\n private inlineKey(key: string): string {\n if (this.dir?.value !== 'rtl') return key;\n if (key === 'ArrowRight') return 'ArrowLeft';\n if (key === 'ArrowLeft') return 'ArrowRight';\n return key;\n }\n}\n","@for (cell of cells(); track trackIndex($index)) {\n <input\n #cell\n class=\"wr-input-otp__cell\"\n [type]=\"cellType()\"\n [attr.inputmode]=\"cellInputMode()\"\n maxlength=\"1\"\n autocomplete=\"one-time-code\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n [value]=\"cell\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"cellLabel($index)\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (input)=\"onInput($event, $index)\"\n (keydown)=\"onKeyDown($event, $index)\"\n (compositionend)=\"onCompositionEnd($event, $index)\"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,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,MAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,aAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,WAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,QAAM,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -49,6 +49,29 @@ var WrInputHarness = class WrInputHarness extends ComponentHarness {
|
|
|
49
49
|
return (await this.host()).isFocused();
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* @license
|
|
54
|
+
*
|
|
55
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
56
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
57
|
+
*/
|
|
58
|
+
var WrInputGroupHarness = class extends ComponentHarness {
|
|
59
|
+
static hostSelector = "wr-input-group";
|
|
60
|
+
async getInput() {
|
|
61
|
+
return this.locatorFor(WrInputHarness)();
|
|
62
|
+
}
|
|
63
|
+
async hasClearButton() {
|
|
64
|
+
return await this.locatorForOptional(".wr-input-group__clear")() !== null;
|
|
65
|
+
}
|
|
66
|
+
async clear() {
|
|
67
|
+
const button = await this.locatorForOptional(".wr-input-group__clear")();
|
|
68
|
+
if (!button) throw new Error("WrInputGroupHarness.clear(): no clear button. It shows on a `clearable` group whose field has text and is neither disabled nor read-only.");
|
|
69
|
+
await button.click();
|
|
70
|
+
}
|
|
71
|
+
async isLoading() {
|
|
72
|
+
return await this.locatorForOptional(".wr-input-group__spinner")() !== null;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export { WrInputGroupHarness, WrInputHarness };
|
|
53
76
|
|
|
54
77
|
//# sourceMappingURL=ngwr-input-testing.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-input-testing.mjs","names":[],"sources":["../../../projects/lib/input/testing/wr-input-harness.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 { WrInputHarnessFilters } from './types';\n\n/**\n * Test harness for `[wrInput]` — the directive form, on a real `<input>` or\n * `<textarea>`.\n *\n * There is no `<wr-input>` component to wrap: ngwr styles the native control in\n * place, which is why the value, the placeholder and the disabled state are all\n * read straight off the host. {@link setValue} dispatches `input` AND `change`,\n * because a signal-forms control listens to the first and classic `[(ngModel)]`\n * setups to the second — typing into only one of them makes a harness that works\n * in some consumers' specs and not others.\n *\n * @example\n * ```ts\n * const email = await loader.getHarness(WrInputHarness.with({ placeholder: 'Email' }));\n * await email.setValue('ada@example.test');\n * expect(await email.getValue()).toBe('ada@example.test');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrInputHarness extends ComponentHarness {\n static hostSelector = 'input[wrInput], textarea[wrInput]';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrInputHarnessFilters = {}): HarnessPredicate<WrInputHarness> {\n return new HarnessPredicate(WrInputHarness, 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('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n }\n\n async getValue(): Promise<string> {\n return (await this.host()).getProperty<string>('value');\n }\n\n /**\n * Type a value in, the way a user would as far as the framework can tell.\n *\n * `input` is the one that carries the value — a signal-forms control listens to\n * it, and so does Angular's `DefaultValueAccessor`, which is what `[(ngModel)]`\n * and a reactive form bind through (its listeners are `input`, `blur` and the\n * two composition events; `change` is NOT among them). `change` is dispatched\n * after it for the consumer's own `(change)` handler: a browser defers that\n * event to the commit — blur, or Enter — which a harness write never reaches, so\n * a spec binding it would otherwise never see it fire.\n */\n async setValue(value: string): Promise<void> {\n const host = await this.host();\n await host.clear();\n await host.sendKeys(value);\n await host.dispatchEvent('change');\n }\n\n /** Clear the field, dispatching the same pair of events as {@link setValue}. */\n async clear(): Promise<void> {\n const host = await this.host();\n await host.clear();\n await host.dispatchEvent('change');\n }\n\n async getPlaceholder(): Promise<string> {\n return (await this.host()).getProperty<string>('placeholder');\n }\n\n async isDisabled(): Promise<boolean> {\n return (await this.host()).getProperty<boolean>('disabled');\n }\n\n async isReadonly(): Promise<boolean> {\n return (await this.host()).getProperty<boolean>('readOnly');\n }\n\n /** `input` or `textarea` — the directive styles both. */\n async getTagName(): Promise<string> {\n return (await (await this.host()).getProperty<string>('tagName')).toLowerCase();\n }\n\n /**\n * Whether the field is marked invalid.\n *\n * `<wr-form-field>` sets `aria-invalid` when it has an error to describe, so\n * this answers what a screen reader is told rather than what the model thinks.\n */\n async isInvalid(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-invalid')) === 'true';\n }\n\n async focus(): Promise<void> {\n return (await this.host()).focus();\n }\n\n async blur(): Promise<void> {\n return (await this.host()).blur();\n }\n\n async isFocused(): Promise<boolean> {\n return (await this.host()).isFocused();\n }\n}\n"],"mappings":";;;;;;;AA+BA,IAAa,iBAAb,MAAa,uBAAuB,iBAAgB;CAClD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAiC,CAAA,GAAE;EAC7C,OAAO,IAAI,iBAAiB,gBAAgB,OAAO,CAAC,CACjD,UAAU,SAAS,QAAQ,QAAQ,SAAS,UAAU,iBAAiB,cAAc,QAAQ,SAAQ,GAAI,KAAK,CAAC,CAAC,CAChH,UAAU,eAAe,QAAQ,cAAc,SAAS,gBACvD,iBAAiB,cAAc,QAAQ,eAAc,GAAI,WAAW,CAAC,CACtE,CACA,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,QAAQ;CACnH;CAEA,MAAM,WAAQ;EACZ,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,YAAoB,OAAO;CACxD;CAaA,MAAM,SAAS,OAAa;EAC1B,MAAM,OAAO,MAAM,KAAK,KAAI;EAC5B,MAAM,KAAK,MAAK;EAChB,MAAM,KAAK,SAAS,KAAK;EACzB,MAAM,KAAK,cAAc,QAAQ;CACnC;CAGA,MAAM,QAAK;EACT,MAAM,OAAO,MAAM,KAAK,KAAI;EAC5B,MAAM,KAAK,MAAK;EAChB,MAAM,KAAK,cAAc,QAAQ;CACnC;CAEA,MAAM,iBAAc;EAClB,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,YAAoB,aAAa;CAC9D;CAEA,MAAM,aAAU;EACd,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,YAAqB,UAAU;CAC5D;CAEA,MAAM,aAAU;EACd,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,YAAqB,UAAU;CAC5D;CAGA,MAAM,aAAU;EACd,QAAQ,OAAO,MAAM,KAAK,KAAI,EAAA,CAAI,YAAoB,SAAS,EAAA,CAAG,YAAW;CAC/E;CAQA,MAAM,YAAS;EACb,OAAQ,OAAO,MAAM,KAAK,KAAI,EAAA,CAAI,aAAa,cAAc,MAAO;CACtE;CAEA,MAAM,QAAK;EACT,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,MAAK;CAClC;CAEA,MAAM,OAAI;EACR,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,KAAI;CACjC;CAEA,MAAM,YAAS;EACb,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,UAAS;CACtC"}
|
|
1
|
+
{"version":3,"file":"ngwr-input-testing.mjs","names":[],"sources":["../../../projects/lib/input/testing/wr-input-harness.ts","../../../projects/lib/input/testing/wr-input-group-harness.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 { WrInputHarnessFilters } from './types';\n\n/**\n * Test harness for `[wrInput]` — the directive form, on a real `<input>` or\n * `<textarea>`.\n *\n * There is no `<wr-input>` component to wrap: ngwr styles the native control in\n * place, which is why the value, the placeholder and the disabled state are all\n * read straight off the host. {@link setValue} dispatches `input` AND `change`,\n * because a signal-forms control listens to the first and classic `[(ngModel)]`\n * setups to the second — typing into only one of them makes a harness that works\n * in some consumers' specs and not others.\n *\n * @example\n * ```ts\n * const email = await loader.getHarness(WrInputHarness.with({ placeholder: 'Email' }));\n * await email.setValue('ada@example.test');\n * expect(await email.getValue()).toBe('ada@example.test');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrInputHarness extends ComponentHarness {\n static hostSelector = 'input[wrInput], textarea[wrInput]';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrInputHarnessFilters = {}): HarnessPredicate<WrInputHarness> {\n return new HarnessPredicate(WrInputHarness, 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('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n }\n\n async getValue(): Promise<string> {\n return (await this.host()).getProperty<string>('value');\n }\n\n /**\n * Type a value in, the way a user would as far as the framework can tell.\n *\n * `input` is the one that carries the value — a signal-forms control listens to\n * it, and so does Angular's `DefaultValueAccessor`, which is what `[(ngModel)]`\n * and a reactive form bind through (its listeners are `input`, `blur` and the\n * two composition events; `change` is NOT among them). `change` is dispatched\n * after it for the consumer's own `(change)` handler: a browser defers that\n * event to the commit — blur, or Enter — which a harness write never reaches, so\n * a spec binding it would otherwise never see it fire.\n */\n async setValue(value: string): Promise<void> {\n const host = await this.host();\n await host.clear();\n await host.sendKeys(value);\n await host.dispatchEvent('change');\n }\n\n /** Clear the field, dispatching the same pair of events as {@link setValue}. */\n async clear(): Promise<void> {\n const host = await this.host();\n await host.clear();\n await host.dispatchEvent('change');\n }\n\n async getPlaceholder(): Promise<string> {\n return (await this.host()).getProperty<string>('placeholder');\n }\n\n async isDisabled(): Promise<boolean> {\n return (await this.host()).getProperty<boolean>('disabled');\n }\n\n async isReadonly(): Promise<boolean> {\n return (await this.host()).getProperty<boolean>('readOnly');\n }\n\n /** `input` or `textarea` — the directive styles both. */\n async getTagName(): Promise<string> {\n return (await (await this.host()).getProperty<string>('tagName')).toLowerCase();\n }\n\n /**\n * Whether the field is marked invalid.\n *\n * `<wr-form-field>` sets `aria-invalid` when it has an error to describe, so\n * this answers what a screen reader is told rather than what the model thinks.\n */\n async isInvalid(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-invalid')) === 'true';\n }\n\n async focus(): Promise<void> {\n return (await this.host()).focus();\n }\n\n async blur(): Promise<void> {\n return (await this.host()).blur();\n }\n\n async isFocused(): Promise<boolean> {\n return (await this.host()).isFocused();\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 { ComponentHarness } from '@angular/cdk/testing';\n\nimport { WrInputHarness } from './wr-input-harness';\n\n/**\n * Harness for `<wr-input-group>`: the clear (×) button and the spinner it draws\n * around the field it wraps. The field itself is a {@link WrInputHarness}, from\n * {@link getInput}.\n *\n * There is no `getPrefix()` / `getSuffix()`: an affix is the app's own markup,\n * so a spec reads it straight off its own template.\n *\n * @example\n * ```ts\n * const search = await loader.getHarness(WrInputGroupHarness);\n *\n * await (await search.getInput()).setValue('ada');\n * expect(await search.isLoading()).toBe(true);\n * await search.clear();\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrInputGroupHarness extends ComponentHarness {\n static hostSelector = 'wr-input-group';\n\n /** The first field the group wraps, the one `clearable` and `loading` act on. */\n async getInput(): Promise<WrInputHarness> {\n return this.locatorFor(WrInputHarness)();\n }\n\n /** Whether the clear (×) button is on show: `clearable`, with text, neither disabled nor read-only. */\n async hasClearButton(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-input-group__clear')()) !== null;\n }\n\n /** Click the clear (×) button. Throws when it is not on show. */\n async clear(): Promise<void> {\n const button = await this.locatorForOptional('.wr-input-group__clear')();\n if (!button) {\n throw new Error(\n 'WrInputGroupHarness.clear(): no clear button. It shows on a `clearable` group ' +\n 'whose field has text and is neither disabled nor read-only.'\n );\n }\n await button.click();\n }\n\n /** Whether the group is drawing its `loading` spinner. */\n async isLoading(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-input-group__spinner')()) !== null;\n }\n}\n"],"mappings":";;;;;;;AA+BA,IAAa,iBAAb,MAAa,uBAAuB,iBAAgB;CAClD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAiC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Q,MAAM,KAAK,KAAI,EAAA,CAAI,KAAI;CACjC;CAEA,MAAM,YAAS;EACb,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,UAAS;CACtC;;;;;;;;AChFF,IAAa,sBAAb,cAAyC,iBAAgB;CACvD,OAAO,eAAe;CAGtB,MAAM,WAAQ;EACZ,OAAO,KAAK,WAAW,cAAc,CAAC,CAAA;CACxC;CAGA,MAAM,iBAAc;EAClB,OAAQ,MAAM,KAAK,mBAAmB,wBAAwB,CAAC,CAAA,MAAQ;CACzE;CAGA,MAAM,QAAK;EACT,MAAM,SAAS,MAAM,KAAK,mBAAmB,wBAAwB,CAAC,CAAA;EACtE,IAAI,CAAC,QACH,MAAM,IAAI,MACR,2IAC+D;EAGnE,MAAM,OAAO,MAAK;CACpB;CAGA,MAAM,YAAS;EACb,OAAQ,MAAM,KAAK,mBAAmB,0BAA0B,CAAC,CAAA,MAAQ;CAC3E"}
|
package/fesm2022/ngwr-input.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { Component, Directive, ElementRef, ViewEncapsulation, computed, inject, input, signal } from "@angular/core";
|
|
2
|
+
import { Component, Directive, ElementRef, Renderer2, ViewEncapsulation, afterEveryRender, computed, contentChild, effect, inject, input, output, signal } from "@angular/core";
|
|
3
3
|
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
|
4
4
|
import { wrCheckStyles } from "ngwr/utils";
|
|
5
5
|
import { useI18nText } from "ngwr/i18n";
|
|
6
|
+
import { WrSpinner } from "ngwr/spinner";
|
|
6
7
|
import { WR_FORM_FIELD, useFormFieldAria } from "ngwr/form";
|
|
7
8
|
/**
|
|
8
9
|
* @license
|
|
@@ -36,7 +37,7 @@ var WrInput = class WrInput {
|
|
|
36
37
|
}, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
37
38
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
38
39
|
minVersion: "12.0.0",
|
|
39
|
-
version: "22.2.
|
|
40
|
+
version: "22.2.6",
|
|
40
41
|
ngImport: i0,
|
|
41
42
|
type: WrInput,
|
|
42
43
|
deps: [],
|
|
@@ -44,7 +45,7 @@ var WrInput = class WrInput {
|
|
|
44
45
|
});
|
|
45
46
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
46
47
|
minVersion: "17.1.0",
|
|
47
|
-
version: "22.2.
|
|
48
|
+
version: "22.2.6",
|
|
48
49
|
type: WrInput,
|
|
49
50
|
isStandalone: true,
|
|
50
51
|
selector: "input[wrInput], textarea[wrInput]",
|
|
@@ -78,7 +79,7 @@ var WrInput = class WrInput {
|
|
|
78
79
|
};
|
|
79
80
|
i0.ɵɵngDeclareClassMetadata({
|
|
80
81
|
minVersion: "12.0.0",
|
|
81
|
-
version: "22.2.
|
|
82
|
+
version: "22.2.6",
|
|
82
83
|
ngImport: i0,
|
|
83
84
|
type: WrInput,
|
|
84
85
|
decorators: [{
|
|
@@ -126,7 +127,7 @@ var WrInputPrefix = class WrInputPrefix {
|
|
|
126
127
|
}
|
|
127
128
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
128
129
|
minVersion: "12.0.0",
|
|
129
|
-
version: "22.2.
|
|
130
|
+
version: "22.2.6",
|
|
130
131
|
ngImport: i0,
|
|
131
132
|
type: WrInputPrefix,
|
|
132
133
|
deps: [],
|
|
@@ -134,7 +135,7 @@ var WrInputPrefix = class WrInputPrefix {
|
|
|
134
135
|
});
|
|
135
136
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
136
137
|
minVersion: "14.0.0",
|
|
137
|
-
version: "22.2.
|
|
138
|
+
version: "22.2.6",
|
|
138
139
|
type: WrInputPrefix,
|
|
139
140
|
isStandalone: true,
|
|
140
141
|
selector: "[wrInputPrefix]",
|
|
@@ -144,7 +145,7 @@ var WrInputPrefix = class WrInputPrefix {
|
|
|
144
145
|
};
|
|
145
146
|
i0.ɵɵngDeclareClassMetadata({
|
|
146
147
|
minVersion: "12.0.0",
|
|
147
|
-
version: "22.2.
|
|
148
|
+
version: "22.2.6",
|
|
148
149
|
ngImport: i0,
|
|
149
150
|
type: WrInputPrefix,
|
|
150
151
|
decorators: [{
|
|
@@ -168,7 +169,7 @@ var WrInputSuffix = class WrInputSuffix {
|
|
|
168
169
|
}
|
|
169
170
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
170
171
|
minVersion: "12.0.0",
|
|
171
|
-
version: "22.2.
|
|
172
|
+
version: "22.2.6",
|
|
172
173
|
ngImport: i0,
|
|
173
174
|
type: WrInputSuffix,
|
|
174
175
|
deps: [],
|
|
@@ -176,7 +177,7 @@ var WrInputSuffix = class WrInputSuffix {
|
|
|
176
177
|
});
|
|
177
178
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
178
179
|
minVersion: "14.0.0",
|
|
179
|
-
version: "22.2.
|
|
180
|
+
version: "22.2.6",
|
|
180
181
|
type: WrInputSuffix,
|
|
181
182
|
isStandalone: true,
|
|
182
183
|
selector: "[wrInputSuffix]",
|
|
@@ -186,7 +187,7 @@ var WrInputSuffix = class WrInputSuffix {
|
|
|
186
187
|
};
|
|
187
188
|
i0.ɵɵngDeclareClassMetadata({
|
|
188
189
|
minVersion: "12.0.0",
|
|
189
|
-
version: "22.2.
|
|
190
|
+
version: "22.2.6",
|
|
190
191
|
ngImport: i0,
|
|
191
192
|
type: WrInputSuffix,
|
|
192
193
|
decorators: [{
|
|
@@ -205,13 +206,51 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
205
206
|
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
206
207
|
*/
|
|
207
208
|
var WrInputGroup = class WrInputGroup {
|
|
209
|
+
renderer = inject(Renderer2);
|
|
208
210
|
constructor() {
|
|
209
211
|
if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("input");
|
|
212
|
+
afterEveryRender({ read: () => this.syncClear() });
|
|
213
|
+
effect(() => {
|
|
214
|
+
const field = this.field()?.nativeElement;
|
|
215
|
+
if (!field) return;
|
|
216
|
+
if (this.loading()) this.renderer.setAttribute(field, "aria-busy", "true");
|
|
217
|
+
else this.renderer.removeAttribute(field, "aria-busy");
|
|
218
|
+
});
|
|
210
219
|
}
|
|
211
220
|
rounded = input(false, {
|
|
212
221
|
...ngDevMode ? { debugName: "rounded" } : /* istanbul ignore next */ {},
|
|
213
222
|
transform: coerceBooleanProperty
|
|
214
223
|
});
|
|
224
|
+
clearable = input(false, {
|
|
225
|
+
...ngDevMode ? { debugName: "clearable" } : /* istanbul ignore next */ {},
|
|
226
|
+
transform: coerceBooleanProperty
|
|
227
|
+
});
|
|
228
|
+
clearLabel = input(null, ...ngDevMode ? [{ debugName: "clearLabel" }] : /* istanbul ignore next */ []);
|
|
229
|
+
loading = input(false, {
|
|
230
|
+
...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
|
|
231
|
+
transform: coerceBooleanProperty
|
|
232
|
+
});
|
|
233
|
+
cleared = output();
|
|
234
|
+
resolvedClear = useI18nText(this.clearLabel, "common.clear", "Clear");
|
|
235
|
+
field = contentChild(WrInput, {
|
|
236
|
+
...ngDevMode ? { debugName: "field" } : /* istanbul ignore next */ {},
|
|
237
|
+
read: ElementRef
|
|
238
|
+
});
|
|
239
|
+
fieldClearable = signal(false, ...ngDevMode ? [{ debugName: "fieldClearable" }] : /* istanbul ignore next */ []);
|
|
240
|
+
clearShown = computed(() => this.clearable() && this.fieldClearable(), ...ngDevMode ? [{ debugName: "clearShown" }] : /* istanbul ignore next */ []);
|
|
241
|
+
syncClear() {
|
|
242
|
+
if (!this.clearable()) return;
|
|
243
|
+
const field = this.field()?.nativeElement;
|
|
244
|
+
this.fieldClearable.set(!!field && field.value !== "" && !field.disabled && !field.readOnly);
|
|
245
|
+
}
|
|
246
|
+
clear() {
|
|
247
|
+
const field = this.field()?.nativeElement;
|
|
248
|
+
if (!field || field.disabled || field.readOnly) return;
|
|
249
|
+
field.value = "";
|
|
250
|
+
field.dispatchEvent(new Event("input", { bubbles: true }));
|
|
251
|
+
field.focus();
|
|
252
|
+
this.cleared.emit();
|
|
253
|
+
}
|
|
215
254
|
classes = computed(() => {
|
|
216
255
|
const parts = [];
|
|
217
256
|
if (this.rounded()) parts.push("wr-input-group--rounded");
|
|
@@ -219,61 +258,138 @@ var WrInputGroup = class WrInputGroup {
|
|
|
219
258
|
}, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
220
259
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
221
260
|
minVersion: "12.0.0",
|
|
222
|
-
version: "22.2.
|
|
261
|
+
version: "22.2.6",
|
|
223
262
|
ngImport: i0,
|
|
224
263
|
type: WrInputGroup,
|
|
225
264
|
deps: [],
|
|
226
265
|
target: i0.ɵɵFactoryTarget.Component
|
|
227
266
|
});
|
|
228
267
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
229
|
-
minVersion: "17.
|
|
230
|
-
version: "22.2.
|
|
268
|
+
minVersion: "17.0.0",
|
|
269
|
+
version: "22.2.6",
|
|
231
270
|
type: WrInputGroup,
|
|
232
271
|
isStandalone: true,
|
|
233
272
|
selector: "wr-input-group",
|
|
234
|
-
inputs: {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
273
|
+
inputs: {
|
|
274
|
+
rounded: {
|
|
275
|
+
classPropertyName: "rounded",
|
|
276
|
+
publicName: "rounded",
|
|
277
|
+
isSignal: true,
|
|
278
|
+
isRequired: false,
|
|
279
|
+
transformFunction: null
|
|
280
|
+
},
|
|
281
|
+
clearable: {
|
|
282
|
+
classPropertyName: "clearable",
|
|
283
|
+
publicName: "clearable",
|
|
284
|
+
isSignal: true,
|
|
285
|
+
isRequired: false,
|
|
286
|
+
transformFunction: null
|
|
287
|
+
},
|
|
288
|
+
clearLabel: {
|
|
289
|
+
classPropertyName: "clearLabel",
|
|
290
|
+
publicName: "clearLabel",
|
|
291
|
+
isSignal: true,
|
|
292
|
+
isRequired: false,
|
|
293
|
+
transformFunction: null
|
|
294
|
+
},
|
|
295
|
+
loading: {
|
|
296
|
+
classPropertyName: "loading",
|
|
297
|
+
publicName: "loading",
|
|
298
|
+
isSignal: true,
|
|
299
|
+
isRequired: false,
|
|
300
|
+
transformFunction: null
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
outputs: { cleared: "cleared" },
|
|
241
304
|
host: {
|
|
305
|
+
listeners: { "input": "syncClear()" },
|
|
242
306
|
properties: { "class": "classes()" },
|
|
243
307
|
classAttribute: "wr-input-group"
|
|
244
308
|
},
|
|
309
|
+
queries: [{
|
|
310
|
+
propertyName: "field",
|
|
311
|
+
first: true,
|
|
312
|
+
predicate: WrInput,
|
|
313
|
+
descendants: true,
|
|
314
|
+
read: ElementRef,
|
|
315
|
+
isSignal: true
|
|
316
|
+
}],
|
|
245
317
|
ngImport: i0,
|
|
246
|
-
template: "<ng-content
|
|
247
|
-
|
|
318
|
+
template: "<ng-content />\n<!-- Pointer-only, as the select's is: emptying the field is the keyboard way to clear. -->\n@if (clearShown()) {\n <span class=\"wr-input-group__clear\" role=\"button\" [attr.aria-label]=\"resolvedClear()\" tabindex=\"-1\" (click)=\"clear()\">\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </span>\n} @else if (clearable()) {\n <!-- Holds the ×'s room while the field is empty, so clearing does not narrow the group. -->\n <span class=\"wr-input-group__clear-space\" aria-hidden=\"true\"></span>\n}\n<!-- Hidden from the accessibility tree: the field says it is busy with `aria-busy`. -->\n@if (loading()) {\n <wr-spinner class=\"wr-input-group__spinner\" size=\"sm\" aria-hidden=\"true\" />\n}\n<ng-content select=\"[wrInputSuffix], wr-password-toggle\" />\n",
|
|
319
|
+
dependencies: [{
|
|
320
|
+
kind: "component",
|
|
321
|
+
type: WrSpinner,
|
|
322
|
+
selector: "wr-spinner",
|
|
323
|
+
inputs: ["size", "ariaLabel"]
|
|
324
|
+
}],
|
|
248
325
|
encapsulation: i0.ViewEncapsulation.None
|
|
249
326
|
});
|
|
250
327
|
};
|
|
251
328
|
i0.ɵɵngDeclareClassMetadata({
|
|
252
329
|
minVersion: "12.0.0",
|
|
253
|
-
version: "22.2.
|
|
330
|
+
version: "22.2.6",
|
|
254
331
|
ngImport: i0,
|
|
255
332
|
type: WrInputGroup,
|
|
256
333
|
decorators: [{
|
|
257
334
|
type: Component,
|
|
258
335
|
args: [{
|
|
259
336
|
selector: "wr-input-group",
|
|
260
|
-
template: "<ng-content />",
|
|
261
337
|
encapsulation: ViewEncapsulation.None,
|
|
262
338
|
host: {
|
|
263
339
|
class: "wr-input-group",
|
|
264
|
-
"[class]": "classes()"
|
|
265
|
-
|
|
340
|
+
"[class]": "classes()",
|
|
341
|
+
"(input)": "syncClear()"
|
|
342
|
+
},
|
|
343
|
+
imports: [WrSpinner],
|
|
344
|
+
template: "<ng-content />\n<!-- Pointer-only, as the select's is: emptying the field is the keyboard way to clear. -->\n@if (clearShown()) {\n <span class=\"wr-input-group__clear\" role=\"button\" [attr.aria-label]=\"resolvedClear()\" tabindex=\"-1\" (click)=\"clear()\">\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </span>\n} @else if (clearable()) {\n <!-- Holds the ×'s room while the field is empty, so clearing does not narrow the group. -->\n <span class=\"wr-input-group__clear-space\" aria-hidden=\"true\"></span>\n}\n<!-- Hidden from the accessibility tree: the field says it is busy with `aria-busy`. -->\n@if (loading()) {\n <wr-spinner class=\"wr-input-group__spinner\" size=\"sm\" aria-hidden=\"true\" />\n}\n<ng-content select=\"[wrInputSuffix], wr-password-toggle\" />\n"
|
|
266
345
|
}]
|
|
267
346
|
}],
|
|
268
347
|
ctorParameters: () => [],
|
|
269
|
-
propDecorators: {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
348
|
+
propDecorators: {
|
|
349
|
+
rounded: [{
|
|
350
|
+
type: i0.Input,
|
|
351
|
+
args: [{
|
|
352
|
+
isSignal: true,
|
|
353
|
+
alias: "rounded",
|
|
354
|
+
required: false
|
|
355
|
+
}]
|
|
356
|
+
}],
|
|
357
|
+
clearable: [{
|
|
358
|
+
type: i0.Input,
|
|
359
|
+
args: [{
|
|
360
|
+
isSignal: true,
|
|
361
|
+
alias: "clearable",
|
|
362
|
+
required: false
|
|
363
|
+
}]
|
|
364
|
+
}],
|
|
365
|
+
clearLabel: [{
|
|
366
|
+
type: i0.Input,
|
|
367
|
+
args: [{
|
|
368
|
+
isSignal: true,
|
|
369
|
+
alias: "clearLabel",
|
|
370
|
+
required: false
|
|
371
|
+
}]
|
|
372
|
+
}],
|
|
373
|
+
loading: [{
|
|
374
|
+
type: i0.Input,
|
|
375
|
+
args: [{
|
|
376
|
+
isSignal: true,
|
|
377
|
+
alias: "loading",
|
|
378
|
+
required: false
|
|
379
|
+
}]
|
|
380
|
+
}],
|
|
381
|
+
cleared: [{
|
|
382
|
+
type: i0.Output,
|
|
383
|
+
args: ["cleared"]
|
|
384
|
+
}],
|
|
385
|
+
field: [{
|
|
386
|
+
type: i0.ContentChild,
|
|
387
|
+
args: [i0.forwardRef(() => WrInput), {
|
|
388
|
+
read: ElementRef,
|
|
389
|
+
isSignal: true
|
|
390
|
+
}]
|
|
275
391
|
}]
|
|
276
|
-
}
|
|
392
|
+
}
|
|
277
393
|
});
|
|
278
394
|
/**
|
|
279
395
|
* @license
|
|
@@ -300,7 +416,7 @@ var WrPasswordToggle = class WrPasswordToggle {
|
|
|
300
416
|
}
|
|
301
417
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
302
418
|
minVersion: "12.0.0",
|
|
303
|
-
version: "22.2.
|
|
419
|
+
version: "22.2.6",
|
|
304
420
|
ngImport: i0,
|
|
305
421
|
type: WrPasswordToggle,
|
|
306
422
|
deps: [],
|
|
@@ -308,7 +424,7 @@ var WrPasswordToggle = class WrPasswordToggle {
|
|
|
308
424
|
});
|
|
309
425
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
310
426
|
minVersion: "17.0.0",
|
|
311
|
-
version: "22.2.
|
|
427
|
+
version: "22.2.6",
|
|
312
428
|
type: WrPasswordToggle,
|
|
313
429
|
isStandalone: true,
|
|
314
430
|
selector: "wr-password-toggle",
|
|
@@ -342,7 +458,7 @@ var WrPasswordToggle = class WrPasswordToggle {
|
|
|
342
458
|
};
|
|
343
459
|
i0.ɵɵngDeclareClassMetadata({
|
|
344
460
|
minVersion: "12.0.0",
|
|
345
|
-
version: "22.2.
|
|
461
|
+
version: "22.2.6",
|
|
346
462
|
ngImport: i0,
|
|
347
463
|
type: WrPasswordToggle,
|
|
348
464
|
decorators: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-input.mjs","names":[],"sources":["../../../projects/lib/input/directives/wr-input.ts","../../../projects/lib/input/directives/wr-input-prefix.ts","../../../projects/lib/input/directives/wr-input-suffix.ts","../../../projects/lib/input/input-group.ts","../../../projects/lib/input/password-toggle.ts","../../../projects/lib/input/password-toggle.html"],"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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Directive, ElementRef, computed, inject, input } from '@angular/core';\n\nimport { WR_FORM_FIELD, useFormFieldAria } from 'ngwr/form';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrInputSize } from '../types';\n\n/**\n * Applies NGWR input styling to a native `<input>` element.\n *\n * Because this is an attribute directive on the real `<input>` (not a wrapper\n * component), any other directive that targets `input` — `[(ngModel)]`,\n * `[formControl]`, validators, third-party libraries like `ngx-mask` — composes\n * naturally on the same element.\n *\n * @example\n * ```html\n * <input wrInput [(ngModel)]=\"name\" placeholder=\"Your name\" />\n *\n * <!-- Works with ngx-mask, validators, etc. -->\n * <input wrInput [(ngModel)]=\"phone\" mask=\"(000) 000-0000\" />\n * ```\n *\n * For prefix / suffix / password-toggle layouts, wrap the input in\n * `<wr-input-group>`.\n *\n * @see https://ngwr.dev/reference/components/input\n */\n@Directive({\n selector: 'input[wrInput], textarea[wrInput]',\n host: {\n class: 'wr-input',\n '[class]': 'classes()',\n '[attr.id]': 'resolvedId()',\n '[attr.aria-invalid]': 'ariaInvalid()',\n '[attr.aria-describedby]': 'describedBy()',\n },\n})\nexport class WrInput {\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly field = inject(WR_FORM_FIELD, { optional: true });\n\n /**\n * Read once, at construction: a static `id=\"\"` in the template is already on\n * the element by the time a directive is instantiated, and it must win over\n * the field's generated one.\n */\n private readonly ownId = this.host.nativeElement.getAttribute('id');\n\n /**\n * Adopts the surrounding `<wr-form-field>`'s `controlId`, so the label it\n * already rendered actually points at this element. Without this the `for`\n * referenced an id that existed nowhere and the input had no label at all.\n */\n protected readonly resolvedId = computed(() => this.ownId ?? this.field?.controlId() ?? null);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n // Tell the field which id actually stuck. Without this its `<label for>` keeps\n // pointing at the generated id while this element answers to the author's own —\n // a label referencing nothing, which is the same as having none.\n if (this.ownId) this.field?.adoptControlId(this.ownId);\n }\n\n /**\n * Announced state, taken from the surrounding `<wr-form-field>`.\n *\n * The field renders the message but cannot reach the projected control, so\n * the control reads back: without this the error is visible on screen and\n * invisible to a screen reader, which never learns the field is invalid or\n * what the message says.\n */\n // Through the shared helper, not a local pair: the hint is described by\n // `hintId`, which only `useFormFieldAria()` composes, and `aria-invalid` keys\n // on the error COUNT rather than on \"something is described\". Hand-rolled here,\n // these three announced the error and never the hint — and `<input wrInput>` is\n // the control the report was filed against.\n private readonly fieldAria = useFormFieldAria();\n protected readonly describedBy = this.fieldAria.describedBy;\n protected readonly ariaInvalid = this.fieldAria.ariaInvalid;\n\n /**\n * Control size. @default 'md'\n *\n * Called `wrSize` until v14, to dodge the native `<input size>` attribute —\n * which measures the field in characters and which `.wr-input`'s `width: 100%`\n * has always overridden, so the clash it guarded against was never observable.\n * It made this the one size input in the catalog spelled differently from the\n * other twenty-three. The cost of the change is that a consumer who wanted the\n * NATIVE `size` on an ngwr input can no longer have it — but `width: 100%`\n * meant they never did.\n */\n readonly size = input<WrInputSize>('md');\n\n /** Pill-shaped corners. @default false */\n readonly rounded = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-input--${size}`);\n if (this.rounded()) parts.push('wr-input--rounded');\n return parts.join(' ');\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 { Directive } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Marks an element as the **left** decoration inside `<wr-input-group>`.\n * Adds the `.wr-input-group__affix` class so the group's layout flexes it\n * to the input's left edge.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <span wrInputPrefix>$</span>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * </wr-input-group>\n * ```\n */\n@Directive({\n selector: '[wrInputPrefix]',\n host: { class: 'wr-input-group__affix wr-input-group__affix--prefix' },\n})\nexport class WrInputPrefix {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\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 { Directive } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Marks an element as the **right** decoration inside `<wr-input-group>`.\n * Adds the `.wr-input-group__affix` class so the group's layout flexes it\n * to the input's right edge.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * <span wrInputSuffix>USD</span>\n * </wr-input-group>\n * ```\n */\n@Directive({\n selector: '[wrInputSuffix]',\n host: { class: 'wr-input-group__affix wr-input-group__affix--suffix' },\n})\nexport class WrInputSuffix {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Container for `<input wrInput>` + `[wrInputPrefix]` / `[wrInputSuffix]` /\n * `<wr-password-toggle>` siblings. Renders the border and focus ring; the\n * inner native input drops its own border so it visually melts into the\n * group.\n *\n * Pure layout — no signals shared with the inner directive, focus styling is\n * driven entirely by `:focus-within` so any focusable child counts.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <span wrInputPrefix>$</span>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * <span wrInputSuffix>USD</span>\n * </wr-input-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/input\n */\n@Component({\n selector: 'wr-input-group',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-input-group', '[class]': 'classes()' },\n})\nexport class WrInputGroup {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n }\n\n /** Pill-shaped corners. @default false */\n readonly rounded = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.rounded()) parts.push('wr-input-group--rounded');\n return parts.join(' ');\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, computed, input, signal } from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Self-contained eye-toggle button. Flips the linked `<input>`'s `type`\n * attribute between `password` and `text`. Drop it inside an\n * `<wr-input-group>` next to a password input.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <input wrInput type=\"password\" [(ngModel)]=\"pw\" #pwInput />\n * <wr-password-toggle [for]=\"pwInput\" />\n * </wr-input-group>\n * ```\n */\n@Component({\n selector: 'wr-password-toggle',\n templateUrl: './password-toggle.html',\n encapsulation: ViewEncapsulation.None,\n})\nexport class WrPasswordToggle {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n }\n\n /** Reference to the linked password input. */\n readonly for = input.required<HTMLInputElement>();\n\n protected readonly revealed = signal(false);\n\n /** Accessible name while the password is hidden. Falls back to `input.showPassword`. */\n readonly showPasswordLabel = input<string | null>(null);\n\n /** Accessible name while the password is revealed. Falls back to `input.hidePassword`. */\n readonly hidePasswordLabel = input<string | null>(null);\n\n private readonly resolvedShowPasswordLabel = useI18nText(\n this.showPasswordLabel,\n 'input.showPassword',\n 'Show password'\n );\n private readonly resolvedHidePasswordLabel = useI18nText(\n this.hidePasswordLabel,\n 'input.hidePassword',\n 'Hide password'\n );\n\n protected readonly ariaLabel = computed(() =>\n this.revealed() ? this.resolvedHidePasswordLabel() : this.resolvedShowPasswordLabel()\n );\n\n protected toggle(): void {\n const input = this.for();\n const next = input.type === 'password' ? 'text' : 'password';\n input.type = next;\n this.revealed.set(next === 'text');\n }\n}\n","<button\n type=\"button\"\n class=\"wr-input-group__toggle\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-pressed]=\"revealed()\"\n (click)=\"toggle()\"\n>\n @if (revealed()) {\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49\" />\n <path d=\"M14.084 14.158a3 3 0 0 1-4.242-4.242\" />\n <path d=\"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143\" />\n <path d=\"m2 2 20 20\" />\n </svg>\n } @else {\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n }\n</button>\n"],"mappings":";;;;;;;;;;;;AA8CA,IAAa,UAAb,MAAa,QAAO;CACD,OAAO,OAAgC,UAAU;CACjD,QAAQ,OAAO,eAAe,EAAE,UAAU,KAAI,CAAE;CAOhD,QAAQ,KAAK,KAAK,cAAc,aAAa,IAAI;CAO/C,aAAa,eAAe,KAAK,SAAS,KAAK,OAAO,UAAS,KAAM,MAAK,GAAA,YAAA,CAAA,EAA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A;GAAA,mBAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,UAAA;EAAA,UC9B7B;EAyCA,eAAA,GAAA,kBAAA;CAAA,CAAA;;ADXa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgB,YAAA,CAAA;EAL5B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAoB,eAEf,kBAAkB;GAAI,UAAA;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-input.mjs","names":[],"sources":["../../../projects/lib/input/directives/wr-input.ts","../../../projects/lib/input/directives/wr-input-prefix.ts","../../../projects/lib/input/directives/wr-input-suffix.ts","../../../projects/lib/input/input-group.ts","../../../projects/lib/input/input-group.html","../../../projects/lib/input/password-toggle.ts","../../../projects/lib/input/password-toggle.html"],"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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Directive, ElementRef, computed, inject, input } from '@angular/core';\n\nimport { WR_FORM_FIELD, useFormFieldAria } from 'ngwr/form';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrInputSize } from '../types';\n\n/**\n * Applies NGWR input styling to a native `<input>` element.\n *\n * Because this is an attribute directive on the real `<input>` (not a wrapper\n * component), any other directive that targets `input` — `[(ngModel)]`,\n * `[formControl]`, validators, third-party libraries like `ngx-mask` — composes\n * naturally on the same element.\n *\n * @example\n * ```html\n * <input wrInput [(ngModel)]=\"name\" placeholder=\"Your name\" />\n *\n * <!-- Works with ngx-mask, validators, etc. -->\n * <input wrInput [(ngModel)]=\"phone\" mask=\"(000) 000-0000\" />\n * ```\n *\n * For prefix / suffix / password-toggle layouts, wrap the input in\n * `<wr-input-group>`.\n *\n * @see https://ngwr.dev/reference/components/input\n */\n@Directive({\n selector: 'input[wrInput], textarea[wrInput]',\n host: {\n class: 'wr-input',\n '[class]': 'classes()',\n '[attr.id]': 'resolvedId()',\n '[attr.aria-invalid]': 'ariaInvalid()',\n '[attr.aria-describedby]': 'describedBy()',\n },\n})\nexport class WrInput {\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly field = inject(WR_FORM_FIELD, { optional: true });\n\n /**\n * Read once, at construction: a static `id=\"\"` in the template is already on\n * the element by the time a directive is instantiated, and it must win over\n * the field's generated one.\n */\n private readonly ownId = this.host.nativeElement.getAttribute('id');\n\n /**\n * Adopts the surrounding `<wr-form-field>`'s `controlId`, so the label it\n * already rendered actually points at this element. Without this the `for`\n * referenced an id that existed nowhere and the input had no label at all.\n */\n protected readonly resolvedId = computed(() => this.ownId ?? this.field?.controlId() ?? null);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n // Tell the field which id actually stuck. Without this its `<label for>` keeps\n // pointing at the generated id while this element answers to the author's own —\n // a label referencing nothing, which is the same as having none.\n if (this.ownId) this.field?.adoptControlId(this.ownId);\n }\n\n /**\n * Announced state, taken from the surrounding `<wr-form-field>`.\n *\n * The field renders the message but cannot reach the projected control, so\n * the control reads back: without this the error is visible on screen and\n * invisible to a screen reader, which never learns the field is invalid or\n * what the message says.\n */\n // Through the shared helper, not a local pair: the hint is described by\n // `hintId`, which only `useFormFieldAria()` composes, and `aria-invalid` keys\n // on the error COUNT rather than on \"something is described\". Hand-rolled here,\n // these three announced the error and never the hint — and `<input wrInput>` is\n // the control the report was filed against.\n private readonly fieldAria = useFormFieldAria();\n protected readonly describedBy = this.fieldAria.describedBy;\n protected readonly ariaInvalid = this.fieldAria.ariaInvalid;\n\n /**\n * Control size. @default 'md'\n *\n * Called `wrSize` until v14, to dodge the native `<input size>` attribute —\n * which measures the field in characters and which `.wr-input`'s `width: 100%`\n * has always overridden, so the clash it guarded against was never observable.\n * It made this the one size input in the catalog spelled differently from the\n * other twenty-three. The cost of the change is that a consumer who wanted the\n * NATIVE `size` on an ngwr input can no longer have it — but `width: 100%`\n * meant they never did.\n */\n readonly size = input<WrInputSize>('md');\n\n /** Pill-shaped corners. @default false */\n readonly rounded = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-input--${size}`);\n if (this.rounded()) parts.push('wr-input--rounded');\n return parts.join(' ');\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 { Directive } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Marks an element as the **left** decoration inside `<wr-input-group>`.\n * Adds the `.wr-input-group__affix` class so the group's layout flexes it\n * to the input's left edge.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <span wrInputPrefix>$</span>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * </wr-input-group>\n * ```\n */\n@Directive({\n selector: '[wrInputPrefix]',\n host: { class: 'wr-input-group__affix wr-input-group__affix--prefix' },\n})\nexport class WrInputPrefix {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\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 { Directive } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Marks an element as the **right** decoration inside `<wr-input-group>`.\n * Adds the `.wr-input-group__affix` class so the group's layout flexes it\n * to the input's right edge.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * <span wrInputSuffix>USD</span>\n * </wr-input-group>\n * ```\n */\n@Directive({\n selector: '[wrInputSuffix]',\n host: { class: 'wr-input-group__affix wr-input-group__affix--suffix' },\n})\nexport class WrInputSuffix {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n ElementRef,\n Renderer2,\n ViewEncapsulation,\n afterEveryRender,\n computed,\n contentChild,\n effect,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { WrSpinner } from 'ngwr/spinner';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrInput } from './directives';\n\n/**\n * Container for `<input wrInput>` + `[wrInputPrefix]` / `[wrInputSuffix]` /\n * `<wr-password-toggle>` siblings. Renders the border and focus ring; the\n * inner native input drops its own border so it visually melts into the\n * group.\n *\n * Focus styling is driven entirely by `:focus-within`, so any focusable child\n * counts.\n *\n * `clearable` and `loading` draw a clear (×) button and a spinner after the\n * field, before any `[wrInputSuffix]` or `<wr-password-toggle>`. Both act on the\n * first `wrInput` the group wraps.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <span wrInputPrefix>$</span>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * <span wrInputSuffix>USD</span>\n * </wr-input-group>\n *\n * <!-- a search box: a clear button, and a spinner while the lookup runs -->\n * <wr-input-group clearable [loading]=\"pending()\">\n * <input wrInput [(ngModel)]=\"query\" placeholder=\"Search\" />\n * </wr-input-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/input\n */\n@Component({\n selector: 'wr-input-group',\n templateUrl: './input-group.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-input-group', '[class]': 'classes()', '(input)': 'syncClear()' },\n imports: [WrSpinner],\n})\nexport class WrInputGroup {\n private readonly renderer = inject(Renderer2);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n\n // A native field's value is not a signal, and a model write (`ngModel`,\n // `[formField]`, a bound `[value]`) reaches it with no event. So the field\n // is read after every render, and on its own `input` events in between.\n afterEveryRender({ read: () => this.syncClear() });\n\n effect(() => {\n const field = this.field()?.nativeElement;\n if (!field) return;\n if (this.loading()) this.renderer.setAttribute(field, 'aria-busy', 'true');\n else this.renderer.removeAttribute(field, 'aria-busy');\n });\n }\n\n /** Pill-shaped corners. @default false */\n readonly rounded = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Show a clear (×) button while the field holds text and is neither disabled\n * nor read-only. Clearing empties the field through an `input` event, so\n * whatever is bound to it (`ngModel`, `[formField]`, an `(input)` listener)\n * hears it as an edit, and puts focus back in the field. It is a pointer\n * control: from the keyboard, emptying the field clears it. @default false\n */\n readonly clearable = input(false, { transform: coerceBooleanProperty });\n\n /** Clear (×) button aria-label. Falls back to `common.clear`. */\n readonly clearLabel = input<string | null>(null);\n\n /**\n * Show a spinner after the field and mark the field `aria-busy`. The field\n * stays editable. @default false\n */\n readonly loading = input(false, { transform: coerceBooleanProperty });\n\n /** Emitted after the clear (×) button emptied the field. */\n readonly cleared = output<void>();\n\n protected readonly resolvedClear = useI18nText(this.clearLabel, 'common.clear', 'Clear');\n\n private readonly field = contentChild<WrInput, ElementRef<HTMLInputElement | HTMLTextAreaElement>>(WrInput, {\n read: ElementRef,\n });\n\n /** Whether the field has text a user could clear right now. */\n private readonly fieldClearable = signal(false);\n\n protected readonly clearShown = computed(() => this.clearable() && this.fieldClearable());\n\n protected syncClear(): void {\n if (!this.clearable()) return;\n const field = this.field()?.nativeElement;\n this.fieldClearable.set(!!field && field.value !== '' && !field.disabled && !field.readOnly);\n }\n\n protected clear(): void {\n const field = this.field()?.nativeElement;\n if (!field || field.disabled || field.readOnly) return;\n field.value = '';\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.focus();\n this.cleared.emit();\n }\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.rounded()) parts.push('wr-input-group--rounded');\n return parts.join(' ');\n });\n}\n","<ng-content />\n<!-- Pointer-only, as the select's is: emptying the field is the keyboard way to clear. -->\n@if (clearShown()) {\n <span class=\"wr-input-group__clear\" role=\"button\" [attr.aria-label]=\"resolvedClear()\" tabindex=\"-1\" (click)=\"clear()\">\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </span>\n} @else if (clearable()) {\n <!-- Holds the ×'s room while the field is empty, so clearing does not narrow the group. -->\n <span class=\"wr-input-group__clear-space\" aria-hidden=\"true\"></span>\n}\n<!-- Hidden from the accessibility tree: the field says it is busy with `aria-busy`. -->\n@if (loading()) {\n <wr-spinner class=\"wr-input-group__spinner\" size=\"sm\" aria-hidden=\"true\" />\n}\n<ng-content select=\"[wrInputSuffix], wr-password-toggle\" />\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, computed, input, signal } from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Self-contained eye-toggle button. Flips the linked `<input>`'s `type`\n * attribute between `password` and `text`. Drop it inside an\n * `<wr-input-group>` next to a password input.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <input wrInput type=\"password\" [(ngModel)]=\"pw\" #pwInput />\n * <wr-password-toggle [for]=\"pwInput\" />\n * </wr-input-group>\n * ```\n */\n@Component({\n selector: 'wr-password-toggle',\n templateUrl: './password-toggle.html',\n encapsulation: ViewEncapsulation.None,\n})\nexport class WrPasswordToggle {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n }\n\n /** Reference to the linked password input. */\n readonly for = input.required<HTMLInputElement>();\n\n protected readonly revealed = signal(false);\n\n /** Accessible name while the password is hidden. Falls back to `input.showPassword`. */\n readonly showPasswordLabel = input<string | null>(null);\n\n /** Accessible name while the password is revealed. Falls back to `input.hidePassword`. */\n readonly hidePasswordLabel = input<string | null>(null);\n\n private readonly resolvedShowPasswordLabel = useI18nText(\n this.showPasswordLabel,\n 'input.showPassword',\n 'Show password'\n );\n private readonly resolvedHidePasswordLabel = useI18nText(\n this.hidePasswordLabel,\n 'input.hidePassword',\n 'Hide password'\n );\n\n protected readonly ariaLabel = computed(() =>\n this.revealed() ? this.resolvedHidePasswordLabel() : this.resolvedShowPasswordLabel()\n );\n\n protected toggle(): void {\n const input = this.for();\n const next = input.type === 'password' ? 'text' : 'password';\n input.type = next;\n this.revealed.set(next === 'text');\n }\n}\n","<button\n type=\"button\"\n class=\"wr-input-group__toggle\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-pressed]=\"revealed()\"\n (click)=\"toggle()\"\n>\n @if (revealed()) {\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49\" />\n <path d=\"M14.084 14.158a3 3 0 0 1-4.242-4.242\" />\n <path d=\"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143\" />\n <path d=\"m2 2 20 20\" />\n </svg>\n } @else {\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n }\n</button>\n"],"mappings":";;;;;;;;;;;;;AA8CA,IAAa,UAAb,MAAa,QAAO;CACD,OAAO,OAAgC,UAAU;CACjD,QAAQ,OAAO,eAAe,EAAE,UAAU,KAAI,CAAE;CAOhD,QAAQ,KAAK,KAAK,cAAc,aAAa,IAAI;CAO/C,aAAa,eAAe,KAAK,SAAS,KAAK,OAAO,UAAS,KAAM,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAE7F,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,OAAO;EAIxE,IAAI,KAAK,OAAO,KAAK,OAAO,eAAe,KAAK,KAAK;CACvD;CAeiB,YAAY,iBAAgB;CAC1B,cAAc,KAAK,UAAU;CAC7B,cAAc,KAAK,UAAU;CAavC,OAAO,MAAmB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAG/B,UAAU,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAE/C,UAAU,eAAc;EACzC,MAAM,QAAkB,CAAA;EACxB,MAAM,OAAO,KAAK,KAAI;EACtB,IAAI,SAAS,MAAM,MAAM,KAAK,aAAa,MAAM;EACjD,IAAI,KAAK,QAAO,GAAI,MAAM,KAAK,mBAAmB;EAClD,OAAO,MAAM,KAAK,GAAG;CACvB,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAjES,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAA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