ngwr 16.5.0 → 16.7.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/avatar/styles/_index.scss +39 -0
- package/back-top/styles/_index.scss +6 -0
- package/breadcrumbs/styles/_rules.scss +34 -0
- package/button/styles/_index.scss +45 -2
- package/cascader/styles/_rules.scss +7 -0
- package/charts/chart-legend/styles/_index.scss +1 -9
- package/copy-value/styles/_index.scss +4 -0
- package/counter/styles/_index.scss +1 -8
- package/date-picker/styles/_index.scss +15 -9
- package/dialog/styles/_index.scss +37 -0
- package/dropdown/styles/_index.scss +17 -0
- package/editor/styles/_index.scss +1 -8
- package/event-calendar/styles/_index.scss +2 -6
- package/fesm2022/ngwr-affix.mjs +4 -4
- package/fesm2022/ngwr-affix.mjs.map +1 -1
- package/fesm2022/ngwr-alert.mjs +3 -3
- package/fesm2022/ngwr-anchor.mjs +12 -5
- package/fesm2022/ngwr-anchor.mjs.map +1 -1
- package/fesm2022/ngwr-animations-aurora.mjs +3 -3
- package/fesm2022/ngwr-animations-aurora.mjs.map +1 -1
- package/fesm2022/ngwr-animations-blur-reveal.mjs +3 -3
- package/fesm2022/ngwr-animations-blur-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-click-sparks.mjs +3 -3
- package/fesm2022/ngwr-animations-click-sparks.mjs.map +1 -1
- package/fesm2022/ngwr-animations-confetti.mjs +3 -3
- package/fesm2022/ngwr-animations-confetti.mjs.map +1 -1
- package/fesm2022/ngwr-animations-decode.mjs +3 -3
- package/fesm2022/ngwr-animations-decode.mjs.map +1 -1
- package/fesm2022/ngwr-animations-destruct.mjs +3 -3
- package/fesm2022/ngwr-animations-destruct.mjs.map +1 -1
- package/fesm2022/ngwr-animations-dot-grid.mjs +3 -3
- package/fesm2022/ngwr-animations-dot-grid.mjs.map +1 -1
- package/fesm2022/ngwr-animations-falling-letters.mjs +3 -3
- package/fesm2022/ngwr-animations-falling-letters.mjs.map +1 -1
- package/fesm2022/ngwr-animations-flow-lines.mjs +3 -3
- package/fesm2022/ngwr-animations-flow-lines.mjs.map +1 -1
- package/fesm2022/ngwr-animations-fluid-cursor.mjs +3 -3
- package/fesm2022/ngwr-animations-fluid-cursor.mjs.map +1 -1
- package/fesm2022/ngwr-animations-glitch.mjs +3 -3
- package/fesm2022/ngwr-animations-glitch.mjs.map +1 -1
- package/fesm2022/ngwr-animations-glow-border.mjs +3 -3
- package/fesm2022/ngwr-animations-glow-border.mjs.map +1 -1
- package/fesm2022/ngwr-animations-gradient-flow.mjs +3 -3
- package/fesm2022/ngwr-animations-gradient-flow.mjs.map +1 -1
- package/fesm2022/ngwr-animations-marquee.mjs +4 -3
- package/fesm2022/ngwr-animations-marquee.mjs.map +1 -1
- package/fesm2022/ngwr-animations-orbit.mjs +3 -3
- package/fesm2022/ngwr-animations-orbit.mjs.map +1 -1
- package/fesm2022/ngwr-animations-reveal.mjs +3 -3
- package/fesm2022/ngwr-animations-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-ripple-grid.mjs +3 -3
- package/fesm2022/ngwr-animations-ripple-grid.mjs.map +1 -1
- package/fesm2022/ngwr-animations-rotate-reveal.mjs +3 -3
- package/fesm2022/ngwr-animations-rotate-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-shimmer.mjs +3 -3
- package/fesm2022/ngwr-animations-shimmer.mjs.map +1 -1
- package/fesm2022/ngwr-animations-spotlight.mjs +3 -3
- package/fesm2022/ngwr-animations-spotlight.mjs.map +1 -1
- package/fesm2022/ngwr-animations-thread-lines.mjs +3 -3
- package/fesm2022/ngwr-animations-thread-lines.mjs.map +1 -1
- package/fesm2022/ngwr-animations-tilt.mjs +23 -16
- package/fesm2022/ngwr-animations-tilt.mjs.map +1 -1
- package/fesm2022/ngwr-animations-typewriter.mjs +3 -3
- package/fesm2022/ngwr-animations-typewriter.mjs.map +1 -1
- package/fesm2022/ngwr-avatar.mjs +171 -6
- package/fesm2022/ngwr-avatar.mjs.map +1 -1
- package/fesm2022/ngwr-back-top.mjs +3 -3
- package/fesm2022/ngwr-badge.mjs +6 -6
- package/fesm2022/ngwr-breadcrumbs.mjs +47 -13
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-burger.mjs +3 -3
- package/fesm2022/ngwr-button.mjs +38 -9
- package/fesm2022/ngwr-button.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +3 -3
- package/fesm2022/ngwr-card.mjs +9 -9
- package/fesm2022/ngwr-carousel.mjs +14 -8
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +27 -7
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart.mjs +3 -3
- 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 +9 -9
- package/fesm2022/ngwr-charts-core.mjs +18 -11
- package/fesm2022/ngwr-charts-core.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart.mjs +3 -3
- 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.mjs +3 -3
- package/fesm2022/ngwr-charts-meter-group.mjs +7 -5
- package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-scatter-chart.mjs +3 -3
- 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 +9 -8
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-clipboard.mjs +3 -3
- package/fesm2022/ngwr-collapse.mjs +9 -9
- package/fesm2022/ngwr-color-picker.mjs +27 -7
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-command-palette.mjs +3 -3
- package/fesm2022/ngwr-comment.mjs +7 -6
- package/fesm2022/ngwr-comment.mjs.map +1 -1
- package/fesm2022/ngwr-compare.mjs +3 -3
- package/fesm2022/ngwr-context-menu.mjs +16 -17
- 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 +35 -0
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +151 -54
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp.mjs +3 -3
- package/fesm2022/ngwr-date.mjs +40 -16
- 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 +35 -24
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +189 -23
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-divider.mjs +3 -3
- package/fesm2022/ngwr-drawer.mjs +18 -18
- package/fesm2022/ngwr-dropdown-testing.mjs +5 -1
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +59 -16
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +6 -5
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-empty.mjs +3 -3
- package/fesm2022/ngwr-event-calendar.mjs +27 -15
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload-testing.mjs +5 -0
- package/fesm2022/ngwr-file-upload-testing.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +68 -13
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +181 -12
- 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 +100 -11
- package/fesm2022/ngwr-graph.mjs.map +1 -1
- package/fesm2022/ngwr-hotkey.mjs +6 -6
- package/fesm2022/ngwr-i18n-ar.mjs +21 -2
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +21 -2
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +21 -2
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +21 -2
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +21 -2
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +21 -2
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +21 -2
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +21 -2
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +21 -2
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +21 -2
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +21 -2
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-kk.mjs +520 -0
- package/fesm2022/ngwr-i18n-kk.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-ko.mjs +21 -2
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +21 -2
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +21 -2
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +21 -2
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +21 -2
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +21 -2
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +21 -2
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +21 -2
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +21 -2
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +21 -2
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +21 -2
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +91 -20
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-icon.mjs +6 -6
- package/fesm2022/ngwr-image-cropper.mjs +8 -4
- package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +27 -4
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +5 -5
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +25 -17
- 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-layout.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +8 -8
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +9 -9
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-load-state.mjs +16 -15
- package/fesm2022/ngwr-load-state.mjs.map +1 -1
- package/fesm2022/ngwr-loading-bar-router.mjs.map +1 -1
- package/fesm2022/ngwr-loading-bar.mjs +8 -8
- package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
- package/fesm2022/ngwr-mention.mjs +14 -6
- package/fesm2022/ngwr-mention.mjs.map +1 -1
- package/fesm2022/ngwr-meta.mjs +15 -12
- package/fesm2022/ngwr-meta.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +9 -9
- package/fesm2022/ngwr-page-header.mjs +24 -3
- package/fesm2022/ngwr-page-header.mjs.map +1 -1
- package/fesm2022/ngwr-pagination-testing.mjs +3 -0
- package/fesm2022/ngwr-pagination-testing.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +34 -5
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +35 -28
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-platform.mjs +9 -9
- package/fesm2022/ngwr-popconfirm.mjs +9 -7
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +162 -18
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-progress.mjs +75 -10
- package/fesm2022/ngwr-progress.mjs.map +1 -1
- package/fesm2022/ngwr-pull-to-refresh.mjs +3 -3
- package/fesm2022/ngwr-qr.mjs +9 -5
- package/fesm2022/ngwr-qr.mjs.map +1 -1
- package/fesm2022/ngwr-radio.mjs +77 -11
- package/fesm2022/ngwr-radio.mjs.map +1 -1
- package/fesm2022/ngwr-rating.mjs +3 -3
- package/fesm2022/ngwr-resizable.mjs +3 -3
- package/fesm2022/ngwr-result.mjs +12 -12
- package/fesm2022/ngwr-schema-form.mjs +20 -7
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-scroll.mjs +233 -10
- package/fesm2022/ngwr-scroll.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +23 -3
- package/fesm2022/ngwr-segmented.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +106 -26
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-sidebar-testing.mjs +17 -1
- package/fesm2022/ngwr-sidebar-testing.mjs.map +1 -1
- package/fesm2022/ngwr-sidebar.mjs +66 -11
- package/fesm2022/ngwr-sidebar.mjs.map +1 -1
- package/fesm2022/ngwr-skeleton.mjs +3 -3
- package/fesm2022/ngwr-slider.mjs +3 -3
- package/fesm2022/ngwr-sortable-list.mjs +27 -15
- 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 +6 -6
- package/fesm2022/ngwr-storage.mjs +4 -4
- package/fesm2022/ngwr-storage.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +5 -5
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-table-router.mjs +89 -0
- package/fesm2022/ngwr-table-router.mjs.map +1 -0
- package/fesm2022/ngwr-table-testing.mjs +5 -0
- package/fesm2022/ngwr-table-testing.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +307 -47
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tabs-router.mjs +9 -5
- package/fesm2022/ngwr-tabs-router.mjs.map +1 -1
- package/fesm2022/ngwr-tabs-testing.mjs +8 -1
- package/fesm2022/ngwr-tabs-testing.mjs.map +1 -1
- package/fesm2022/ngwr-tabs.mjs +60 -10
- package/fesm2022/ngwr-tabs.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +5 -5
- 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 +43 -15
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-toolbar.mjs +3 -3
- package/fesm2022/ngwr-tour.mjs +9 -8
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-transfer.mjs +4 -3
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +3 -3
- package/fesm2022/ngwr-typography.mjs +23 -3
- package/fesm2022/ngwr-typography.mjs.map +1 -1
- package/fesm2022/ngwr-utils-router.mjs +3 -3
- package/fesm2022/ngwr-utils-router.mjs.map +1 -1
- package/fesm2022/ngwr-utils.mjs +74 -4
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-validators.mjs +33 -1
- package/fesm2022/ngwr-validators.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 +18 -13
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/file-upload/styles/_index.scss +16 -0
- package/form/styles/_index.scss +37 -0
- package/graph/styles/_index.scss +49 -9
- package/i18n/ar.json +19 -2
- package/i18n/cs.json +19 -2
- package/i18n/de.json +19 -2
- package/i18n/en.json +19 -2
- package/i18n/es.json +19 -2
- package/i18n/fr.json +19 -2
- package/i18n/he.json +19 -2
- package/i18n/hi.json +19 -2
- package/i18n/id.json +19 -2
- package/i18n/it.json +19 -2
- package/i18n/ja.json +19 -2
- package/i18n/kk.json +567 -0
- package/i18n/ko.json +19 -2
- package/i18n/nl.json +19 -2
- package/i18n/pl.json +19 -2
- package/i18n/pt.json +19 -2
- package/i18n/ru.json +19 -2
- package/i18n/sv.json +19 -2
- package/i18n/tr.json +19 -2
- package/i18n/uk.json +19 -2
- package/i18n/vi.json +19 -2
- package/i18n/zh-TW.json +19 -2
- package/i18n/zh.json +19 -2
- package/image-cropper/styles/_index.scss +1 -9
- package/input-number/styles/_index.scss +7 -0
- package/layout/styles/_index.scss +13 -1
- package/llms-full.txt +37 -26
- package/llms.txt +4 -1
- package/loading-bar/styles/_rules.scss +6 -0
- package/package.json +16 -8
- package/page-header/styles/_index.scss +18 -0
- package/pagination/styles/_index.scss +6 -0
- package/popover/styles/_index.scss +9 -0
- package/progress/styles/_index.scss +64 -0
- package/schematics/use/symbol-map.json +7 -0
- package/segmented/styles/_index.scss +7 -0
- package/select/styles/_index.scss +7 -0
- package/sidebar/styles/_index.scss +64 -6
- package/skills/ngwr/SKILL.md +7 -6
- package/skills/ngwr/references/catalog.md +7 -5
- package/sortable-list/styles/_rules.scss +1 -9
- package/speed-dial/styles/_index.scss +6 -0
- package/stepper/styles/_index.scss +1 -9
- package/table/styles/_index.scss +168 -30
- package/tabs/styles/_index.scss +9 -0
- package/theme/_index.scss +12 -1
- package/theme/styles/_colors.scss +11 -0
- package/theme/styles/_contrast.scss +6 -0
- package/theme/styles/_focus.scss +3 -1
- package/theme/styles/_index.scss +1 -0
- package/theme/styles/_mixins.scss +45 -0
- package/theme/styles/_print.scss +17 -0
- package/toast/styles/_index.scss +7 -0
- package/tour/styles/_index.scss +9 -0
- package/tree/styles/_index.scss +1 -9
- package/types/ngwr-anchor.d.ts +3 -0
- package/types/ngwr-animations-aurora.d.ts +6 -0
- package/types/ngwr-animations-blur-reveal.d.ts +6 -0
- package/types/ngwr-animations-click-sparks.d.ts +6 -0
- package/types/ngwr-animations-confetti.d.ts +6 -0
- package/types/ngwr-animations-decode.d.ts +6 -0
- package/types/ngwr-animations-destruct.d.ts +6 -0
- package/types/ngwr-animations-dot-grid.d.ts +6 -0
- package/types/ngwr-animations-falling-letters.d.ts +6 -0
- package/types/ngwr-animations-flow-lines.d.ts +6 -0
- package/types/ngwr-animations-fluid-cursor.d.ts +6 -0
- package/types/ngwr-animations-glitch.d.ts +6 -0
- package/types/ngwr-animations-glow-border.d.ts +6 -0
- package/types/ngwr-animations-gradient-flow.d.ts +6 -0
- package/types/ngwr-animations-marquee.d.ts +6 -0
- package/types/ngwr-animations-orbit.d.ts +6 -0
- package/types/ngwr-animations-reveal.d.ts +6 -0
- package/types/ngwr-animations-ripple-grid.d.ts +6 -0
- package/types/ngwr-animations-rotate-reveal.d.ts +6 -0
- package/types/ngwr-animations-shimmer.d.ts +6 -0
- package/types/ngwr-animations-spotlight.d.ts +6 -0
- package/types/ngwr-animations-thread-lines.d.ts +6 -0
- package/types/ngwr-animations-tilt.d.ts +10 -0
- package/types/ngwr-animations-typewriter.d.ts +6 -0
- package/types/ngwr-avatar.d.ts +39 -0
- package/types/ngwr-breadcrumbs.d.ts +25 -0
- package/types/ngwr-button.d.ts +35 -3
- package/types/ngwr-carousel.d.ts +2 -0
- package/types/ngwr-cascader.d.ts +7 -0
- package/types/ngwr-charts-core.d.ts +16 -0
- package/types/ngwr-charts-meter-group.d.ts +2 -0
- package/types/ngwr-checkbox.d.ts +1 -0
- package/types/ngwr-color-picker.d.ts +1 -0
- package/types/ngwr-context-menu.d.ts +1 -1
- package/types/ngwr-date-picker-testing.d.ts +22 -0
- package/types/ngwr-date-picker.d.ts +97 -17
- package/types/ngwr-date.d.ts +51 -0
- package/types/ngwr-dialog.d.ts +39 -8
- package/types/ngwr-directives.d.ts +57 -4
- package/types/ngwr-drawer.d.ts +1 -1
- package/types/ngwr-dropdown-testing.d.ts +8 -1
- package/types/ngwr-dropdown.d.ts +30 -1
- package/types/ngwr-event-calendar.d.ts +4 -0
- package/types/ngwr-file-upload-testing.d.ts +10 -0
- package/types/ngwr-file-upload.d.ts +55 -1
- package/types/ngwr-form.d.ts +87 -1
- package/types/ngwr-graph-testing.d.ts +28 -1
- package/types/ngwr-graph.d.ts +53 -3
- package/types/ngwr-i18n-kk.d.ts +3 -0
- package/types/ngwr-i18n.d.ts +65 -5
- package/types/ngwr-image-cropper.d.ts +6 -0
- package/types/ngwr-input-number.d.ts +8 -0
- package/types/ngwr-input.d.ts +7 -0
- package/types/ngwr-layout.d.ts +1 -1
- package/types/ngwr-loading-bar-router.d.ts +6 -0
- package/types/ngwr-page-header.d.ts +23 -1
- package/types/ngwr-pagination-testing.d.ts +8 -0
- package/types/ngwr-pagination.d.ts +16 -0
- package/types/ngwr-popconfirm.d.ts +1 -1
- package/types/ngwr-popover.d.ts +67 -4
- package/types/ngwr-progress.d.ts +63 -1
- package/types/ngwr-radio.d.ts +47 -5
- package/types/ngwr-scroll.d.ts +86 -0
- package/types/ngwr-segmented.d.ts +7 -0
- package/types/ngwr-select.d.ts +88 -25
- package/types/ngwr-sidebar-testing.d.ts +21 -7
- package/types/ngwr-sidebar.d.ts +66 -4
- package/types/ngwr-sortable-list.d.ts +20 -7
- package/types/ngwr-table-router.d.ts +49 -0
- package/types/ngwr-table-testing.d.ts +7 -0
- package/types/ngwr-table.d.ts +241 -10
- package/types/ngwr-tabs-router.d.ts +7 -1
- package/types/ngwr-tabs-testing.d.ts +5 -1
- package/types/ngwr-tabs.d.ts +34 -1
- package/types/ngwr-toast.d.ts +11 -0
- package/types/ngwr-tour.d.ts +0 -1
- package/types/ngwr-typography.d.ts +7 -0
- package/types/ngwr-utils-router.d.ts +6 -0
- package/types/ngwr-utils.d.ts +69 -2
- package/types/ngwr-validators.d.ts +49 -1
- package/types/ngwr-version.d.ts +1 -1
- package/typography/styles/_index.scss +4 -0
- package/window/styles/_index.scss +1 -9
|
@@ -98,7 +98,7 @@ var WrStatistic = class WrStatistic {
|
|
|
98
98
|
}, ...ngDevMode ? [{ debugName: "deltaText" }] : /* istanbul ignore next */ []);
|
|
99
99
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
100
100
|
minVersion: "12.0.0",
|
|
101
|
-
version: "22.
|
|
101
|
+
version: "22.3.0",
|
|
102
102
|
ngImport: i0,
|
|
103
103
|
type: WrStatistic,
|
|
104
104
|
deps: [],
|
|
@@ -106,7 +106,7 @@ var WrStatistic = class WrStatistic {
|
|
|
106
106
|
});
|
|
107
107
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
108
108
|
minVersion: "17.0.0",
|
|
109
|
-
version: "22.
|
|
109
|
+
version: "22.3.0",
|
|
110
110
|
type: WrStatistic,
|
|
111
111
|
isStandalone: true,
|
|
112
112
|
selector: "wr-statistic",
|
|
@@ -202,7 +202,7 @@ var WrStatistic = class WrStatistic {
|
|
|
202
202
|
};
|
|
203
203
|
i0.ɵɵngDeclareClassMetadata({
|
|
204
204
|
minVersion: "12.0.0",
|
|
205
|
-
version: "22.
|
|
205
|
+
version: "22.3.0",
|
|
206
206
|
ngImport: i0,
|
|
207
207
|
type: WrStatistic,
|
|
208
208
|
decorators: [{
|
|
@@ -369,7 +369,7 @@ var WrStatisticCountdown = class WrStatisticCountdown {
|
|
|
369
369
|
}
|
|
370
370
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
371
371
|
minVersion: "12.0.0",
|
|
372
|
-
version: "22.
|
|
372
|
+
version: "22.3.0",
|
|
373
373
|
ngImport: i0,
|
|
374
374
|
type: WrStatisticCountdown,
|
|
375
375
|
deps: [],
|
|
@@ -377,7 +377,7 @@ var WrStatisticCountdown = class WrStatisticCountdown {
|
|
|
377
377
|
});
|
|
378
378
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
379
379
|
minVersion: "17.0.0",
|
|
380
|
-
version: "22.
|
|
380
|
+
version: "22.3.0",
|
|
381
381
|
type: WrStatisticCountdown,
|
|
382
382
|
isStandalone: true,
|
|
383
383
|
selector: "wr-statistic-countdown",
|
|
@@ -427,7 +427,7 @@ var WrStatisticCountdown = class WrStatisticCountdown {
|
|
|
427
427
|
};
|
|
428
428
|
i0.ɵɵngDeclareClassMetadata({
|
|
429
429
|
minVersion: "12.0.0",
|
|
430
|
-
version: "22.
|
|
430
|
+
version: "22.3.0",
|
|
431
431
|
ngImport: i0,
|
|
432
432
|
type: WrStatisticCountdown,
|
|
433
433
|
decorators: [{
|
|
@@ -504,7 +504,7 @@ var WrStatisticGroup = class WrStatisticGroup {
|
|
|
504
504
|
});
|
|
505
505
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
506
506
|
minVersion: "12.0.0",
|
|
507
|
-
version: "22.
|
|
507
|
+
version: "22.3.0",
|
|
508
508
|
ngImport: i0,
|
|
509
509
|
type: WrStatisticGroup,
|
|
510
510
|
deps: [],
|
|
@@ -512,7 +512,7 @@ var WrStatisticGroup = class WrStatisticGroup {
|
|
|
512
512
|
});
|
|
513
513
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
514
514
|
minVersion: "17.1.0",
|
|
515
|
-
version: "22.
|
|
515
|
+
version: "22.3.0",
|
|
516
516
|
type: WrStatisticGroup,
|
|
517
517
|
isStandalone: true,
|
|
518
518
|
selector: "wr-statistic-group",
|
|
@@ -547,7 +547,7 @@ var WrStatisticGroup = class WrStatisticGroup {
|
|
|
547
547
|
};
|
|
548
548
|
i0.ɵɵngDeclareClassMetadata({
|
|
549
549
|
minVersion: "12.0.0",
|
|
550
|
-
version: "22.
|
|
550
|
+
version: "22.3.0",
|
|
551
551
|
ngImport: i0,
|
|
552
552
|
type: WrStatisticGroup,
|
|
553
553
|
decorators: [{
|
|
@@ -36,7 +36,7 @@ var WrStep = class WrStep {
|
|
|
36
36
|
isActive = computed(() => this._index() === this.stepper.active(), ...ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []);
|
|
37
37
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
38
38
|
minVersion: "12.0.0",
|
|
39
|
-
version: "22.
|
|
39
|
+
version: "22.3.0",
|
|
40
40
|
ngImport: i0,
|
|
41
41
|
type: WrStep,
|
|
42
42
|
deps: [],
|
|
@@ -44,7 +44,7 @@ var WrStep = class WrStep {
|
|
|
44
44
|
});
|
|
45
45
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
46
46
|
minVersion: "17.1.0",
|
|
47
|
-
version: "22.
|
|
47
|
+
version: "22.3.0",
|
|
48
48
|
type: WrStep,
|
|
49
49
|
isStandalone: true,
|
|
50
50
|
selector: "wr-step",
|
|
@@ -97,7 +97,7 @@ var WrStep = class WrStep {
|
|
|
97
97
|
};
|
|
98
98
|
i0.ɵɵngDeclareClassMetadata({
|
|
99
99
|
minVersion: "12.0.0",
|
|
100
|
-
version: "22.
|
|
100
|
+
version: "22.3.0",
|
|
101
101
|
ngImport: i0,
|
|
102
102
|
type: WrStep,
|
|
103
103
|
decorators: [{
|
|
@@ -225,7 +225,7 @@ var WrStepper = class WrStepper {
|
|
|
225
225
|
}
|
|
226
226
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
227
227
|
minVersion: "12.0.0",
|
|
228
|
-
version: "22.
|
|
228
|
+
version: "22.3.0",
|
|
229
229
|
ngImport: i0,
|
|
230
230
|
type: WrStepper,
|
|
231
231
|
deps: [],
|
|
@@ -233,7 +233,7 @@ var WrStepper = class WrStepper {
|
|
|
233
233
|
});
|
|
234
234
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
235
235
|
minVersion: "17.0.0",
|
|
236
|
-
version: "22.
|
|
236
|
+
version: "22.3.0",
|
|
237
237
|
type: WrStepper,
|
|
238
238
|
isStandalone: true,
|
|
239
239
|
selector: "wr-stepper",
|
|
@@ -302,7 +302,7 @@ var WrStepper = class WrStepper {
|
|
|
302
302
|
};
|
|
303
303
|
i0.ɵɵngDeclareClassMetadata({
|
|
304
304
|
minVersion: "12.0.0",
|
|
305
|
-
version: "22.
|
|
305
|
+
version: "22.3.0",
|
|
306
306
|
ngImport: i0,
|
|
307
307
|
type: WrStepper,
|
|
308
308
|
decorators: [{
|
|
@@ -97,7 +97,7 @@ var WrStorage = class WrStorage {
|
|
|
97
97
|
}
|
|
98
98
|
if (!isEnvelope(parsed)) return parsed;
|
|
99
99
|
if (parsed.e !== void 0 && parsed.e < Date.now()) {
|
|
100
|
-
this.remove(key);
|
|
100
|
+
untracked(() => this.remove(key));
|
|
101
101
|
return fallback;
|
|
102
102
|
}
|
|
103
103
|
return parsed.v;
|
|
@@ -208,7 +208,7 @@ var WrStorage = class WrStorage {
|
|
|
208
208
|
}
|
|
209
209
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
210
210
|
minVersion: "12.0.0",
|
|
211
|
-
version: "22.
|
|
211
|
+
version: "22.3.0",
|
|
212
212
|
ngImport: i0,
|
|
213
213
|
type: WrStorage,
|
|
214
214
|
deps: [],
|
|
@@ -216,14 +216,14 @@ var WrStorage = class WrStorage {
|
|
|
216
216
|
});
|
|
217
217
|
static ɵprov = i0.ɵɵngDeclareService({
|
|
218
218
|
minVersion: "22.0.0",
|
|
219
|
-
version: "22.
|
|
219
|
+
version: "22.3.0",
|
|
220
220
|
ngImport: i0,
|
|
221
221
|
type: WrStorage
|
|
222
222
|
});
|
|
223
223
|
};
|
|
224
224
|
i0.ɵɵngDeclareClassMetadata({
|
|
225
225
|
minVersion: "12.0.0",
|
|
226
|
-
version: "22.
|
|
226
|
+
version: "22.3.0",
|
|
227
227
|
ngImport: i0,
|
|
228
228
|
type: WrStorage,
|
|
229
229
|
decorators: [{ type: Service }]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-storage.mjs","names":[],"sources":["../../../projects/lib/storage/storage-config.ts","../../../projects/lib/storage/storage-engine.ts","../../../projects/lib/storage/storage.ts","../../../projects/lib/storage/with-storage.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageConfigResolved } from './types';\n\nexport const DEFAULT_WR_STORAGE_CONFIG: WrStorageConfigResolved = {\n prefix: '',\n json: true,\n ttl: 0,\n};\n\nexport const WR_STORAGE_CONFIG = new InjectionToken<WrStorageConfigResolved>('WR_STORAGE_CONFIG', {\n providedIn: 'root',\n factory: () => DEFAULT_WR_STORAGE_CONFIG,\n});\n\nexport type { WrStorageConfig, WrStorageConfigResolved } from './types';\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 { InjectionToken } from '@angular/core';\n\nimport type { WrStorageEngine } from './types';\n\n/**\n * Probe a `Storage` candidate to confirm it's writable. Safari private\n * mode, disabled cookies, and storage-blocked iframes all throw on\n * `setItem` — fall back to memory in those cases.\n */\nfunction probe(engine: WrStorageEngine): boolean {\n try {\n const k = '__wr_storage_probe__';\n engine.setItem(k, '1');\n engine.removeItem(k);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * In-memory implementation of `Storage`. Used as the SSR / private-mode\n * fallback. Exported so consumers can opt into it explicitly for tests.\n */\nexport function wrCreateMemoryStorage(): WrStorageEngine {\n const map = new Map<string, string>();\n return {\n get length(): number {\n return map.size;\n },\n clear(): void {\n map.clear();\n },\n getItem(key: string): string | null {\n return map.has(key) ? map.get(key)! : null;\n },\n key(i: number): string | null {\n return Array.from(map.keys())[i] ?? null;\n },\n removeItem(key: string): void {\n map.delete(key);\n },\n setItem(key: string, value: string): void {\n map.set(key, value);\n },\n };\n}\n\n/**\n * Injection token for the active storage engine. Provide it at BOOTSTRAP to\n * swap engines (e.g. `sessionStorage` for a tab-only app):\n *\n * ```ts\n * providers: [{ provide: WR_STORAGE_ENGINE, useValue: sessionStorage }]\n * ```\n *\n * Not at an arbitrary injector level: `WrStorage` is root-provided and reads\n * the token in a field initializer, so the singleton resolves its engine once\n * and a token re-provided on a lazy route or in a component's `providers`\n * reaches no existing `inject(WrStorage)` — every read and write still goes to\n * the engine the root instance already took, with nothing thrown and nothing\n * logged. A feature that genuinely needs its own engine provides its own\n * `WrStorage` beside it.\n *\n * The default factory returns `localStorage` in the browser when it's\n * actually writable, an in-memory map otherwise.\n */\nexport const WR_STORAGE_ENGINE = new InjectionToken<WrStorageEngine>('WR_STORAGE_ENGINE', {\n providedIn: 'root',\n factory: () => {\n try {\n // The getter itself throws a SecurityError when the browser blocks storage.\n if (typeof localStorage !== 'undefined' && probe(localStorage)) return localStorage;\n } catch {\n // Fall through to memory.\n }\n return wrCreateMemoryStorage();\n },\n});\n\nexport type { WrStorageEngine } from './types';\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 { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Service,\n PLATFORM_ID,\n type Signal,\n type WritableSignal,\n inject,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WR_STORAGE_CONFIG } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\nimport type { WrStorageEnvelope } from './types';\n\nfunction isEnvelope(x: unknown): x is WrStorageEnvelope {\n return x !== null && typeof x === 'object' && 'v' in x;\n}\n\n/**\n * One key's signal. `sig.set` persists, so a refresh from storage goes through\n * `write`, the setter the signal was born with.\n */\ninterface Watcher {\n readonly sig: WritableSignal<unknown>;\n readonly fallback: unknown;\n readonly write: (value: unknown) => void;\n}\n\n/**\n * Reactive key/value storage on top of any `Storage`-compatible engine.\n *\n * - **Swap engines** through {@link WR_STORAGE_ENGINE} or\n * `provideWr(withStorage(...))`. Default: `localStorage` with an in-memory\n * fallback for SSR / private mode.\n * - **Namespacing** via `prefix` (config) — every key is transparently\n * prefixed on read / write.\n * - **TTL** per-call or default — values past their expiry are removed\n * lazily on the next `get` / `watch` read.\n * - **Reactive watch** — `watch(key)` returns a `Signal` that updates on\n * local writes and cross-tab `storage` events. `signal(key, default)` is the\n * writable twin: `set` and `update` persist as they go.\n * - **On-disk format** — values are wrapped in a {@link WrStorageEnvelope}\n * (`{\"v\":…,\"e\":…}`) while `json` is on. Anything reading the same key from\n * outside Angular has to unwrap it.\n *\n * SSR-safe: the default engine factory returns an in-memory shim when\n * `localStorage` is unavailable, so reads always work.\n *\n * @example\n * ```ts\n * const store = inject(WrStorage);\n *\n * store.set('user', { name: 'Ada' });\n * store.get<{ name: string }>('user'); // { name: 'Ada' }\n *\n * store.set('cart', items, { ttl: 60_000 }); // expires in 60s\n *\n * const theme = store.watch<'light' | 'dark'>('theme', 'light');\n * effect(() => console.log('theme is', theme()));\n *\n * const density = store.signal<'compact' | 'comfortable'>('density', 'comfortable');\n * density.set('compact'); // stored, and every tab follows\n * ```\n *\n * @see https://ngwr.dev/reference/services/storage\n */\n@Service()\nexport class WrStorage {\n private readonly engine = inject(WR_STORAGE_ENGINE);\n private readonly config = inject(WR_STORAGE_CONFIG);\n private readonly destroyRef = inject(DestroyRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /**\n * Per-key watchers. Shared so multiple `watch(k)` and `signal(k)` calls reuse\n * one signal.\n *\n * The fallback is kept alongside the signal because every refresh has to read\n * the key the same way `watch` first did. Refreshing without it made `get` and\n * `watch` disagree about what an ABSENT key means: after a `remove()` the\n * signal went to `null` while `get(key, fallback)` still answered with the\n * default, so a consumer watching `'theme'` with a `'light'` fallback got no\n * theme at all rather than the light one.\n */\n private readonly watchers = new Map<string, Watcher>();\n private listenerInstalled = false;\n\n // Public API\n\n /**\n * Is `key` present? A raw presence check: it does not parse the envelope, so\n * an EXPIRED entry still answers `true` until something reads it — `get()`\n * is what notices the TTL and removes the key on its way out. Branch on\n * `get() !== null` when the answer has to respect expiry; this one is for\n * \"is there anything under this key at all\", quota accounting included.\n */\n has(key: string): boolean {\n return this.engine.getItem(this.fullKey(key)) !== null;\n }\n\n /**\n * Read `key`. Returns `fallback` (default `null`) when the key is\n * missing or expired. Expired values are also removed as a side effect.\n */\n get<T = unknown>(key: string, fallback: T | null = null): T | null {\n const fk = this.fullKey(key);\n const raw = this.engine.getItem(fk);\n if (raw === null) return fallback;\n\n if (!this.config.json) return raw as unknown as T;\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // Non-JSON value written by external code — return as-is.\n return raw as unknown as T;\n }\n\n if (!isEnvelope(parsed)) return parsed as T;\n\n if (parsed.e !== undefined && parsed.e < Date.now()) {\n this.remove(key);\n return fallback;\n }\n return parsed.v as T;\n }\n\n /**\n * Write `value` at `key`. Per-call `ttl` (ms) overrides the config\n * default. JSON-serializable values only when `json` is on (the default).\n *\n * What lands in the engine is a {@link WrStorageEnvelope} —\n * `{\"v\":<value>}`, plus `\"e\"` when a TTL applies — not the bare value. Code\n * outside Angular that reads the same key has to unwrap it; see the envelope's\n * own docs for the exact format.\n */\n set<T = unknown>(key: string, value: T, opts?: { ttl?: number }): void {\n if (this.persist(key, value, opts)) this.notify(key);\n }\n\n /** Remove `key`. No-op when absent. */\n remove(key: string): void {\n this.engine.removeItem(this.fullKey(key));\n this.notify(key);\n }\n\n /**\n * Clear every key owned by this prefix. When `prefix` is empty this\n * defers to `engine.clear()` (clears everything — be careful with\n * shared storage).\n */\n clear(): void {\n const p = this.config.prefix;\n if (p) {\n for (const fk of this.rawKeys()) this.engine.removeItem(fk);\n } else {\n this.engine.clear();\n }\n // Refresh every active watcher — they may have just been cleared.\n this.refreshAll();\n }\n\n /** All known keys under our prefix, with the prefix stripped. */\n keys(): readonly string[] {\n const p = this.config.prefix;\n return this.rawKeys().map(k => (p ? k.slice(p.length) : k));\n }\n\n /**\n * Reactive read of `key`. Updates when this instance writes to the key,\n * when `clear()` runs, and when another tab updates `localStorage`\n * under the same prefix. Returned signal is shared per key — calling\n * `watch(k)` twice returns the same signal.\n */\n watch<T = unknown>(key: string, fallback: T | null = null): Signal<T | null> {\n return (this.watcher(key, fallback).sig as WritableSignal<T | null>).asReadonly();\n }\n\n /**\n * Writable twin of {@link watch}: `set` and `update` store the value, then\n * the signal takes it. The signal is the one `watch(key)` reads, so a\n * `set()`, `remove()` or `clear()` on this instance moves it too, and so does\n * a write from another tab; a key another tab removes goes back to\n * `defaultValue`. Shared per key, so a second `signal(key)` is the same\n * signal and the first call's default stands.\n *\n * A `set` to the value it already holds (`Object.is`) writes nothing, like a\n * plain signal. A write the engine refuses (quota, storage disabled) is\n * logged and dropped exactly as `set()` does, and nothing throws: the signal\n * keeps the new value for this tab, and the next load reads what was stored\n * before.\n *\n * On the server it reads the engine as `watch()` does, so with the default\n * in-memory engine it holds `defaultValue`, and no `storage` listener is\n * installed. Hydration: the server renders that default and the browser\n * instance reads `localStorage` when it is created, so the first client\n * render can differ from the server markup, as with `watch()`.\n */\n signal<T>(key: string, defaultValue: T): WritableSignal<T> {\n return this.watcher(key, defaultValue).sig as WritableSignal<T>;\n }\n\n // Internals\n\n private fullKey(key: string): string {\n return this.config.prefix + key;\n }\n\n private watcher(key: string, fallback: unknown): Watcher {\n const existing = this.watchers.get(key);\n if (existing) return existing;\n\n const sig = signal<unknown>(this.get(key, fallback));\n const write = sig.set.bind(sig);\n sig.set = value => {\n if (Object.is(value, untracked(sig))) return;\n this.persist(key, value);\n write(value);\n };\n sig.update = fn => sig.set(fn(untracked(sig)));\n\n const entry: Watcher = { sig, fallback, write };\n this.watchers.set(key, entry);\n this.installCrossTabListener();\n return entry;\n }\n\n /** Serialize and store. `false` when nothing landed in the engine. */\n private persist<T>(key: string, value: T, opts?: { ttl?: number }): boolean {\n const fk = this.fullKey(key);\n let serialized: string;\n\n if (this.config.json) {\n const ttl = opts?.ttl ?? this.config.ttl;\n const env: WrStorageEnvelope<T> = ttl ? { v: value, e: Date.now() + ttl } : { v: value };\n try {\n serialized = JSON.stringify(env);\n } catch (err) {\n // eslint-disable-next-line no-console -- intentional diagnostic for unserialisable values\n console.warn('[ngwr/storage] value not JSON-serializable', err);\n return false;\n }\n } else {\n serialized = String(value);\n }\n\n try {\n this.engine.setItem(fk, serialized);\n } catch (err) {\n // Quota exceeded / disabled / cleared mid-write — log + carry on.\n // eslint-disable-next-line no-console -- intentional diagnostic on storage write failure\n console.warn('[ngwr/storage] setItem failed', err);\n return false;\n }\n return true;\n }\n\n private notify(key: string): void {\n const entry = this.watchers.get(key);\n if (entry) entry.write(this.get(key, entry.fallback));\n }\n\n private refreshAll(): void {\n for (const [k, entry] of this.watchers) entry.write(this.get(k, entry.fallback));\n }\n\n private rawKeys(): string[] {\n const p = this.config.prefix;\n const out: string[] = [];\n for (let i = 0; i < this.engine.length; i++) {\n const k = this.engine.key(i);\n if (k === null) continue;\n if (!p || k.startsWith(p)) out.push(k);\n }\n return out;\n }\n\n private installCrossTabListener(): void {\n if (!this.isBrowser || this.listenerInstalled) return;\n this.listenerInstalled = true;\n\n const handler = (event: StorageEvent): void => {\n // `storage` only fires for `localStorage` / `sessionStorage`, and\n // only for changes from OTHER tabs. Local writes are handled by\n // `notify()` in `set`/`remove`/`clear`.\n if (event.key === null) {\n // Storage cleared from another tab.\n this.refreshAll();\n return;\n }\n const p = this.config.prefix;\n if (p && !event.key.startsWith(p)) return;\n this.notify(p ? event.key.slice(p.length) : event.key);\n };\n\n window.addEventListener('storage', handler);\n\n // The listener belongs to THIS injector. Root-provided it lives as long as\n // the page, but a route or component that lists `WrStorage` in its own\n // `providers` used to leave the handler on the window after its injector was\n // gone — still driving the watcher signals of a destroyed instance, and\n // holding the instance and every signal in it reachable for the life of the\n // page. Same bug `WrHotkey` already fixed once.\n this.destroyRef.onDestroy(() => {\n window.removeEventListener('storage', handler);\n this.listenerInstalled = false;\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { Provider } from '@angular/core';\n\nimport { type WrFeature, wrFeature } from 'ngwr/utils';\n\nimport { DEFAULT_WR_STORAGE_CONFIG, WR_STORAGE_CONFIG, type WrStorageConfigResolved } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\nimport type { WrStorageOptions } from './types';\n\n/**\n * Configure {@link WrStorage}, as a feature of `provideWr()`. All fields\n * optional — merged with defaults.\n *\n * Bootstrap only: {@link WrStorage} is root-provided and resolves its engine\n * and config once, from the root injector — see {@link WR_STORAGE_ENGINE}.\n *\n * @example Override the engine globally (e.g. session storage)\n * ```ts\n * import { provideWr } from 'ngwr';\n * import { withStorage } from 'ngwr/storage';\n *\n * providers: [provideWr(withStorage({ engine: sessionStorage }))]\n * ```\n *\n * @example Lazy engine factory (e.g. wrap localStorage with encryption)\n * ```ts\n * provideWr(withStorage({ engine: () => new EncryptedStorage(localStorage, key) }))\n * ```\n *\n * @example Namespace + auto-expire\n * ```ts\n * provideWr(withStorage({ prefix: 'myapp:', ttl: 24 * 60 * 60 * 1000 }))\n * ```\n */\nexport function withStorage(options: WrStorageOptions = {}): WrFeature<'storage'> {\n const { engine, ...config } = options;\n\n const merged: WrStorageConfigResolved = { ...DEFAULT_WR_STORAGE_CONFIG, ...config };\n\n const providers: Provider[] = [{ provide: WR_STORAGE_CONFIG, useValue: merged }];\n\n if (engine !== undefined) {\n providers.push(\n typeof engine === 'function'\n ? { provide: WR_STORAGE_ENGINE, useFactory: engine }\n : { provide: WR_STORAGE_ENGINE, useValue: engine }\n );\n }\n\n return wrFeature('storage', providers);\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAa,4BAAqD;CAChE,QAAQ;CACR,MAAM;CACN,KAAK;AACN;AAED,MAAa,oBAAoB,IAAI,eAAwC,qBAAqB;CAChG,YAAY;CACZ,eAAe;AAChB,CAAA;;;;;;;ACJD,SAAS,MAAM,QAAuB;CACpC,IAAI;EACF,MAAM,IAAI;EACV,OAAO,QAAQ,GAAG,GAAG;EACrB,OAAO,WAAW,CAAC;EACnB,OAAO;CACT,QAAQ;EACN,OAAO;C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IxD,OAAO,UAAU,WAAW,SAAS;AACvC"}
|
|
1
|
+
{"version":3,"file":"ngwr-storage.mjs","names":[],"sources":["../../../projects/lib/storage/storage-config.ts","../../../projects/lib/storage/storage-engine.ts","../../../projects/lib/storage/storage.ts","../../../projects/lib/storage/with-storage.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageConfigResolved } from './types';\n\nexport const DEFAULT_WR_STORAGE_CONFIG: WrStorageConfigResolved = {\n prefix: '',\n json: true,\n ttl: 0,\n};\n\nexport const WR_STORAGE_CONFIG = new InjectionToken<WrStorageConfigResolved>('WR_STORAGE_CONFIG', {\n providedIn: 'root',\n factory: () => DEFAULT_WR_STORAGE_CONFIG,\n});\n\nexport type { WrStorageConfig, WrStorageConfigResolved } from './types';\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 { InjectionToken } from '@angular/core';\n\nimport type { WrStorageEngine } from './types';\n\n/**\n * Probe a `Storage` candidate to confirm it's writable. Safari private\n * mode, disabled cookies, and storage-blocked iframes all throw on\n * `setItem` — fall back to memory in those cases.\n */\nfunction probe(engine: WrStorageEngine): boolean {\n try {\n const k = '__wr_storage_probe__';\n engine.setItem(k, '1');\n engine.removeItem(k);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * In-memory implementation of `Storage`. Used as the SSR / private-mode\n * fallback. Exported so consumers can opt into it explicitly for tests.\n */\nexport function wrCreateMemoryStorage(): WrStorageEngine {\n const map = new Map<string, string>();\n return {\n get length(): number {\n return map.size;\n },\n clear(): void {\n map.clear();\n },\n getItem(key: string): string | null {\n return map.has(key) ? map.get(key)! : null;\n },\n key(i: number): string | null {\n return Array.from(map.keys())[i] ?? null;\n },\n removeItem(key: string): void {\n map.delete(key);\n },\n setItem(key: string, value: string): void {\n map.set(key, value);\n },\n };\n}\n\n/**\n * Injection token for the active storage engine. Provide it at BOOTSTRAP to\n * swap engines (e.g. `sessionStorage` for a tab-only app):\n *\n * ```ts\n * providers: [{ provide: WR_STORAGE_ENGINE, useValue: sessionStorage }]\n * ```\n *\n * Not at an arbitrary injector level: `WrStorage` is root-provided and reads\n * the token in a field initializer, so the singleton resolves its engine once\n * and a token re-provided on a lazy route or in a component's `providers`\n * reaches no existing `inject(WrStorage)` — every read and write still goes to\n * the engine the root instance already took, with nothing thrown and nothing\n * logged. A feature that genuinely needs its own engine provides its own\n * `WrStorage` beside it.\n *\n * The default factory returns `localStorage` in the browser when it's\n * actually writable, an in-memory map otherwise.\n */\nexport const WR_STORAGE_ENGINE = new InjectionToken<WrStorageEngine>('WR_STORAGE_ENGINE', {\n providedIn: 'root',\n factory: () => {\n try {\n // The getter itself throws a SecurityError when the browser blocks storage.\n if (typeof localStorage !== 'undefined' && probe(localStorage)) return localStorage;\n } catch {\n // Fall through to memory.\n }\n return wrCreateMemoryStorage();\n },\n});\n\nexport type { WrStorageEngine } from './types';\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 { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Service,\n PLATFORM_ID,\n type Signal,\n type WritableSignal,\n inject,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WR_STORAGE_CONFIG } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\nimport type { WrStorageEnvelope } from './types';\n\nfunction isEnvelope(x: unknown): x is WrStorageEnvelope {\n return x !== null && typeof x === 'object' && 'v' in x;\n}\n\n/**\n * One key's signal. `sig.set` persists, so a refresh from storage goes through\n * `write`, the setter the signal was born with.\n */\ninterface Watcher {\n readonly sig: WritableSignal<unknown>;\n readonly fallback: unknown;\n readonly write: (value: unknown) => void;\n}\n\n/**\n * Reactive key/value storage on top of any `Storage`-compatible engine.\n *\n * - **Swap engines** through {@link WR_STORAGE_ENGINE} or\n * `provideWr(withStorage(...))`. Default: `localStorage` with an in-memory\n * fallback for SSR / private mode.\n * - **Namespacing** via `prefix` (config) — every key is transparently\n * prefixed on read / write.\n * - **TTL** per-call or default — values past their expiry are removed\n * lazily on the next `get` / `watch` read.\n * - **Reactive watch** — `watch(key)` returns a `Signal` that updates on\n * local writes and cross-tab `storage` events. `signal(key, default)` is the\n * writable twin: `set` and `update` persist as they go.\n * - **On-disk format** — values are wrapped in a {@link WrStorageEnvelope}\n * (`{\"v\":…,\"e\":…}`) while `json` is on. Anything reading the same key from\n * outside Angular has to unwrap it.\n *\n * SSR-safe: the default engine factory returns an in-memory shim when\n * `localStorage` is unavailable, so reads always work.\n *\n * @example\n * ```ts\n * const store = inject(WrStorage);\n *\n * store.set('user', { name: 'Ada' });\n * store.get<{ name: string }>('user'); // { name: 'Ada' }\n *\n * store.set('cart', items, { ttl: 60_000 }); // expires in 60s\n *\n * const theme = store.watch<'light' | 'dark'>('theme', 'light');\n * effect(() => console.log('theme is', theme()));\n *\n * const density = store.signal<'compact' | 'comfortable'>('density', 'comfortable');\n * density.set('compact'); // stored, and every tab follows\n * ```\n *\n * @see https://ngwr.dev/reference/services/storage\n */\n@Service()\nexport class WrStorage {\n private readonly engine = inject(WR_STORAGE_ENGINE);\n private readonly config = inject(WR_STORAGE_CONFIG);\n private readonly destroyRef = inject(DestroyRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /**\n * Per-key watchers. Shared so multiple `watch(k)` and `signal(k)` calls reuse\n * one signal.\n *\n * The fallback is kept alongside the signal because every refresh has to read\n * the key the same way `watch` first did. Refreshing without it made `get` and\n * `watch` disagree about what an ABSENT key means: after a `remove()` the\n * signal went to `null` while `get(key, fallback)` still answered with the\n * default, so a consumer watching `'theme'` with a `'light'` fallback got no\n * theme at all rather than the light one.\n */\n private readonly watchers = new Map<string, Watcher>();\n private listenerInstalled = false;\n\n // Public API\n\n /**\n * Is `key` present? A raw presence check: it does not parse the envelope, so\n * an EXPIRED entry still answers `true` until something reads it — `get()`\n * is what notices the TTL and removes the key on its way out. Branch on\n * `get() !== null` when the answer has to respect expiry; this one is for\n * \"is there anything under this key at all\", quota accounting included.\n */\n has(key: string): boolean {\n return this.engine.getItem(this.fullKey(key)) !== null;\n }\n\n /**\n * Read `key`. Returns `fallback` (default `null`) when the key is\n * missing or expired. Expired values are also removed as a side effect.\n */\n get<T = unknown>(key: string, fallback: T | null = null): T | null {\n const fk = this.fullKey(key);\n const raw = this.engine.getItem(fk);\n if (raw === null) return fallback;\n\n if (!this.config.json) return raw as unknown as T;\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // Non-JSON value written by external code — return as-is.\n return raw as unknown as T;\n }\n\n if (!isEnvelope(parsed)) return parsed as T;\n\n if (parsed.e !== undefined && parsed.e < Date.now()) {\n // Watchers are written untracked: a read inside a computed or template must not write signals.\n untracked(() => this.remove(key));\n return fallback;\n }\n return parsed.v as T;\n }\n\n /**\n * Write `value` at `key`. Per-call `ttl` (ms) overrides the config\n * default. JSON-serializable values only when `json` is on (the default).\n *\n * What lands in the engine is a {@link WrStorageEnvelope} —\n * `{\"v\":<value>}`, plus `\"e\"` when a TTL applies — not the bare value. Code\n * outside Angular that reads the same key has to unwrap it; see the envelope's\n * own docs for the exact format.\n */\n set<T = unknown>(key: string, value: T, opts?: { ttl?: number }): void {\n if (this.persist(key, value, opts)) this.notify(key);\n }\n\n /** Remove `key`. No-op when absent. */\n remove(key: string): void {\n this.engine.removeItem(this.fullKey(key));\n this.notify(key);\n }\n\n /**\n * Clear every key owned by this prefix. When `prefix` is empty this\n * defers to `engine.clear()` (clears everything — be careful with\n * shared storage).\n */\n clear(): void {\n const p = this.config.prefix;\n if (p) {\n for (const fk of this.rawKeys()) this.engine.removeItem(fk);\n } else {\n this.engine.clear();\n }\n // Refresh every active watcher — they may have just been cleared.\n this.refreshAll();\n }\n\n /** All known keys under our prefix, with the prefix stripped. */\n keys(): readonly string[] {\n const p = this.config.prefix;\n return this.rawKeys().map(k => (p ? k.slice(p.length) : k));\n }\n\n /**\n * Reactive read of `key`. Updates when this instance writes to the key,\n * when `clear()` runs, and when another tab updates `localStorage`\n * under the same prefix. Returned signal is shared per key — calling\n * `watch(k)` twice returns the same signal.\n */\n watch<T = unknown>(key: string, fallback: T | null = null): Signal<T | null> {\n return (this.watcher(key, fallback).sig as WritableSignal<T | null>).asReadonly();\n }\n\n /**\n * Writable twin of {@link watch}: `set` and `update` store the value, then\n * the signal takes it. The signal is the one `watch(key)` reads, so a\n * `set()`, `remove()` or `clear()` on this instance moves it too, and so does\n * a write from another tab; a key another tab removes goes back to\n * `defaultValue`. Shared per key, so a second `signal(key)` is the same\n * signal and the first call's default stands.\n *\n * A `set` to the value it already holds (`Object.is`) writes nothing, like a\n * plain signal. A write the engine refuses (quota, storage disabled) is\n * logged and dropped exactly as `set()` does, and nothing throws: the signal\n * keeps the new value for this tab, and the next load reads what was stored\n * before.\n *\n * On the server it reads the engine as `watch()` does, so with the default\n * in-memory engine it holds `defaultValue`, and no `storage` listener is\n * installed. Hydration: the server renders that default and the browser\n * instance reads `localStorage` when it is created, so the first client\n * render can differ from the server markup, as with `watch()`.\n */\n signal<T>(key: string, defaultValue: T): WritableSignal<T> {\n return this.watcher(key, defaultValue).sig as WritableSignal<T>;\n }\n\n // Internals\n\n private fullKey(key: string): string {\n return this.config.prefix + key;\n }\n\n private watcher(key: string, fallback: unknown): Watcher {\n const existing = this.watchers.get(key);\n if (existing) return existing;\n\n const sig = signal<unknown>(this.get(key, fallback));\n const write = sig.set.bind(sig);\n sig.set = value => {\n if (Object.is(value, untracked(sig))) return;\n this.persist(key, value);\n write(value);\n };\n sig.update = fn => sig.set(fn(untracked(sig)));\n\n const entry: Watcher = { sig, fallback, write };\n this.watchers.set(key, entry);\n this.installCrossTabListener();\n return entry;\n }\n\n /** Serialize and store. `false` when nothing landed in the engine. */\n private persist<T>(key: string, value: T, opts?: { ttl?: number }): boolean {\n const fk = this.fullKey(key);\n let serialized: string;\n\n if (this.config.json) {\n const ttl = opts?.ttl ?? this.config.ttl;\n const env: WrStorageEnvelope<T> = ttl ? { v: value, e: Date.now() + ttl } : { v: value };\n try {\n serialized = JSON.stringify(env);\n } catch (err) {\n // eslint-disable-next-line no-console -- intentional diagnostic for unserialisable values\n console.warn('[ngwr/storage] value not JSON-serializable', err);\n return false;\n }\n } else {\n serialized = String(value);\n }\n\n try {\n this.engine.setItem(fk, serialized);\n } catch (err) {\n // Quota exceeded / disabled / cleared mid-write — log + carry on.\n // eslint-disable-next-line no-console -- intentional diagnostic on storage write failure\n console.warn('[ngwr/storage] setItem failed', err);\n return false;\n }\n return true;\n }\n\n private notify(key: string): void {\n const entry = this.watchers.get(key);\n if (entry) entry.write(this.get(key, entry.fallback));\n }\n\n private refreshAll(): void {\n for (const [k, entry] of this.watchers) entry.write(this.get(k, entry.fallback));\n }\n\n private rawKeys(): string[] {\n const p = this.config.prefix;\n const out: string[] = [];\n for (let i = 0; i < this.engine.length; i++) {\n const k = this.engine.key(i);\n if (k === null) continue;\n if (!p || k.startsWith(p)) out.push(k);\n }\n return out;\n }\n\n private installCrossTabListener(): void {\n if (!this.isBrowser || this.listenerInstalled) return;\n this.listenerInstalled = true;\n\n const handler = (event: StorageEvent): void => {\n // `storage` only fires for `localStorage` / `sessionStorage`, and\n // only for changes from OTHER tabs. Local writes are handled by\n // `notify()` in `set`/`remove`/`clear`.\n if (event.key === null) {\n // Storage cleared from another tab.\n this.refreshAll();\n return;\n }\n const p = this.config.prefix;\n if (p && !event.key.startsWith(p)) return;\n this.notify(p ? event.key.slice(p.length) : event.key);\n };\n\n window.addEventListener('storage', handler);\n\n // The listener belongs to THIS injector. Root-provided it lives as long as\n // the page, but a route or component that lists `WrStorage` in its own\n // `providers` used to leave the handler on the window after its injector was\n // gone — still driving the watcher signals of a destroyed instance, and\n // holding the instance and every signal in it reachable for the life of the\n // page. Same bug `WrHotkey` already fixed once.\n this.destroyRef.onDestroy(() => {\n window.removeEventListener('storage', handler);\n this.listenerInstalled = false;\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { Provider } from '@angular/core';\n\nimport { type WrFeature, wrFeature } from 'ngwr/utils';\n\nimport { DEFAULT_WR_STORAGE_CONFIG, WR_STORAGE_CONFIG, type WrStorageConfigResolved } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\nimport type { WrStorageOptions } from './types';\n\n/**\n * Configure {@link WrStorage}, as a feature of `provideWr()`. All fields\n * optional — merged with defaults.\n *\n * Bootstrap only: {@link WrStorage} is root-provided and resolves its engine\n * and config once, from the root injector — see {@link WR_STORAGE_ENGINE}.\n *\n * @example Override the engine globally (e.g. session storage)\n * ```ts\n * import { provideWr } from 'ngwr';\n * import { withStorage } from 'ngwr/storage';\n *\n * providers: [provideWr(withStorage({ engine: sessionStorage }))]\n * ```\n *\n * @example Lazy engine factory (e.g. wrap localStorage with encryption)\n * ```ts\n * provideWr(withStorage({ engine: () => new EncryptedStorage(localStorage, key) }))\n * ```\n *\n * @example Namespace + auto-expire\n * ```ts\n * provideWr(withStorage({ prefix: 'myapp:', ttl: 24 * 60 * 60 * 1000 }))\n * ```\n */\nexport function withStorage(options: WrStorageOptions = {}): WrFeature<'storage'> {\n const { engine, ...config } = options;\n\n const merged: WrStorageConfigResolved = { ...DEFAULT_WR_STORAGE_CONFIG, ...config };\n\n const providers: Provider[] = [{ provide: WR_STORAGE_CONFIG, useValue: merged }];\n\n if (engine !== undefined) {\n providers.push(\n typeof engine === 'function'\n ? { provide: WR_STORAGE_ENGINE, useFactory: engine }\n : { provide: WR_STORAGE_ENGINE, useValue: engine }\n );\n }\n\n return wrFeature('storage', providers);\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAa,4BAAqD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AAE;CACxD,MAAM,EAAE,QAAQ,GAAG,WAAW;CAE9B,MAAM,SAAkC;EAAE,GAAG;EAA2B,GAAG;CAAM;CAEjF,MAAM,YAAwB,CAAC;EAAE,SAAS;EAAmB,UAAU;CAAM,CAAE;CAE/E,IAAI,WAAW,QACb,UAAU,KACR,OAAO,WAAW,aACd;EAAE,SAAS;EAAmB,YAAY;CAAM,IAChD;EAAE,SAAS;EAAmB,UAAU;CAAM,CAAE;CAIxD,OAAO,UAAU,WAAW,SAAS;AACvC"}
|
package/fesm2022/ngwr-switch.mjs
CHANGED
|
@@ -55,7 +55,7 @@ var WrSwitch = class WrSwitch {
|
|
|
55
55
|
}
|
|
56
56
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
57
57
|
minVersion: "12.0.0",
|
|
58
|
-
version: "22.
|
|
58
|
+
version: "22.3.0",
|
|
59
59
|
ngImport: i0,
|
|
60
60
|
type: WrSwitch,
|
|
61
61
|
deps: [],
|
|
@@ -63,7 +63,7 @@ var WrSwitch = class WrSwitch {
|
|
|
63
63
|
});
|
|
64
64
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
65
65
|
minVersion: "17.2.0",
|
|
66
|
-
version: "22.
|
|
66
|
+
version: "22.3.0",
|
|
67
67
|
type: WrSwitch,
|
|
68
68
|
isStandalone: true,
|
|
69
69
|
selector: "wr-switch",
|
|
@@ -130,13 +130,13 @@ var WrSwitch = class WrSwitch {
|
|
|
130
130
|
isSignal: true
|
|
131
131
|
}],
|
|
132
132
|
ngImport: i0,
|
|
133
|
-
template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n",
|
|
133
|
+
template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-required]=\"fieldAria.ariaRequired()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n",
|
|
134
134
|
encapsulation: i0.ViewEncapsulation.None
|
|
135
135
|
});
|
|
136
136
|
};
|
|
137
137
|
i0.ɵɵngDeclareClassMetadata({
|
|
138
138
|
minVersion: "12.0.0",
|
|
139
|
-
version: "22.
|
|
139
|
+
version: "22.3.0",
|
|
140
140
|
ngImport: i0,
|
|
141
141
|
type: WrSwitch,
|
|
142
142
|
decorators: [{
|
|
@@ -149,7 +149,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
149
149
|
"[class]": "classes()",
|
|
150
150
|
"[attr.id]": "null"
|
|
151
151
|
},
|
|
152
|
-
template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n"
|
|
152
|
+
template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-required]=\"fieldAria.ariaRequired()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n"
|
|
153
153
|
}]
|
|
154
154
|
}],
|
|
155
155
|
ctorParameters: () => [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-switch.mjs","names":[],"sources":["../../../projects/lib/switch/switch.ts","../../../projects/lib/switch/switch.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 {\n Component,\n type ElementRef,\n ViewEncapsulation,\n computed,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\nimport type { FormCheckboxControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Boolean toggle with an iOS-style slider.\n *\n * A signal-forms native control: it implements `FormCheckboxControl`, so\n * `[formField]` binds straight to its `checked` model — no\n * `ControlValueAccessor` in between. `[(checked)]` works standalone.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-switch [formField]=\"form.notifications\">Notifications</wr-switch>\n *\n * <!-- standalone two-way binding -->\n * <wr-switch [(checked)]=\"enabled\">Notifications</wr-switch>\n * ```\n *\n * @see https://ngwr.dev/reference/components/switch\n */\nexport type WrSwitchSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-switch',\n templateUrl: './switch.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-switch',\n '[class]': 'classes()',\n // The `id` input belongs to the native input, not to this element — a static\n // `id=\"x\"` would otherwise be written here too and leave the document with\n // two elements sharing it, which is what broke `<label for>`.\n '[attr.id]': 'null',\n },\n})\nexport class WrSwitch implements FormCheckboxControl {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('switch');\n }\n\n /**\n * Accessible name for a switch used WITHOUT projected text. The wrapping\n * `<label>` names the control whenever content is projected; with none, the\n * label is empty and the input has no name at all.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /**\n * Stable id used to associate the native input with its label. Lands on the\n * inner `<input>`; the host never keeps it.\n */\n readonly id = input<string>(wrRandomId('wr-switch'));\n\n /**\n * Disable the switch. 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 staying focusable and submittable. Bound automatically\n * from the field's readonly state when used with `[formField]`.\n *\n * A native checkbox ignores the `readonly` attribute, so this cancels the\n * click's activation behaviour instead — which covers Space too, since the key\n * arrives as a click — and mirrors the state as `aria-readonly`, which role\n * `switch` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrSwitchSize>('md');\n\n /** On / off state. Bound by `[formField]`, or two-way via `[(checked)]`. */\n readonly checked = model<boolean>(false);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n private readonly native = viewChild.required<ElementRef<HTMLInputElement>>('native');\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-switch--${size}`);\n if (this.checked()) parts.push('wr-switch--checked');\n if (this.disabled()) parts.push('wr-switch--disabled');\n else if (this.readonly()) parts.push('wr-switch--readonly');\n return parts.join(' ');\n });\n\n /**\n * Focus the switch — what Signal Forms calls to focus this control. The native\n * input takes it, since the host has no tab stop of its own; a disabled switch\n * refuses, as a disabled input always does.\n */\n focus(options?: FocusOptions): void {\n this.native().nativeElement.focus(options);\n }\n\n // Template handlers\n\n /**\n * Cancel the toggle while readonly. `change` never fires for a click whose\n * default was prevented, so this is the only guard the pointer and Space paths\n * need; `onInputChange` keeps its own for a synthetic `change`.\n */\n protected onInputClick(event: Event): void {\n if (this.readonly()) event.preventDefault();\n }\n\n protected onInputChange(event: Event): void {\n if (this.readonly()) {\n // A synthetic `change` cannot be prevented — put the DOM back instead.\n (event.target as HTMLInputElement).checked = this.checked();\n return;\n }\n this.checked.set((event.target as HTMLInputElement).checked);\n }\n\n protected onInputBlur(): void {\n this.touch.emit();\n }\n}\n","<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n"],"mappings":";;;;;;;;;;;AAwDA,IAAa,WAAb,MAAa,SAAQ;CACnB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,QAAQ;CAC3E;CAOS,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAMtC,KAAK,MAAc,WAAW,WAAW,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAQ3C,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAa1D,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAGhD,YAAY,iBAAgB;CAGtC,OAAO,MAAoB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAGhC,UAAU,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAG/B,QAAQ,OAAM;CAEN,SAAS,UAAU,SAAuC,UAAS,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAEjE,UAAU,eAAc;EACzC,MAAM,QAAkB,CAAA;EACxB,MAAM,OAAO,KAAK,KAAI;EACtB,IAAI,SAAS,MAAM,MAAM,KAAK,cAAc,MAAM;EAClD,IAAI,KAAK,QAAO,GAAI,MAAM,KAAK,oBAAoB;EACnD,IAAI,KAAK,SAAQ,GAAI,MAAM,KAAK,qBAAqB;OAChD,IAAI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A;GAAA,OAAA;EAAA;EAAA,MAAA;GAAA,YAAA;IAAA,SAAA;IAAA,WAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,aAAA,CAAA;GAAA,cAAA;GAAA,OAAA;GAAA,WAAA,CAAA,QAAA;GAAA,aAAA;GAAA,UAAA;EAAA,CAAA;EAAA,UAAA;EAAA,UCxDrB;
|
|
1
|
+
{"version":3,"file":"ngwr-switch.mjs","names":[],"sources":["../../../projects/lib/switch/switch.ts","../../../projects/lib/switch/switch.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 {\n Component,\n type ElementRef,\n ViewEncapsulation,\n computed,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\nimport type { FormCheckboxControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Boolean toggle with an iOS-style slider.\n *\n * A signal-forms native control: it implements `FormCheckboxControl`, so\n * `[formField]` binds straight to its `checked` model — no\n * `ControlValueAccessor` in between. `[(checked)]` works standalone.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-switch [formField]=\"form.notifications\">Notifications</wr-switch>\n *\n * <!-- standalone two-way binding -->\n * <wr-switch [(checked)]=\"enabled\">Notifications</wr-switch>\n * ```\n *\n * @see https://ngwr.dev/reference/components/switch\n */\nexport type WrSwitchSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-switch',\n templateUrl: './switch.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-switch',\n '[class]': 'classes()',\n // The `id` input belongs to the native input, not to this element — a static\n // `id=\"x\"` would otherwise be written here too and leave the document with\n // two elements sharing it, which is what broke `<label for>`.\n '[attr.id]': 'null',\n },\n})\nexport class WrSwitch implements FormCheckboxControl {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('switch');\n }\n\n /**\n * Accessible name for a switch used WITHOUT projected text. The wrapping\n * `<label>` names the control whenever content is projected; with none, the\n * label is empty and the input has no name at all.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /**\n * Stable id used to associate the native input with its label. Lands on the\n * inner `<input>`; the host never keeps it.\n */\n readonly id = input<string>(wrRandomId('wr-switch'));\n\n /**\n * Disable the switch. 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 staying focusable and submittable. Bound automatically\n * from the field's readonly state when used with `[formField]`.\n *\n * A native checkbox ignores the `readonly` attribute, so this cancels the\n * click's activation behaviour instead — which covers Space too, since the key\n * arrives as a click — and mirrors the state as `aria-readonly`, which role\n * `switch` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrSwitchSize>('md');\n\n /** On / off state. Bound by `[formField]`, or two-way via `[(checked)]`. */\n readonly checked = model<boolean>(false);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n private readonly native = viewChild.required<ElementRef<HTMLInputElement>>('native');\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-switch--${size}`);\n if (this.checked()) parts.push('wr-switch--checked');\n if (this.disabled()) parts.push('wr-switch--disabled');\n else if (this.readonly()) parts.push('wr-switch--readonly');\n return parts.join(' ');\n });\n\n /**\n * Focus the switch — what Signal Forms calls to focus this control. The native\n * input takes it, since the host has no tab stop of its own; a disabled switch\n * refuses, as a disabled input always does.\n */\n focus(options?: FocusOptions): void {\n this.native().nativeElement.focus(options);\n }\n\n // Template handlers\n\n /**\n * Cancel the toggle while readonly. `change` never fires for a click whose\n * default was prevented, so this is the only guard the pointer and Space paths\n * need; `onInputChange` keeps its own for a synthetic `change`.\n */\n protected onInputClick(event: Event): void {\n if (this.readonly()) event.preventDefault();\n }\n\n protected onInputChange(event: Event): void {\n if (this.readonly()) {\n // A synthetic `change` cannot be prevented — put the DOM back instead.\n (event.target as HTMLInputElement).checked = this.checked();\n return;\n }\n this.checked.set((event.target as HTMLInputElement).checked);\n }\n\n protected onInputBlur(): void {\n this.touch.emit();\n }\n}\n","<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-required]=\"fieldAria.ariaRequired()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n"],"mappings":";;;;;;;;;;;AAwDA,IAAa,WAAb,MAAa,SAAQ;CACnB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,QAAQ;CAC3E;CAOS,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAMtC,KAAK,MAAc,WAAW,WAAW,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAQ3C,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAa1D,WAAW,MAAM,O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A,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,IAAA,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,MAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,eAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,UAAQ,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Directive, forwardRef, inject } from "@angular/core";
|
|
3
|
+
import { LocationStrategy } from "@angular/common";
|
|
4
|
+
import { ActivatedRoute, NavigationEnd, Router } from "@angular/router";
|
|
5
|
+
import { toSignal } from "@angular/core/rxjs-interop";
|
|
6
|
+
import { filter, map, startWith } from "rxjs";
|
|
7
|
+
import { WR_TABLE_ROUTING } from "ngwr/table";
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
*
|
|
11
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
12
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
13
|
+
*/
|
|
14
|
+
var WrTableRouting = class WrTableRouting {
|
|
15
|
+
router = inject(Router);
|
|
16
|
+
locationStrategy = inject(LocationStrategy);
|
|
17
|
+
route = inject(ActivatedRoute);
|
|
18
|
+
url = toSignal(this.router.events.pipe(filter((e) => e instanceof NavigationEnd), map((e) => e.urlAfterRedirects), startWith(this.router.url)), { initialValue: this.router.url });
|
|
19
|
+
href(link) {
|
|
20
|
+
this.url();
|
|
21
|
+
return this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.tree(link)));
|
|
22
|
+
}
|
|
23
|
+
navigate(link, event) {
|
|
24
|
+
if (event.button !== 0 || event.ctrlKey || event.shiftKey || event.altKey || event.metaKey) return;
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
this.router.navigateByUrl(this.tree(link));
|
|
27
|
+
}
|
|
28
|
+
tree(link) {
|
|
29
|
+
if (typeof link === "string" && link.startsWith("/")) return this.router.parseUrl(link);
|
|
30
|
+
if (typeof link !== "string") return this.router.createUrlTree([...link], { relativeTo: this.route });
|
|
31
|
+
const cut = link.search(/[?#]/);
|
|
32
|
+
const path = cut >= 0 ? link.slice(0, cut) : link;
|
|
33
|
+
const rest = cut >= 0 ? this.router.parseUrl(`/${link.slice(cut)}`) : null;
|
|
34
|
+
const queryParams = rest && Object.keys(rest.queryParams).length > 0 ? rest.queryParams : void 0;
|
|
35
|
+
return this.router.createUrlTree([path], {
|
|
36
|
+
relativeTo: this.route,
|
|
37
|
+
queryParams,
|
|
38
|
+
fragment: rest?.fragment ?? void 0,
|
|
39
|
+
queryParamsHandling: queryParams ? "replace" : void 0
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
43
|
+
minVersion: "12.0.0",
|
|
44
|
+
version: "22.3.0",
|
|
45
|
+
ngImport: i0,
|
|
46
|
+
type: WrTableRouting,
|
|
47
|
+
deps: [],
|
|
48
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
49
|
+
});
|
|
50
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
51
|
+
minVersion: "14.0.0",
|
|
52
|
+
version: "22.3.0",
|
|
53
|
+
type: WrTableRouting,
|
|
54
|
+
isStandalone: true,
|
|
55
|
+
selector: "[wrTableRouting]",
|
|
56
|
+
providers: [{
|
|
57
|
+
provide: WR_TABLE_ROUTING,
|
|
58
|
+
useExisting: forwardRef(() => WrTableRouting)
|
|
59
|
+
}],
|
|
60
|
+
exportAs: ["wrTableRouting"],
|
|
61
|
+
ngImport: i0
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
65
|
+
minVersion: "12.0.0",
|
|
66
|
+
version: "22.3.0",
|
|
67
|
+
ngImport: i0,
|
|
68
|
+
type: WrTableRouting,
|
|
69
|
+
decorators: [{
|
|
70
|
+
type: Directive,
|
|
71
|
+
args: [{
|
|
72
|
+
selector: "[wrTableRouting]",
|
|
73
|
+
exportAs: "wrTableRouting",
|
|
74
|
+
providers: [{
|
|
75
|
+
provide: WR_TABLE_ROUTING,
|
|
76
|
+
useExisting: forwardRef(() => WrTableRouting)
|
|
77
|
+
}]
|
|
78
|
+
}]
|
|
79
|
+
}]
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* @license
|
|
83
|
+
*
|
|
84
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
85
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
86
|
+
*/
|
|
87
|
+
export { WrTableRouting };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=ngwr-table-router.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngwr-table-router.mjs","names":[],"sources":["../../../projects/lib/table/router/table-routing.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 { LocationStrategy } from '@angular/common';\nimport { Directive, forwardRef, inject } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, NavigationEnd, Router, type UrlTree } from '@angular/router';\n\nimport { filter, map, startWith } from 'rxjs';\n\nimport { WR_TABLE_ROUTING, type WrTableRoutingAdapter } from 'ngwr/table';\n\n/**\n * Router support for the row links of `<wr-table>`. Add it to the `imports` of\n * the component that declares the table, and `wrTableRouting` to the table:\n *\n * @example\n * ```ts\n * import { WrTable } from 'ngwr/table';\n * import { WrTableRouting } from 'ngwr/table/router';\n *\n * @Component({ imports: [WrTable, WrTableRouting], template: `\n * <wr-table wrTableRouting [columns]=\"columns\" [items]=\"orders\" [rowLink]=\"orderLink\" />\n * ` })\n * export class OrdersPage {\n * protected readonly orderLink = (order: Order) => ['/orders', order.id];\n * }\n * ```\n *\n * `rowLink` then returns what `routerLink` takes: a URL string or an array of\n * commands, relative to the route of the component that declares the table\n * unless it starts with `/`. A plain click navigates in the app; a middle\n * click or a click with a modifier stays the browser's, on a real href. A\n * string with a scheme or a host of its own (`https://…`, `mailto:…`, `//…`)\n * stays a plain link.\n *\n * A separate entry point, so a table that links nowhere does not carry\n * `@angular/router`; a directive rather than a provider function, so a\n * relative link resolves against the declaring component's route. Both for\n * the reasons `WrTabsRouting` gives.\n */\n@Directive({\n selector: '[wrTableRouting]',\n exportAs: 'wrTableRouting',\n providers: [\n {\n provide: WR_TABLE_ROUTING,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrTableRouting),\n },\n ],\n})\nexport class WrTableRouting implements WrTableRoutingAdapter {\n private readonly router = inject(Router);\n private readonly locationStrategy = inject(LocationStrategy);\n private readonly route = inject(ActivatedRoute);\n\n /** The current URL as a signal: a relative link's target moves when the route does. */\n private readonly url = toSignal(\n this.router.events.pipe(\n filter((e): e is NavigationEnd => e instanceof NavigationEnd),\n map(e => e.urlAfterRedirects),\n startWith(this.router.url)\n ),\n { initialValue: this.router.url }\n );\n\n href(link: string | readonly unknown[]): string {\n // Read for the dependency, so the table's links recompute on navigation.\n this.url();\n // `prepareExternalUrl`, as `RouterLink` writes it: the href is what a middle\n // click and \"copy link\" use, under a hash location or a base href too.\n return this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.tree(link)));\n }\n\n navigate(link: string | readonly unknown[], event: MouseEvent): void {\n // The guard `RouterLink` applies: a middle click or a modified one belongs\n // to the browser.\n if (event.button !== 0 || event.ctrlKey || event.shiftKey || event.altKey || event.metaKey) return;\n event.preventDefault();\n void this.router.navigateByUrl(this.tree(link));\n }\n\n private tree(link: string | readonly unknown[]): UrlTree {\n // A string is a URL, query and fragment included, the way `routerLink=\"/a?b=1\"`\n // is not: as one command its `?` would be encoded into the path.\n if (typeof link === 'string' && link.startsWith('/')) return this.router.parseUrl(link);\n if (typeof link !== 'string') return this.router.createUrlTree([...link], { relativeTo: this.route });\n // A relative string keeps its query and fragment: the router parses them\n // (decoded, as it stores them) and only the path resolves against the route.\n const cut = link.search(/[?#]/);\n const path = cut >= 0 ? link.slice(0, cut) : link;\n const rest = cut >= 0 ? this.router.parseUrl(`/${link.slice(cut)}`) : null;\n const queryParams = rest && Object.keys(rest.queryParams).length > 0 ? rest.queryParams : undefined;\n return this.router.createUrlTree([path], {\n relativeTo: this.route,\n queryParams,\n fragment: rest?.fragment ?? undefined,\n // The link's own query wins over an app-wide `defaultQueryParamsHandling`.\n queryParamsHandling: queryParams ? 'replace' : undefined,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAwDA,IAAa,iBAAb,MAAa,eAAc;CACR,SAAS,OAAO,MAAM;CACtB,mBAAmB,OAAO,gBAAgB;CAC1C,QAAQ,OAAO,cAAc;CAG7B,MAAM,SACrB,KAAK,OAAO,OAAO,KACjB,QAAQ,MAA0B,aAAa,aAAa,GAC5D,KAAI,MAAK,EAA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A;EAAc,cAAA;EAAA,UAAA;EAAA,WARd,CACT;GACE,SAAS;GAET,aAAa,iBAAiB,cAAc;EAC7C,CACF;EAAA,UAAA,CAAA,gBAAA;EAAA,UAAA;CAAA,CAAA;;AAEU,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAc,YAAA,CAAA;EAX1B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,WAAW,CACT;IACE,SAAS;IAET,aAAa,iBAAgB,cAAe;GAC7C,CACF;EACF,CAAA"}
|
|
@@ -162,6 +162,7 @@ var WrTableRowHarness = class WrTableRowHarness extends ContentContainerComponen
|
|
|
162
162
|
}
|
|
163
163
|
selectBox = this.locatorForOptional(".wr-table__td--select input.wr-checkbox__input");
|
|
164
164
|
disclosure = this.locatorForOptional(".wr-table__expand-btn, button.wr-table__tree-toggle");
|
|
165
|
+
rowLink = this.locatorForOptional(":scope > td > .wr-table__row-link");
|
|
165
166
|
async getCells(filters = {}) {
|
|
166
167
|
return this.locatorForAll(WrTableCellHarness.with(filters))();
|
|
167
168
|
}
|
|
@@ -198,6 +199,10 @@ var WrTableRowHarness = class WrTableRowHarness extends ContentContainerComponen
|
|
|
198
199
|
if (!toggle) throw new Error("WrTableRowHarness.toggleExpand(): this row has no disclosure control — a flat table needs a `[wrTableExpand]` template, and a tree row with no children is a leaf.");
|
|
199
200
|
await toggle.click();
|
|
200
201
|
}
|
|
202
|
+
async getLink() {
|
|
203
|
+
const link = await this.rowLink();
|
|
204
|
+
return link ? link.getAttribute("href") : null;
|
|
205
|
+
}
|
|
201
206
|
async getLevel() {
|
|
202
207
|
return this.numericAttribute("aria-level");
|
|
203
208
|
}
|