ngwr 15.9.0 → 16.1.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/animations/aurora/styles/_index.scss +1 -1
- package/animations/blur-reveal/styles/_index.scss +1 -1
- package/animations/decode/styles/_index.scss +1 -1
- package/animations/dot-grid/styles/_index.scss +1 -1
- package/animations/flow-lines/styles/_index.scss +1 -1
- package/animations/fluid-cursor/styles/_index.scss +1 -1
- package/animations/{core → internal}/styles/_mixins.scss +1 -1
- package/animations/reveal/styles/_index.scss +1 -1
- package/animations/ripple-grid/styles/_index.scss +1 -1
- package/animations/rotate-reveal/styles/_index.scss +1 -1
- package/animations/thread-lines/styles/_index.scss +1 -1
- package/animations/typewriter/styles/_index.scss +1 -1
- package/badge/styles/_tag.scss +8 -4
- package/button/styles/_index.scss +13 -7
- package/cascader/styles/_rules.scss +4 -2
- package/checkbox/styles/_index.scss +4 -2
- package/copy-value/styles/_index.scss +104 -0
- package/date-picker/styles/_index.scss +121 -0
- package/date-stamp/styles/_index.scss +38 -0
- package/dialog/styles/_index.scss +38 -0
- package/fesm2022/{ngwr-animations-core.mjs → internal-BaQU4t_0.mjs} +6 -49
- package/fesm2022/internal-BaQU4t_0.mjs.map +1 -0
- package/fesm2022/internal-CVLvP9b_.mjs +33 -0
- package/fesm2022/internal-CVLvP9b_.mjs.map +1 -0
- package/fesm2022/ngwr-alert.mjs +13 -9
- package/fesm2022/ngwr-alert.mjs.map +1 -1
- package/fesm2022/ngwr-animations-aurora.mjs +21 -21
- 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 +2 -2
- package/fesm2022/ngwr-animations-click-sparks.mjs.map +1 -1
- package/fesm2022/ngwr-animations-confetti.mjs +5 -5
- package/fesm2022/ngwr-animations-confetti.mjs.map +1 -1
- package/fesm2022/ngwr-animations-decode.mjs +4 -4
- package/fesm2022/ngwr-animations-decode.mjs.map +1 -1
- package/fesm2022/ngwr-animations-destruct.mjs +5 -5
- package/fesm2022/ngwr-animations-destruct.mjs.map +1 -1
- package/fesm2022/ngwr-animations-dot-grid.mjs +7 -7
- 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 +17 -17
- package/fesm2022/ngwr-animations-flow-lines.mjs.map +1 -1
- package/fesm2022/ngwr-animations-fluid-cursor.mjs +12 -12
- package/fesm2022/ngwr-animations-fluid-cursor.mjs.map +1 -1
- package/fesm2022/ngwr-animations-glitch.mjs +2 -2
- package/fesm2022/ngwr-animations-glitch.mjs.map +1 -1
- package/fesm2022/ngwr-animations-marquee.mjs +2 -2
- package/fesm2022/ngwr-animations-marquee.mjs.map +1 -1
- package/fesm2022/ngwr-animations-orbit.mjs +7 -7
- package/fesm2022/ngwr-animations-orbit.mjs.map +1 -1
- package/fesm2022/ngwr-animations-reveal.mjs +4 -4
- package/fesm2022/ngwr-animations-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-ripple-grid.mjs +5 -5
- package/fesm2022/ngwr-animations-ripple-grid.mjs.map +1 -1
- package/fesm2022/ngwr-animations-rotate-reveal.mjs +4 -4
- package/fesm2022/ngwr-animations-rotate-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-shimmer.mjs +2 -2
- package/fesm2022/ngwr-animations-shimmer.mjs.map +1 -1
- package/fesm2022/ngwr-animations-spotlight.mjs +1 -1
- package/fesm2022/ngwr-animations-spotlight.mjs.map +1 -1
- package/fesm2022/ngwr-animations-thread-lines.mjs +16 -16
- package/fesm2022/ngwr-animations-thread-lines.mjs.map +1 -1
- package/fesm2022/ngwr-animations-tilt.mjs +3 -3
- package/fesm2022/ngwr-animations-tilt.mjs.map +1 -1
- package/fesm2022/ngwr-animations-typewriter.mjs +4 -4
- package/fesm2022/ngwr-animations-typewriter.mjs.map +1 -1
- package/fesm2022/ngwr-avatar.mjs +14 -10
- package/fesm2022/ngwr-avatar.mjs.map +1 -1
- package/fesm2022/ngwr-back-top.mjs +10 -6
- package/fesm2022/ngwr-back-top.mjs.map +1 -1
- package/fesm2022/ngwr-badge.mjs +18 -6
- package/fesm2022/ngwr-badge.mjs.map +1 -1
- package/fesm2022/ngwr-burger.mjs +9 -6
- package/fesm2022/ngwr-burger.mjs.map +1 -1
- package/fesm2022/ngwr-button.mjs +8 -4
- package/fesm2022/ngwr-button.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +19 -8
- package/fesm2022/ngwr-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-card.mjs +9 -5
- package/fesm2022/ngwr-card.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +54 -25
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart.mjs +13 -13
- package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart.mjs +9 -9
- package/fesm2022/ngwr-charts-boxplot-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bullet-chart.mjs +8 -8
- package/fesm2022/ngwr-charts-bullet-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +5 -2
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-charts-candlestick-chart.mjs +11 -11
- package/fesm2022/ngwr-charts-candlestick-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-chart-legend.mjs +2 -2
- package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
- package/fesm2022/ngwr-charts-core.mjs +20 -20
- package/fesm2022/ngwr-charts-core.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart.mjs +2 -2
- package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart.mjs +6 -6
- package/fesm2022/ngwr-charts-funnel-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-gauge.mjs +3 -3
- package/fesm2022/ngwr-charts-gauge.mjs.map +1 -1
- package/fesm2022/ngwr-charts-heatmap-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-heatmap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart.mjs +10 -10
- package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group.mjs +2 -2
- package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart.mjs +11 -11
- package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart.mjs +10 -10
- package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-treemap-chart.mjs +4 -4
- package/fesm2022/ngwr-charts-treemap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-waterfall-chart.mjs +7 -7
- package/fesm2022/ngwr-charts-waterfall-chart.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox.mjs +12 -8
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-clipboard.mjs +2 -1
- package/fesm2022/ngwr-clipboard.mjs.map +1 -1
- package/fesm2022/ngwr-collapse.mjs +11 -7
- package/fesm2022/ngwr-collapse.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +56 -54
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-command-palette.mjs +4 -4
- package/fesm2022/ngwr-command-palette.mjs.map +1 -1
- package/fesm2022/ngwr-comment.mjs +15 -9
- package/fesm2022/ngwr-comment.mjs.map +1 -1
- package/fesm2022/ngwr-compare.mjs +15 -9
- package/fesm2022/ngwr-compare.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +8 -6
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value-testing.mjs +58 -0
- package/fesm2022/ngwr-copy-value-testing.mjs.map +1 -0
- package/fesm2022/ngwr-copy-value.mjs +201 -0
- package/fesm2022/ngwr-copy-value.mjs.map +1 -0
- package/fesm2022/ngwr-counter.mjs +3 -3
- package/fesm2022/ngwr-counter.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +303 -70
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp-testing.mjs +34 -0
- package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -0
- package/fesm2022/ngwr-date-stamp.mjs +149 -0
- package/fesm2022/ngwr-date-stamp.mjs.map +1 -0
- package/fesm2022/ngwr-date.mjs +304 -53
- package/fesm2022/ngwr-date.mjs.map +1 -1
- package/fesm2022/ngwr-descriptions.mjs +9 -5
- package/fesm2022/ngwr-descriptions.mjs.map +1 -1
- package/fesm2022/ngwr-dialog-testing.mjs +23 -2
- package/fesm2022/ngwr-dialog-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +77 -19
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +218 -12
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-divider.mjs +4 -2
- package/fesm2022/ngwr-divider.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +32 -6
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +17 -14
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +33 -30
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-event-calendar.mjs +9 -7
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +17 -11
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +18 -6
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-graph.mjs +3 -3
- package/fesm2022/ngwr-graph.mjs.map +1 -1
- package/fesm2022/ngwr-hotkey.mjs +22 -22
- package/fesm2022/ngwr-hotkey.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +7 -0
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +7 -0
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +7 -0
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +7 -0
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +7 -0
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +7 -0
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +7 -0
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +7 -0
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +7 -0
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +7 -0
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +7 -0
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +7 -0
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +7 -0
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +7 -0
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +7 -0
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +7 -0
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +7 -0
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +7 -0
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +7 -0
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +7 -0
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +7 -0
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +7 -0
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +36 -10
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-icon.mjs +5 -5
- package/fesm2022/ngwr-icon.mjs.map +1 -1
- package/fesm2022/ngwr-image-cropper.mjs +11 -11
- package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +13 -7
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +6 -4
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +35 -25
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-keyboard.mjs +37 -31
- package/fesm2022/ngwr-keyboard.mjs.map +1 -1
- package/fesm2022/ngwr-knob.mjs +13 -7
- package/fesm2022/ngwr-knob.mjs.map +1 -1
- package/fesm2022/ngwr-layout.mjs +13 -5
- package/fesm2022/ngwr-layout.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +11 -7
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +13 -5
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-load-state.mjs +11 -7
- package/fesm2022/ngwr-load-state.mjs.map +1 -1
- package/fesm2022/ngwr-mention.mjs +6 -6
- package/fesm2022/ngwr-mention.mjs.map +1 -1
- package/fesm2022/ngwr-meta.mjs +19 -3
- package/fesm2022/ngwr-meta.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +87 -4
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +10 -7
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +22 -8
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-platform.mjs +4 -1
- package/fesm2022/ngwr-platform.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm.mjs +6 -5
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +124 -34
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-progress.mjs +4 -2
- package/fesm2022/ngwr-progress.mjs.map +1 -1
- package/fesm2022/ngwr-pull-to-refresh.mjs +2 -2
- package/fesm2022/ngwr-pull-to-refresh.mjs.map +1 -1
- package/fesm2022/ngwr-qr.mjs +6 -6
- package/fesm2022/ngwr-qr.mjs.map +1 -1
- package/fesm2022/ngwr-radio.mjs +12 -8
- package/fesm2022/ngwr-radio.mjs.map +1 -1
- package/fesm2022/ngwr-rating.mjs +19 -13
- package/fesm2022/ngwr-rating.mjs.map +1 -1
- package/fesm2022/ngwr-resizable.mjs +503 -0
- package/fesm2022/ngwr-resizable.mjs.map +1 -0
- package/fesm2022/ngwr-result.mjs +9 -5
- package/fesm2022/ngwr-result.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +15 -5
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +4 -2
- package/fesm2022/ngwr-segmented.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +70 -39
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-sidebar.mjs +3 -3
- package/fesm2022/ngwr-sidebar.mjs.map +1 -1
- package/fesm2022/ngwr-skeleton.mjs +6 -4
- package/fesm2022/ngwr-skeleton.mjs.map +1 -1
- package/fesm2022/ngwr-slider-testing.mjs.map +1 -1
- package/fesm2022/ngwr-slider.mjs +17 -15
- package/fesm2022/ngwr-slider.mjs.map +1 -1
- package/fesm2022/ngwr-sortable-list.mjs +3 -3
- package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +4 -2
- package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
- package/fesm2022/ngwr-spinner.mjs +4 -2
- package/fesm2022/ngwr-spinner.mjs.map +1 -1
- package/fesm2022/ngwr-splitter.mjs +21 -25
- package/fesm2022/ngwr-splitter.mjs.map +1 -1
- package/fesm2022/ngwr-statistic.mjs +5 -3
- package/fesm2022/ngwr-statistic.mjs.map +1 -1
- package/fesm2022/ngwr-stepper.mjs +9 -3
- package/fesm2022/ngwr-stepper.mjs.map +1 -1
- package/fesm2022/ngwr-storage.mjs +6 -4
- package/fesm2022/ngwr-storage.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +11 -7
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-table-testing.mjs +5 -1
- package/fesm2022/ngwr-table-testing.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +396 -35
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tabs.mjs +2 -2
- package/fesm2022/ngwr-tabs.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +9 -3
- package/fesm2022/ngwr-textarea.mjs.map +1 -1
- package/fesm2022/ngwr-timeline.mjs +18 -8
- package/fesm2022/ngwr-timeline.mjs.map +1 -1
- package/fesm2022/ngwr-toast-testing.mjs +14 -2
- package/fesm2022/ngwr-toast-testing.mjs.map +1 -1
- package/fesm2022/ngwr-toast.mjs +588 -120
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +7 -7
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-transfer.mjs +24 -11
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +68 -26
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-typography.mjs +9 -3
- package/fesm2022/ngwr-typography.mjs.map +1 -1
- package/fesm2022/ngwr-utils-router.mjs +18 -2
- package/fesm2022/ngwr-utils-router.mjs.map +1 -1
- package/fesm2022/ngwr-utils.mjs +106 -56
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-validators.mjs +2 -2
- 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-window.mjs +33 -30
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/fesm2022/ngwr.mjs.map +1 -1
- package/i18n/ar.json +11 -0
- package/i18n/cs.json +11 -0
- package/i18n/de.json +11 -0
- package/i18n/en.json +11 -0
- package/i18n/es.json +11 -0
- package/i18n/fr.json +11 -0
- package/i18n/he.json +11 -0
- package/i18n/hi.json +11 -0
- package/i18n/id.json +11 -0
- package/i18n/it.json +11 -0
- package/i18n/ja.json +11 -0
- package/i18n/ko.json +11 -0
- package/i18n/nl.json +11 -0
- package/i18n/pl.json +11 -0
- package/i18n/pt.json +11 -0
- package/i18n/ru.json +11 -0
- package/i18n/sv.json +11 -0
- package/i18n/tr.json +11 -0
- package/i18n/uk.json +11 -0
- package/i18n/vi.json +11 -0
- package/i18n/zh-TW.json +11 -0
- package/i18n/zh.json +11 -0
- package/input/styles/_index.scss +10 -5
- package/input-number/styles/_index.scss +12 -3
- package/input-otp/styles/_index.scss +4 -2
- package/llms-full.txt +54 -23
- package/llms.txt +45 -23
- package/mcp/providers.js +1 -1
- package/package.json +29 -10
- package/radio/styles/_index.scss +4 -2
- package/resizable/styles/_index.scss +154 -0
- package/schematics/icon-set/index.js +3 -3
- package/schematics/migrations/v16/index.js +742 -0
- package/schematics/migrations.json +5 -0
- package/schematics/ng-add/index.js +4 -4
- package/schematics/provider/index.js +4 -4
- package/schematics/use/rule.js +1 -0
- package/schematics/use/symbol-map.json +6 -0
- package/select/styles/_index.scss +7 -4
- package/skills/ngwr/SKILL.md +6 -4
- package/skills/ngwr/references/catalog.md +8 -3
- package/skills/ngwr/references/setup.md +13 -9
- package/switch/styles/_index.scss +4 -2
- package/table/styles/_index.scss +138 -29
- package/textarea/styles/_index.scss +4 -2
- package/theme/styles/_motion.scss +6 -0
- package/toast/styles/_index.scss +49 -0
- package/tree/styles/_index.scss +17 -0
- package/types/index-CXbgza47.d.ts +13 -0
- package/types/ngwr-animations-aurora.d.ts +1 -1
- package/types/ngwr-animations-blur-reveal.d.ts +2 -2
- package/types/ngwr-animations-dot-grid.d.ts +1 -2
- package/types/ngwr-animations-flow-lines.d.ts +1 -1
- package/types/ngwr-animations-fluid-cursor.d.ts +1 -1
- package/types/ngwr-animations-reveal.d.ts +4 -8
- package/types/ngwr-animations-ripple-grid.d.ts +1 -1
- package/types/ngwr-animations-spotlight.d.ts +1 -1
- package/types/ngwr-animations-thread-lines.d.ts +1 -1
- package/types/ngwr-animations-tilt.d.ts +1 -1
- package/types/ngwr-avatar.d.ts +2 -2
- package/types/ngwr-badge.d.ts +1 -1
- package/types/ngwr-burger.d.ts +0 -1
- package/types/ngwr-calendar.d.ts +7 -0
- package/types/ngwr-cascader.d.ts +12 -1
- package/types/ngwr-charts-boxplot-chart.d.ts +1 -1
- package/types/ngwr-charts-bullet-chart.d.ts +2 -2
- package/types/ngwr-charts-calendar-heatmap.d.ts +2 -1
- package/types/ngwr-charts-candlestick-chart.d.ts +1 -1
- package/types/ngwr-charts-core.d.ts +12 -12
- package/types/ngwr-charts-line-chart.d.ts +2 -2
- package/types/ngwr-charts-radar-chart.d.ts +1 -1
- package/types/ngwr-charts-scatter-chart.d.ts +2 -2
- package/types/ngwr-charts-waterfall-chart.d.ts +1 -1
- package/types/ngwr-clipboard.d.ts +7 -0
- package/types/ngwr-color-picker.d.ts +12 -12
- package/types/ngwr-copy-value-testing.d.ts +87 -0
- package/types/ngwr-copy-value.d.ts +95 -0
- package/types/ngwr-date-picker-testing.d.ts +3 -3
- package/types/ngwr-date-picker.d.ts +106 -3
- package/types/ngwr-date-stamp-testing.d.ts +47 -0
- package/types/ngwr-date-stamp.d.ts +81 -0
- package/types/ngwr-date.d.ts +179 -27
- package/types/ngwr-dialog-testing.d.ts +10 -0
- package/types/ngwr-dialog.d.ts +120 -5
- package/types/ngwr-directives.d.ts +76 -1
- package/types/ngwr-drawer.d.ts +22 -1
- package/types/ngwr-dropdown.d.ts +3 -2
- package/types/ngwr-hotkey.d.ts +5 -5
- package/types/ngwr-i18n.d.ts +47 -17
- package/types/ngwr-icon.d.ts +26 -26
- package/types/ngwr-input-number.d.ts +2 -2
- package/types/ngwr-input.d.ts +8 -8
- package/types/ngwr-load-state.d.ts +6 -6
- package/types/ngwr-meta.d.ts +18 -0
- package/types/ngwr-overlay.d.ts +36 -0
- package/types/ngwr-pipes.d.ts +21 -4
- package/types/ngwr-platform.d.ts +2 -1
- package/types/ngwr-popconfirm.d.ts +3 -2
- package/types/ngwr-popover.d.ts +43 -4
- package/types/ngwr-resizable.d.ts +228 -0
- package/types/ngwr-select.d.ts +33 -18
- package/types/ngwr-slider-testing.d.ts +2 -2
- package/types/ngwr-slider.d.ts +3 -3
- package/types/ngwr-statistic.d.ts +5 -1
- package/types/ngwr-storage.d.ts +1 -1
- package/types/ngwr-table-testing.d.ts +5 -2
- package/types/ngwr-table.d.ts +255 -14
- package/types/ngwr-tabs.d.ts +10 -2
- package/types/ngwr-toast-testing.d.ts +18 -3
- package/types/ngwr-toast.d.ts +248 -23
- package/types/ngwr-transfer.d.ts +5 -0
- package/types/ngwr-tree.d.ts +22 -2
- package/types/ngwr-utils-router.d.ts +22 -0
- package/types/ngwr-utils.d.ts +165 -83
- package/types/ngwr-validators.d.ts +4 -2
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr.d.ts +2 -0
- package/types/pointer-tracker-D7fXxLQL.d.ts +24 -0
- package/fesm2022/ngwr-animations-core.mjs.map +0 -1
- package/types/ngwr-animations-core.d.ts +0 -294
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-splitter.mjs","names":[],"sources":["../../../projects/lib/splitter/splitter.ts","../../../projects/lib/splitter/splitter.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 { Component, ElementRef, ViewEncapsulation, computed, effect, inject, input, model } from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { clamp, round, wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Resizable two-pane splitter. Project two pieces of content via\n * `[wrSplitterStart]` and `[wrSplitterEnd]`; the user drags the divider\n * to reallocate space between them.\n *\n * @example\n * ```html\n * <wr-splitter [(position)]=\"pos\">\n * <div wrSplitterStart>Files</div>\n * <div wrSplitterEnd>Editor</div>\n * </wr-splitter>\n *\n * <wr-splitter orientation=\"vertical\" [minPosition]=\"20\" [maxPosition]=\"80\">\n * <div wrSplitterStart>Preview</div>\n * <div wrSplitterEnd>Logs</div>\n * </wr-splitter>\n * ```\n *\n * @see https://ngwr.dev/reference/components/splitter\n */\n@Component({\n selector: 'wr-splitter',\n templateUrl: './splitter.html',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n})\nexport class WrSplitter {\n /** Position of the divider as a percentage (0–100). Two-way bindable. @default 50 */\n readonly position = model(50);\n\n /**\n * Divider direction:\n * - `'horizontal'` — vertical divider, drags L/R (panes side by side).\n * - `'vertical'` — horizontal divider, drags U/D (panes stacked).\n * @default 'horizontal'\n */\n readonly orientation = input<'horizontal' | 'vertical'>('horizontal');\n\n /** Minimum allowed position. @default 0 */\n readonly minPosition = input(0, { transform: (v: unknown): number => coerceNumberProperty(v, 0) });\n\n /** Maximum allowed position. @default 100 */\n readonly maxPosition = input(100, { transform: (v: unknown): number => coerceNumberProperty(v, 100) });\n\n /** Disable dragging. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Accessible name of the divider. A focusable `role=\"separator\"` is an\n * interactive widget, so it needs one — without it a screen reader reaching the\n * divider announces nothing but \"separator\" and its number. Falls back to\n * `splitter.divider`.\n */\n readonly dividerLabel = input<string | null>(null);\n\n protected readonly resolvedDividerLabel = useI18nText(this.dividerLabel, 'splitter.divider', 'Resize panes');\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n // Optional on purpose: `Directionality` is root-provided, so a consumer never has to\n // supply it — and a bare `TestBed` does not either.\n private readonly dir = inject(Directionality, { optional: true });\n private dragging = false;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('splitter');\n // `position` is a `model`, so `[(position)]` and a restored layout write into it\n // directly; only the drag and the arrows clamped. Left alone, an out-of-range\n // write reached the DOM as `aria-valuenow=\"150\"` against a `valuemax` of 100 and\n // sized a pane at `150%`.\n effect(() => {\n const clamped = clamp(this.position(), this.minPosition(), this.maxPosition());\n if (clamped !== this.position()) this.position.set(clamped);\n });\n }\n\n protected readonly classes = computed(() => {\n const parts = ['wr-splitter', `wr-splitter--${this.orientation()}`];\n if (this.disabled()) parts.push('wr-splitter--disabled');\n return parts.join(' ');\n });\n\n protected readonly startStyle = computed(() => `${this.position()}%`);\n protected readonly endStyle = computed(() => `${100 - this.position()}%`);\n\n // Drag\n\n protected onPointerDown(event: PointerEvent): void {\n if (this.disabled()) return;\n // Any pointerdown used to start a drag, so holding the RIGHT button over the\n // divider and moving resized the panes; the same guard keeps a second finger\n // from taking over a drag already in progress.\n if (event.button !== 0 || !event.isPrimary) return;\n event.preventDefault();\n this.dragging = true;\n const handle = event.currentTarget as HTMLElement;\n handle.setPointerCapture(event.pointerId);\n // `preventDefault` above also suppresses the click's default focus, so without\n // this the arrows did nothing after a mouse drag until the user found the\n // divider again with Tab. `wr-slider` focuses its thumb for the same reason.\n handle.focus();\n }\n\n protected onPointerMove(event: PointerEvent): void {\n if (!this.dragging) return;\n const rect = this.host.nativeElement.getBoundingClientRect();\n const raw =\n this.orientation() === 'horizontal'\n ? this.inlineFraction(event.clientX, rect) * 100\n : // The vertical split is laid out on the BLOCK axis, which `dir` does not\n // touch — measured from the top in both directions.\n ((event.clientY - rect.top) / rect.height) * 100;\n // To a tenth of a percent — about a pixel on a full-width split. The raw\n // quotient reached `aria-valuenow` and `[(position)]` as `29.99999822054938`,\n // read out digit by digit and handed to the host to persist.\n this.position.set(clamp(round(raw, 1), this.minPosition(), this.maxPosition()));\n }\n\n protected onPointerUp(event: PointerEvent): void {\n if (!this.dragging) return;\n this.dragging = false;\n (event.currentTarget as HTMLElement).releasePointerCapture(event.pointerId);\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (this.disabled()) return;\n const step = event.shiftKey ? 10 : 1;\n // An arrow step lands on a whole number, so the keys after a drag do not\n // carry the drag's fraction along (`30.4` stepped to `31.4`, `32.4`, …).\n // Home and End below are the bounds themselves, whatever they are.\n const position = round(this.position());\n let next: number | null = null;\n if (this.orientation() === 'horizontal') {\n // Arrows follow the VISUAL axis (WAI-ARIA APG). Under `dir=\"rtl\"` the start pane\n // is the one on the RIGHT, so the visual right is the low end of the range and\n // ArrowRight has to shrink the position rather than grow it — otherwise the\n // divider walks away from the key the user is pressing.\n const inline = this.isRtl() ? -step : step;\n if (event.key === 'ArrowLeft') next = position - inline;\n else if (event.key === 'ArrowRight') next = position + inline;\n } else {\n // Block axis: unaffected by `dir`.\n if (event.key === 'ArrowUp') next = position - step;\n else if (event.key === 'ArrowDown') next = position + step;\n }\n // Home/End are semantic — first/last, not left/right — so they never mirror.\n if (event.key === 'Home') next = this.minPosition();\n else if (event.key === 'End') next = this.maxPosition();\n if (next === null) return;\n event.preventDefault();\n this.position.set(clamp(next, this.minPosition(), this.maxPosition()));\n }\n\n /**\n * Fraction of the host's width measured from the INLINE-START edge — the left edge in\n * LTR, the right edge in RTL, which is where `flex-direction: row` puts the start pane\n * whose size `position` is. Counted from `rect.left` in both, a drag under `dir=\"rtl\"`\n * read 0 where the start pane was widest and inverted the whole gesture.\n */\n private inlineFraction(clientX: number, rect: DOMRect): number {\n return this.isRtl() ? (rect.right - clientX) / rect.width : (clientX - rect.left) / rect.width;\n }\n\n /**\n * Read per event rather than cached: nothing this component renders is derived from the\n * direction — `flex-direction: row` mirrors the panes on its own — so there is no stale\n * value for `Directionality.change` to invalidate.\n */\n private isRtl(): boolean {\n return this.dir?.value === 'rtl';\n }\n}\n","<div class=\"wr-splitter__pane wr-splitter__pane--start\" [style.flex-basis]=\"startStyle()\">\n <ng-content select=\"[wrSplitterStart]\" />\n</div>\n\n<!-- Roving focus + arrow keys for keyboard resizing. -->\n<div\n class=\"wr-splitter__divider\"\n role=\"separator\"\n [attr.aria-label]=\"resolvedDividerLabel()\"\n [attr.aria-orientation]=\"orientation() === 'horizontal' ? 'vertical' : 'horizontal'\"\n [attr.aria-valuemin]=\"minPosition()\"\n [attr.aria-valuemax]=\"maxPosition()\"\n [attr.aria-valuenow]=\"position()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.tabindex]=\"disabled() ? -1 : 0\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (keydown)=\"onKeydown($event)\"\n>\n <span class=\"wr-splitter__handle\" aria-hidden=\"true\"></span>\n</div>\n\n<div class=\"wr-splitter__pane wr-splitter__pane--end\" [style.flex-basis]=\"endStyle()\">\n <ng-content select=\"[wrSplitterEnd]\" />\n</div>\n"],"mappings":";;;;;;;;;;;;AAwCA,IAAa,aAAb,MAAa,WAAU;CAEZ,WAAW,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAQpB,cAAc,MAAiC,cAAa,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAG5D,cAAc,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,cAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,CAAC;CAAC,CAAA;CAGtF,cAAc,MAAM,KAAG;EAAA,GAAA,YAAA,EAAA,WAAA,cAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,GAAG;CAAC,CAAA;CAG1F,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAQ1D,eAAe,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,eAAA,CAAA,+BAAA,CAAA,CAAA;CAE/B,uBAAuB,YAAY,KAAK,cAAc,oBAAoB,cAAc;CAE1F,OAAO,OAAgC,UAAU;CAGjD,MAAM,OAAO,gBAAgB,EAAE,UAAU,KAAI,CAAE;CACxD,WAAW;CAEnB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,UAAU;EAK3E,aAAY;GACV,MAAM,UAAU,MAAM,KAAK,SAAQ,GAAI,KAAK,YAAW,GAAI,KAAK,YAAW,CAAE;GAC7E,IAAI,YAAY,KAAK,SAAQ,GAAI,KAAK,SAAS,IAAI,OAAO;E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AAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,cAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA,EAAA,UAAA,iBAAA;EAAA,MAAA,EAAA,YAAA,EAAA,SAAA,YAAA,EAAA;EAAA,UAAA;EAAA,UCxCvB;EA2BA,eAAA,GAAA,kBAAA;CAAA,CAAA;;ADaa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA;EANtB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAa,eAER,kBAAkB;GAAI,MAC/B,EAAE,WAAW,YAAW;GAAE,UAAA;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-splitter.mjs","names":[],"sources":["../../../projects/lib/splitter/splitter.ts","../../../projects/lib/splitter/splitter.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 { Component, ElementRef, ViewEncapsulation, computed, effect, inject, input, model } from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrClamp, wrRound, wrCheckStyles } from 'ngwr/utils';\n\nimport { wrBeginSeparatorDrag, wrEndSeparatorDrag, wrSeparatorKeyMove } from './internal';\n\n/**\n * Resizable two-pane splitter. Project two pieces of content via\n * `[wrSplitterStart]` and `[wrSplitterEnd]`; the user drags the divider\n * to reallocate space between them.\n *\n * @example\n * ```html\n * <wr-splitter [(position)]=\"pos\">\n * <div wrSplitterStart>Files</div>\n * <div wrSplitterEnd>Editor</div>\n * </wr-splitter>\n *\n * <wr-splitter orientation=\"vertical\" [minPosition]=\"20\" [maxPosition]=\"80\">\n * <div wrSplitterStart>Preview</div>\n * <div wrSplitterEnd>Logs</div>\n * </wr-splitter>\n * ```\n *\n * @see https://ngwr.dev/reference/components/splitter\n */\n@Component({\n selector: 'wr-splitter',\n templateUrl: './splitter.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-splitter', '[class]': 'classes()' },\n})\nexport class WrSplitter {\n /** Position of the divider as a percentage (0–100). Two-way bindable. @default 50 */\n readonly position = model(50);\n\n /**\n * Divider direction:\n * - `'horizontal'` — vertical divider, drags L/R (panes side by side).\n * - `'vertical'` — horizontal divider, drags U/D (panes stacked).\n * @default 'horizontal'\n */\n readonly orientation = input<'horizontal' | 'vertical'>('horizontal');\n\n /** Minimum allowed position. @default 0 */\n readonly minPosition = input(0, { transform: (v: unknown): number => coerceNumberProperty(v, 0) });\n\n /** Maximum allowed position. @default 100 */\n readonly maxPosition = input(100, { transform: (v: unknown): number => coerceNumberProperty(v, 100) });\n\n /** Disable dragging. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Accessible name of the divider. A focusable `role=\"separator\"` is an\n * interactive widget, so it needs one — without it a screen reader reaching the\n * divider announces nothing but \"separator\" and its number. Falls back to\n * `splitter.divider`.\n */\n readonly dividerLabel = input<string | null>(null);\n\n protected readonly resolvedDividerLabel = useI18nText(this.dividerLabel, 'splitter.divider', 'Resize panes');\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n // Optional on purpose: `Directionality` is root-provided, so a consumer never has to\n // supply it — and a bare `TestBed` does not either.\n private readonly dir = inject(Directionality, { optional: true });\n private dragging = false;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('splitter');\n // `position` is a `model`, so `[(position)]` and a restored layout write into it\n // directly; only the drag and the arrows clamped. Left alone, an out-of-range\n // write reached the DOM as `aria-valuenow=\"150\"` against a `valuemax` of 100 and\n // sized a pane at `150%`.\n effect(() => {\n const clamped = wrClamp(this.position(), this.minPosition(), this.maxPosition());\n if (clamped !== this.position()) this.position.set(clamped);\n });\n }\n\n protected readonly classes = computed(() => {\n const parts = ['wr-splitter', `wr-splitter--${this.orientation()}`];\n if (this.disabled()) parts.push('wr-splitter--disabled');\n return parts.join(' ');\n });\n\n protected readonly startStyle = computed(() => `${this.position()}%`);\n protected readonly endStyle = computed(() => `${100 - this.position()}%`);\n\n // Drag\n\n protected onPointerDown(event: PointerEvent): void {\n if (this.disabled()) return;\n this.dragging = wrBeginSeparatorDrag(event);\n }\n\n protected onPointerMove(event: PointerEvent): void {\n if (!this.dragging) return;\n const rect = this.host.nativeElement.getBoundingClientRect();\n const raw =\n this.orientation() === 'horizontal'\n ? this.inlineFraction(event.clientX, rect) * 100\n : // The vertical split is laid out on the BLOCK axis, which `dir` does not\n // touch — measured from the top in both directions.\n ((event.clientY - rect.top) / rect.height) * 100;\n // To a tenth of a percent — about a pixel on a full-width split. The raw\n // quotient reached `aria-valuenow` and `[(position)]` as `29.99999822054938`,\n // read out digit by digit and handed to the host to persist.\n this.position.set(wrClamp(wrRound(raw, 1), this.minPosition(), this.maxPosition()));\n }\n\n protected onPointerUp(event: PointerEvent): void {\n if (!this.dragging) return;\n this.dragging = false;\n wrEndSeparatorDrag(event);\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (this.disabled()) return;\n const move = wrSeparatorKeyMove(event, this.orientation() === 'horizontal' ? 'inline' : 'block', this.isRtl());\n if (move === null) return;\n event.preventDefault();\n let next: number;\n if (move === 'min') next = this.minPosition();\n else if (move === 'max') next = this.maxPosition();\n // An arrow step lands on a whole number, so the keys after a drag do not\n // carry the drag's fraction along (`30.4` stepped to `31.4`, `32.4`, …).\n // Home and End above are the bounds themselves, whatever they are.\n else next = wrRound(this.position()) + move * (event.shiftKey ? 10 : 1);\n this.position.set(wrClamp(next, this.minPosition(), this.maxPosition()));\n }\n\n /**\n * Fraction of the host's width measured from the INLINE-START edge — the left edge in\n * LTR, the right edge in RTL, which is where `flex-direction: row` puts the start pane\n * whose size `position` is. Counted from `rect.left` in both, a drag under `dir=\"rtl\"`\n * read 0 where the start pane was widest and inverted the whole gesture.\n */\n private inlineFraction(clientX: number, rect: DOMRect): number {\n return this.isRtl() ? (rect.right - clientX) / rect.width : (clientX - rect.left) / rect.width;\n }\n\n /**\n * Read per event rather than cached: nothing this component renders is derived from the\n * direction — `flex-direction: row` mirrors the panes on its own — so there is no stale\n * value for `Directionality.change` to invalidate.\n */\n private isRtl(): boolean {\n return this.dir?.value === 'rtl';\n }\n}\n","<div class=\"wr-splitter__pane wr-splitter__pane--start\" [style.flex-basis]=\"startStyle()\">\n <ng-content select=\"[wrSplitterStart]\" />\n</div>\n\n<!-- Roving focus + arrow keys for keyboard resizing. -->\n<div\n class=\"wr-splitter__divider\"\n role=\"separator\"\n [attr.aria-label]=\"resolvedDividerLabel()\"\n [attr.aria-orientation]=\"orientation() === 'horizontal' ? 'vertical' : 'horizontal'\"\n [attr.aria-valuemin]=\"minPosition()\"\n [attr.aria-valuemax]=\"maxPosition()\"\n [attr.aria-valuenow]=\"position()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.tabindex]=\"disabled() ? -1 : 0\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (keydown)=\"onKeydown($event)\"\n>\n <span class=\"wr-splitter__handle\" aria-hidden=\"true\"></span>\n</div>\n\n<div class=\"wr-splitter__pane wr-splitter__pane--end\" [style.flex-basis]=\"endStyle()\">\n <ng-content select=\"[wrSplitterEnd]\" />\n</div>\n"],"mappings":";;;;;;;;;;;;;AA0CA,IAAa,aAAb,MAAa,WAAU;CAEZ,WAAW,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAQpB,cAAc,MAAiC,cAAa,GAAA,YAAA,CAAA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AA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAU,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAV,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAU,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,aAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,aAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,aAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,cAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA,EAAA,UAAA,iBAAA;EAAA,MAAA;GAAA,YAAA,EAAA,SAAA,YAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UC1CvB;EA2BA,eAAA,GAAA,kBAAA;CAAA,CAAA;;ADea,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA;EANtB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAa,eAER,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAe,WAAW;GAAW;GAAE,UAAA;EAAA,CAAA"}
|
|
@@ -2,7 +2,7 @@ import * as i0 from "@angular/core";
|
|
|
2
2
|
import { Component, LOCALE_ID, PLATFORM_ID, ViewEncapsulation, computed, effect, inject, input, output, signal, untracked } from "@angular/core";
|
|
3
3
|
import { coerceBooleanProperty, coerceNumberProperty } from "@angular/cdk/coercion";
|
|
4
4
|
import { isPlatformBrowser } from "@angular/common";
|
|
5
|
-
import {
|
|
5
|
+
import { wrCheckStyles, wrNumAttr } from "ngwr/utils";
|
|
6
6
|
import { useI18nFormatter, useI18nText } from "ngwr/i18n";
|
|
7
7
|
import { WrPlatform } from "ngwr/platform";
|
|
8
8
|
import { WrCountUp } from "ngwr/counter";
|
|
@@ -31,7 +31,7 @@ var WrStatistic = class WrStatistic {
|
|
|
31
31
|
});
|
|
32
32
|
duration = input(700, {
|
|
33
33
|
...ngDevMode ? { debugName: "duration" } : /* istanbul ignore next */ {},
|
|
34
|
-
transform:
|
|
34
|
+
transform: wrNumAttr(700)
|
|
35
35
|
});
|
|
36
36
|
numericValue = computed(() => {
|
|
37
37
|
const raw = this.value();
|
|
@@ -328,7 +328,7 @@ var WrStatisticCountdown = class WrStatisticCountdown {
|
|
|
328
328
|
endText = input(null, ...ngDevMode ? [{ debugName: "endText" }] : /* istanbul ignore next */ []);
|
|
329
329
|
tickMs = input(1e3, {
|
|
330
330
|
...ngDevMode ? { debugName: "tickMs" } : /* istanbul ignore next */ {},
|
|
331
|
-
transform: (v) => Math.max(16,
|
|
331
|
+
transform: (v) => Math.max(16, wrNumAttr(1e3)(v))
|
|
332
332
|
});
|
|
333
333
|
countdownEnd = output();
|
|
334
334
|
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
@@ -349,9 +349,11 @@ var WrStatisticCountdown = class WrStatisticCountdown {
|
|
|
349
349
|
const ms = this.remainingMs();
|
|
350
350
|
this.remaining.set(ms ?? 0);
|
|
351
351
|
this.finished.set(ms === 0);
|
|
352
|
+
if (ms === 0) untracked(() => this.countdownEnd.emit());
|
|
352
353
|
});
|
|
353
354
|
if (!this.isBrowser) return;
|
|
354
355
|
effect((onCleanup) => {
|
|
356
|
+
if (this.finished()) return;
|
|
355
357
|
const handle = setInterval(() => this.tick(), this.tickMs());
|
|
356
358
|
onCleanup(() => clearInterval(handle));
|
|
357
359
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-statistic.mjs","names":[],"sources":["../../../projects/lib/statistic/statistic.ts","../../../projects/lib/statistic/statistic.html","../../../projects/lib/statistic/statistic-countdown.ts","../../../projects/lib/statistic/statistic-countdown.html","../../../projects/lib/statistic/statistic-group.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 { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n LOCALE_ID,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WrCountUp } from 'ngwr/counter';\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\nimport { WrPlatform } from 'ngwr/platform';\nimport { numAttr, wrCheckStyles } from 'ngwr/utils';\n\n/** Digits with one optional point and a sign: the form `Intl` reads exactly. */\nconst PLAIN_DECIMAL = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)$/;\n\n/**\n * KPI card — label + big number + optional prefix/suffix + delta. Pair\n * with `<wr-statistic-group>` for a responsive dashboard grid.\n *\n * When `value` is numeric the number counts up (eased) from its previous\n * value to the new one on every change — see `animate`. String values and\n * `prefers-reduced-motion` render instantly.\n *\n * @example\n * ```html\n * <wr-statistic label=\"Active users\" [value]=\"12345\" suffix=\"users\" />\n * <wr-statistic label=\"Revenue\" [value]=\"9512\" prefix=\"$\" [delta]=\"12.4\" />\n * <wr-statistic label=\"Churn\" [value]=\"1.8\" suffix=\"%\" [precision]=\"1\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/statistic\n */\n@Component({\n selector: 'wr-statistic',\n templateUrl: './statistic.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-statistic' },\n imports: [WrCountUp],\n})\nexport class WrStatistic {\n private readonly platform = inject(WrPlatform);\n private readonly locale = inject(LOCALE_ID);\n\n /**\n * The caption above the figure — what the number counts. Keep it short; the\n * value is the thing being read, and this names it.\n */\n readonly label = input<string>('');\n\n /** The number (or string) to display in the main slot. */\n readonly value = input<number | string | null>(null);\n\n /** Prefix glyph / symbol (e.g. `'$'`). */\n readonly prefix = input<string>('');\n\n /** Suffix glyph / unit (e.g. `'%'`, `'kg'`). */\n readonly suffix = input<string>('');\n\n /** Fixed number of decimals applied to numeric values. @default 0 */\n readonly precision = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /**\n * Count up to a new numeric `value` instead of swapping instantly. Always\n * off for string values or under `prefers-reduced-motion`. @default true\n */\n readonly animate = input(true, { transform: coerceBooleanProperty });\n\n /** Count-up duration (ms). @default 700 */\n readonly duration = input(700, { transform: numAttr(700) });\n\n /**\n * The current value coerced to a finite number, or `null` when `value` is\n * a non-numeric string / empty / nullish (rendered as-is).\n */\n protected readonly numericValue = computed<number | null>(() => {\n const raw = this.value();\n if (raw === null || raw === '') return null;\n const n = typeof raw === 'number' ? raw : coerceNumberProperty(raw, Number.NaN);\n return Number.isFinite(n) ? n : null;\n });\n\n /** Whether the value should count up (browser, numeric, opted-in, motion allowed). */\n protected readonly animated = computed<boolean>(\n () =>\n this.platform.isBrowser &&\n this.animate() &&\n !this.platform.prefersReducedMotion() &&\n typeof this.value() === 'number' &&\n this.numericValue() !== null\n );\n\n /** Animation start — the previously-rendered numeric value (0 on first paint). */\n protected readonly animateFrom = signal(0);\n\n /** Bookkeeping: the last numeric value seen, fed back as the next `from`. */\n private readonly lastNumeric = signal(0);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('statistic');\n // Whenever the numeric value changes, snapshot the prior value as the\n // count-up start, then remember the new one for the next transition.\n effect(() => {\n const next = this.numericValue();\n if (next === null) return;\n untracked(() => {\n this.animateFrom.set(this.lastNumeric());\n this.lastNumeric.set(next);\n });\n });\n }\n\n /**\n * Static (non-animated) display string. Numeric values honour `precision`\n * and locale grouping so they match the count-up output; everything else\n * renders verbatim with an em-dash fallback.\n */\n protected readonly displayValue = computed<string>(() => {\n const n = this.numericValue();\n if (n !== null) {\n // A plain decimal string is formatted as it is, the way `wrNumber` does it,\n // so a long amount keeps every digit. `format()` has taken a string since\n // ES2023, though the ES2022 lib types it as a number only.\n const raw = typeof this.value() === 'string' ? String(this.value()).trim() : '';\n return new Intl.NumberFormat(this.locale, {\n minimumFractionDigits: this.precision(),\n maximumFractionDigits: this.precision(),\n }).format(PLAIN_DECIMAL.test(raw) ? (raw as unknown as number) : n);\n }\n // `numericValue` above already reads `''` as \"no value\"; rendering it\n // verbatim put an empty card on screen instead of the placeholder.\n const raw = this.value();\n return raw === null || raw === undefined || raw === '' ? '—' : String(raw);\n });\n\n /**\n * Optional delta vs previous period — shown as `+x.x%` (or `-x.x%`).\n * Use `deltaSuffix` to change the trailing unit.\n */\n readonly delta = input<number | null>(null, {\n transform: (v: unknown): number | null => {\n if (v === null || v === undefined || v === '') return null;\n const n = coerceNumberProperty(v, Number.NaN);\n return Number.isFinite(n) ? n : null;\n },\n });\n\n // The default moved from the literal `'%'` to `null` so the catalog gets a\n // say. `%` is a string the LIBRARY owns and no locale could reach: a locale\n // that writes it differently — or writes it as a word — had nowhere to put\n // that but a per-instance binding on every `<wr-statistic>` on the page. A\n // bound value still wins, exactly as before, which is what makes this safe.\n /** Unit appended to the delta value. Falls back to `statistic.deltaSuffix`, then `'%'`. */\n readonly deltaSuffix = input<string | null>(null);\n\n protected readonly hasDelta = computed(() => this.delta() !== null);\n\n protected readonly deltaDirection = computed<'up' | 'down' | 'flat'>(() => {\n const d = this.delta();\n if (d === null || d === 0) return 'flat';\n return d > 0 ? 'up' : 'down';\n });\n\n protected readonly resolvedDeltaSuffix = useI18nText(this.deltaSuffix, 'statistic.deltaSuffix', '%');\n\n /** `{{value}}{{suffix}}` — the join, so a locale owns the space before the unit. */\n private readonly deltaFormat = useI18nFormatter('statistic.delta', '{{value}}{{suffix}}');\n\n /**\n * The delta chip, e.g. `+12.4%`.\n *\n * It was `` `${sign}${d}${suffix}` ``, printed one line under a value that\n * goes through `Intl.NumberFormat` — so the two disagreed inside one\n * component: ar-SA showed `١٬٢٣٤٬٥٦٧٫٨٩` above a Latin `12.4%`, and de-DE\n * `1.234.567,89` above `+12.4%`. The sign comes from `signDisplay`, which also\n * fixes the RTL half of it: `+` written by hand is a neutral character that\n * the BiDi algorithm moves to the other end of the number.\n *\n * The digit count is taken from the number rather than from `precision()`,\n * which describes the VALUE and not the delta — so what renders is the same\n * digits as before, in the locale's own numerals. One exception, and it is an\n * improvement rather than a regression: a magnitude JavaScript prints in\n * exponent notation (`1e-7`, `1e+21`) used to reach the DOM that way and is\n * now formatted as a number.\n */\n protected readonly deltaText = computed(() => {\n const d = this.delta();\n if (d === null) return '';\n const decimals = Math.min(20, (String(Math.abs(d)).split('.')[1] ?? '').length);\n const value = new Intl.NumberFormat(this.locale, {\n signDisplay: 'exceptZero',\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n }).format(d);\n return this.deltaFormat({ value, suffix: this.resolvedDeltaSuffix() });\n });\n}\n","@if (label()) {\n <div class=\"wr-statistic__label\">{{ label() }}</div>\n}\n<div class=\"wr-statistic__value\">\n @if (prefix()) {\n <span class=\"wr-statistic__prefix\">{{ prefix() }}</span>\n }\n @if (animated()) {\n <wr-count-up\n class=\"wr-statistic__number\"\n [from]=\"animateFrom()\"\n [to]=\"numericValue() ?? 0\"\n [decimals]=\"precision()\"\n [duration]=\"duration()\"\n />\n } @else {\n <span class=\"wr-statistic__number\">{{ displayValue() }}</span>\n }\n @if (suffix()) {\n <span class=\"wr-statistic__suffix\">{{ suffix() }}</span>\n }\n</div>\n@if (hasDelta()) {\n <div [class]=\"`wr-statistic__delta wr-statistic__delta--${deltaDirection()}`\">\n @if (deltaDirection() === 'up') {\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" aria-hidden=\"true\">\n <path d=\"M5 1 L9 8 L1 8 Z\" fill=\"currentColor\" />\n </svg>\n } @else if (deltaDirection() === 'down') {\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" aria-hidden=\"true\">\n <path d=\"M5 9 L9 2 L1 2 Z\" fill=\"currentColor\" />\n </svg>\n }\n <span>{{ deltaText() }}</span>\n </div>\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 { isPlatformBrowser } from '@angular/common';\nimport {\n Component,\n PLATFORM_ID,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\n\nimport { type WrDurationUnit, wrSplitDuration } from 'ngwr/pipes';\nimport { numAttr, wrCheckStyles } from 'ngwr/utils';\n\n// Helpers\n\nfunction toMs(value: Date | string | number): number {\n if (value instanceof Date) return value.getTime();\n if (typeof value === 'number') return value;\n return new Date(value).getTime();\n}\n\nfunction pad(n: number, width: number): string {\n return String(n).padStart(width, '0');\n}\n\n/**\n * The format's tokens, longest first inside the alternation so `DD` beats `D`,\n * `HH` beats `H`, `mm` beats `m` and `SSS` beats `ss` beats `s`. Matched in one pass\n * so the output is never re-scanned: a sequential `.replace()` chain turned\n * `D days HH:mm:ss` into `1 day42 11:59:42`, its last `/s/g` step re-matching the\n * literal `s` inside `days`.\n */\nconst TOKEN = /(?<![A-Za-z])(?:SSS|DD|HH|mm|ss|D|H|m|s)(?![A-Za-z])/g;\n\n/** The unit each token's letter stands for. */\nconst UNIT_OF: Readonly<Record<string, WrDurationUnit>> = {\n D: 'day',\n H: 'hour',\n m: 'minute',\n s: 'second',\n S: 'millisecond',\n};\n\n/**\n * A unit the format does not show is carried into the next larger one it does:\n * `HH:mm:ss` with three days left reads `73:00:00`. Every unit was taken modulo\n * the next one whatever the format held, so the default format dropped whole days\n * and showed `00:59:59` for three days and an hour. The split itself is\n * `wrSplitDuration`, shared with `wrDuration`.\n */\nfunction formatRemaining(ms: number, fmt: string): string {\n const shown = new Set((fmt.match(TOKEN) ?? []).map(token => UNIT_OF[token[0]]));\n const value = wrSplitDuration(ms, shown);\n return fmt.replace(TOKEN, token => {\n const n = value[UNIT_OF[token[0]]] ?? 0;\n return token === 'SSS' ? pad(n, 3) : token.length === 2 ? pad(n, 2) : String(n);\n });\n}\n\n/**\n * Live-counting variant of `<wr-statistic>` that targets a future date\n * and ticks down to zero. The format string uses Day/Hour/Minute/Second\n * tokens (`D`, `H`, `m`, `s`, double for zero-padded, plus `SSS` for\n * milliseconds).\n *\n * @example\n * ```html\n * <wr-statistic-countdown\n * label=\"Launch in\"\n * [target]=\"launchDate\"\n * format=\"D days HH:mm:ss\"\n * (countdownEnd)=\"onLive()\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/statistic\n */\n@Component({\n selector: 'wr-statistic-countdown',\n templateUrl: './statistic-countdown.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-statistic' },\n})\nexport class WrStatisticCountdown {\n /** Target date / timestamp the countdown is running down to. */\n readonly target = input.required<Date | string | number>();\n\n /** Label rendered above the value. */\n readonly label = input<string>('');\n\n /**\n * Format string. Tokens: `D`/`DD` (days), `H`/`HH` (hours),\n * `m`/`mm` (minutes), `s`/`ss` (seconds), `SSS` (milliseconds).\n * Double-letter forms zero-pad to width 2. A unit the format leaves out is\n * carried into the next larger one it shows, so `HH:mm:ss` reads `73:00:00`\n * with three days and an hour left. @default 'HH:mm:ss'\n */\n readonly format = input<string>('HH:mm:ss');\n\n /** Optional text shown once the countdown reaches zero. */\n readonly endText = input<string | null>(null);\n\n /**\n * Tick interval in ms. Drop to ~16 for `SSS` (millisecond display). Floored\n * at one frame — `0` (or an unparseable value) asked `setInterval` to run as\n * fast as the browser would allow, which is a busy loop, not a countdown.\n * @default 1000\n */\n readonly tickMs = input(1000, { transform: (v: unknown): number => Math.max(16, numAttr(1000)(v)) });\n\n /** Fires once when the countdown crosses zero. */\n readonly countdownEnd = output<void>();\n\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n private readonly targetMs = computed(() => toMs(this.target()));\n\n /**\n * Milliseconds left, or `null` when `target` does not parse to a date at all.\n * `new Date('nope').getTime()` is `NaN`, and `NaN` propagated all the way to\n * the screen as `NaN:NaN:NaN` — and, worse, `tick` compared it to `0` and so\n * never fired `countdownEnd`, while a guard that only clamped the text would\n * have fired it immediately for a target that was never reached.\n */\n private remainingMs(): number | null {\n const target = this.targetMs();\n return Number.isFinite(target) ? Math.max(0, target - Date.now()) : null;\n }\n\n /** Remaining milliseconds (live signal). */\n protected readonly remaining = signal(0);\n protected readonly finished = signal(false);\n\n protected readonly display = computed(() => {\n if (this.finished() && this.endText() != null) return this.endText()!;\n return formatRemaining(this.remaining(), this.format());\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('statistic');\n // Seed once synchronously so SSR / first paint shows a sane value.\n effect(() => {\n const ms = this.remainingMs();\n this.remaining.set(ms ?? 0);\n this.finished.set(ms === 0);\n });\n\n if (!this.isBrowser) return;\n\n // The interval is REBUILT when `tickMs` changes, which is what makes the\n // input bindable rather than an authoring-time constant. Read once from\n // inside `afterNextRender` it was a plain, untracked read, so\n // `[tickMs]=\"precise() ? 16 : 1000\"` kept whatever period the first frame\n // saw and nothing looked wrong — the countdown still counted. Same shape\n // `wr-rotating-text` uses for its own rotation period; the `onCleanup` is\n // what keeps a period change from leaving the old interval running beside\n // the new one.\n effect(onCleanup => {\n const handle = setInterval(() => this.tick(), this.tickMs());\n onCleanup(() => clearInterval(handle));\n });\n }\n\n private tick(): void {\n const ms = this.remainingMs();\n if (ms === null) return;\n this.remaining.set(ms);\n if (ms === 0 && !this.finished()) {\n this.finished.set(true);\n this.countdownEnd.emit();\n }\n }\n}\n","@if (label()) {\n <div class=\"wr-statistic__label\">{{ label() }}</div>\n}\n<div class=\"wr-statistic__value\">\n <span class=\"wr-statistic__number\">{{ display() }}</span>\n</div>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Dashboard grid for `<wr-statistic>` cards. The column count follows the\n * group's OWN width — an intrinsic container-query grid sized by its box, not\n * a viewport media query — so it reflows correctly inside any column, card, or\n * split pane. Columns are never narrower than `min`; `columns` optionally caps\n * how many ever sit side by side on a wide container.\n *\n * @example\n * ```html\n * <wr-statistic-group [columns]=\"4\" min=\"11rem\">\n * <wr-statistic label=\"Active users\" [value]=\"12345\" />\n * <wr-statistic label=\"Revenue\" [value]=\"9512\" prefix=\"$\" [delta]=\"12.4\" />\n * <wr-statistic label=\"Churn\" [value]=\"1.8\" suffix=\"%\" [delta]=\"-0.4\" />\n * <wr-statistic label=\"Sessions\" [value]=\"48210\" />\n * </wr-statistic-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/statistic\n */\n@Component({\n selector: 'wr-statistic-group',\n template: '<div class=\"wr-statistic-group__grid\"><ng-content /></div>',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-statistic-group',\n '[style.--wr-statistic-group-min]': 'min()',\n '[style.--wr-statistic-group-columns]': 'columns() || null',\n },\n})\nexport class WrStatisticGroup {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('statistic');\n }\n\n /**\n * Minimum width of each column before the grid reflows to fewer columns.\n * Any CSS length — smaller packs more cards per row. @default '12rem'\n */\n readonly min = input<string>('12rem');\n\n /**\n * Cap on how many columns ever sit side by side on a wide container. `0`\n * (default) leaves it uncapped — fit as many `min`-wide columns as the\n * width allows. @default 0\n */\n readonly columns = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAM,gBAAgB;AA0BtB,IAAa,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OAAO,cAAc,eAAe,WAAW,cAAc,WAAW;CAC9E;CAMS,MAAM,MAAc,SAAQ,GAAA,YAAA,CAAA,EAAA,WAAA,MAAA,CAAA,+BAAA,CAAA,CAAA;CAO5B,UAAU,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,KAAK,IAAI,GAAG,qBAAqB,GAAG,CAAC,CAAC;CAAC,CAAA;CAhB7F,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAgB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAhB,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAgB,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,KAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA;GAAA,YAAA;IAAA,kCAAA;IAAA,sCAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UARjB;EAA4D,UAAA;EAAA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AAQ3D,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgB,YAAA,CAAA;EAV5B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,eAAe,kBAAkB;GACjC,MAAM;IACJ,OAAO;IACP,oCAAoC;IACpC,wCAAwC;GACzC;EACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-statistic.mjs","names":[],"sources":["../../../projects/lib/statistic/statistic.ts","../../../projects/lib/statistic/statistic.html","../../../projects/lib/statistic/statistic-countdown.ts","../../../projects/lib/statistic/statistic-countdown.html","../../../projects/lib/statistic/statistic-group.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 { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n LOCALE_ID,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WrCountUp } from 'ngwr/counter';\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\n/** Digits with one optional point and a sign: the form `Intl` reads exactly. */\nconst PLAIN_DECIMAL = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)$/;\n\n/**\n * KPI card — label + big number + optional prefix/suffix + delta. Pair\n * with `<wr-statistic-group>` for a responsive dashboard grid.\n *\n * When `value` is numeric the number counts up (eased) from its previous\n * value to the new one on every change — see `animate`. String values and\n * `prefers-reduced-motion` render instantly.\n *\n * @example\n * ```html\n * <wr-statistic label=\"Active users\" [value]=\"12345\" suffix=\"users\" />\n * <wr-statistic label=\"Revenue\" [value]=\"9512\" prefix=\"$\" [delta]=\"12.4\" />\n * <wr-statistic label=\"Churn\" [value]=\"1.8\" suffix=\"%\" [precision]=\"1\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/statistic\n */\n@Component({\n selector: 'wr-statistic',\n templateUrl: './statistic.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-statistic' },\n imports: [WrCountUp],\n})\nexport class WrStatistic {\n private readonly platform = inject(WrPlatform);\n private readonly locale = inject(LOCALE_ID);\n\n /**\n * The caption above the figure — what the number counts. Keep it short; the\n * value is the thing being read, and this names it.\n */\n readonly label = input<string>('');\n\n /** The number (or string) to display in the main slot. */\n readonly value = input<number | string | null>(null);\n\n /** Prefix glyph / symbol (e.g. `'$'`). */\n readonly prefix = input<string>('');\n\n /** Suffix glyph / unit (e.g. `'%'`, `'kg'`). */\n readonly suffix = input<string>('');\n\n /** Fixed number of decimals applied to numeric values. @default 0 */\n readonly precision = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /**\n * Count up to a new numeric `value` instead of swapping instantly. Always\n * off for string values or under `prefers-reduced-motion`. @default true\n */\n readonly animate = input(true, { transform: coerceBooleanProperty });\n\n /** Count-up duration (ms). @default 700 */\n readonly duration = input(700, { transform: wrNumAttr(700) });\n\n /**\n * The current value coerced to a finite number, or `null` when `value` is\n * a non-numeric string / empty / nullish (rendered as-is).\n */\n protected readonly numericValue = computed<number | null>(() => {\n const raw = this.value();\n if (raw === null || raw === '') return null;\n const n = typeof raw === 'number' ? raw : coerceNumberProperty(raw, Number.NaN);\n return Number.isFinite(n) ? n : null;\n });\n\n /** Whether the value should count up (browser, numeric, opted-in, motion allowed). */\n protected readonly animated = computed<boolean>(\n () =>\n this.platform.isBrowser &&\n this.animate() &&\n !this.platform.prefersReducedMotion() &&\n typeof this.value() === 'number' &&\n this.numericValue() !== null\n );\n\n /** Animation start — the previously-rendered numeric value (0 on first paint). */\n protected readonly animateFrom = signal(0);\n\n /** Bookkeeping: the last numeric value seen, fed back as the next `from`. */\n private readonly lastNumeric = signal(0);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('statistic');\n // Whenever the numeric value changes, snapshot the prior value as the\n // count-up start, then remember the new one for the next transition.\n effect(() => {\n const next = this.numericValue();\n if (next === null) return;\n untracked(() => {\n this.animateFrom.set(this.lastNumeric());\n this.lastNumeric.set(next);\n });\n });\n }\n\n /**\n * Static (non-animated) display string. Numeric values honour `precision`\n * and locale grouping so they match the count-up output; everything else\n * renders verbatim with an em-dash fallback.\n */\n protected readonly displayValue = computed<string>(() => {\n const n = this.numericValue();\n if (n !== null) {\n // A plain decimal string is formatted as it is, the way `wrNumber` does it,\n // so a long amount keeps every digit. `format()` has taken a string since\n // ES2023, though the ES2022 lib types it as a number only.\n const raw = typeof this.value() === 'string' ? String(this.value()).trim() : '';\n return new Intl.NumberFormat(this.locale, {\n minimumFractionDigits: this.precision(),\n maximumFractionDigits: this.precision(),\n }).format(PLAIN_DECIMAL.test(raw) ? (raw as unknown as number) : n);\n }\n // `numericValue` above already reads `''` as \"no value\"; rendering it\n // verbatim put an empty card on screen instead of the placeholder.\n const raw = this.value();\n return raw === null || raw === undefined || raw === '' ? '—' : String(raw);\n });\n\n /**\n * Optional delta vs previous period — shown as `+x.x%` (or `-x.x%`).\n * Use `deltaSuffix` to change the trailing unit.\n */\n readonly delta = input<number | null>(null, {\n transform: (v: unknown): number | null => {\n if (v === null || v === undefined || v === '') return null;\n const n = coerceNumberProperty(v, Number.NaN);\n return Number.isFinite(n) ? n : null;\n },\n });\n\n // The default moved from the literal `'%'` to `null` so the catalog gets a\n // say. `%` is a string the LIBRARY owns and no locale could reach: a locale\n // that writes it differently — or writes it as a word — had nowhere to put\n // that but a per-instance binding on every `<wr-statistic>` on the page. A\n // bound value still wins, exactly as before, which is what makes this safe.\n /** Unit appended to the delta value. Falls back to `statistic.deltaSuffix`, then `'%'`. */\n readonly deltaSuffix = input<string | null>(null);\n\n protected readonly hasDelta = computed(() => this.delta() !== null);\n\n protected readonly deltaDirection = computed<'up' | 'down' | 'flat'>(() => {\n const d = this.delta();\n if (d === null || d === 0) return 'flat';\n return d > 0 ? 'up' : 'down';\n });\n\n protected readonly resolvedDeltaSuffix = useI18nText(this.deltaSuffix, 'statistic.deltaSuffix', '%');\n\n /** `{{value}}{{suffix}}` — the join, so a locale owns the space before the unit. */\n private readonly deltaFormat = useI18nFormatter('statistic.delta', '{{value}}{{suffix}}');\n\n /**\n * The delta chip, e.g. `+12.4%`.\n *\n * It was `` `${sign}${d}${suffix}` ``, printed one line under a value that\n * goes through `Intl.NumberFormat` — so the two disagreed inside one\n * component: ar-SA showed `١٬٢٣٤٬٥٦٧٫٨٩` above a Latin `12.4%`, and de-DE\n * `1.234.567,89` above `+12.4%`. The sign comes from `signDisplay`, which also\n * fixes the RTL half of it: `+` written by hand is a neutral character that\n * the BiDi algorithm moves to the other end of the number.\n *\n * The digit count is taken from the number rather than from `precision()`,\n * which describes the VALUE and not the delta — so what renders is the same\n * digits as before, in the locale's own numerals. One exception, and it is an\n * improvement rather than a regression: a magnitude JavaScript prints in\n * exponent notation (`1e-7`, `1e+21`) used to reach the DOM that way and is\n * now formatted as a number.\n */\n protected readonly deltaText = computed(() => {\n const d = this.delta();\n if (d === null) return '';\n const decimals = Math.min(20, (String(Math.abs(d)).split('.')[1] ?? '').length);\n const value = new Intl.NumberFormat(this.locale, {\n signDisplay: 'exceptZero',\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n }).format(d);\n return this.deltaFormat({ value, suffix: this.resolvedDeltaSuffix() });\n });\n}\n","@if (label()) {\n <div class=\"wr-statistic__label\">{{ label() }}</div>\n}\n<div class=\"wr-statistic__value\">\n @if (prefix()) {\n <span class=\"wr-statistic__prefix\">{{ prefix() }}</span>\n }\n @if (animated()) {\n <wr-count-up\n class=\"wr-statistic__number\"\n [from]=\"animateFrom()\"\n [to]=\"numericValue() ?? 0\"\n [decimals]=\"precision()\"\n [duration]=\"duration()\"\n />\n } @else {\n <span class=\"wr-statistic__number\">{{ displayValue() }}</span>\n }\n @if (suffix()) {\n <span class=\"wr-statistic__suffix\">{{ suffix() }}</span>\n }\n</div>\n@if (hasDelta()) {\n <div [class]=\"`wr-statistic__delta wr-statistic__delta--${deltaDirection()}`\">\n @if (deltaDirection() === 'up') {\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" aria-hidden=\"true\">\n <path d=\"M5 1 L9 8 L1 8 Z\" fill=\"currentColor\" />\n </svg>\n } @else if (deltaDirection() === 'down') {\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" aria-hidden=\"true\">\n <path d=\"M5 9 L9 2 L1 2 Z\" fill=\"currentColor\" />\n </svg>\n }\n <span>{{ deltaText() }}</span>\n </div>\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 { isPlatformBrowser } from '@angular/common';\nimport {\n Component,\n PLATFORM_ID,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n output,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { type WrDurationUnit, wrSplitDuration } from 'ngwr/pipes';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\n// Helpers\n\nfunction toMs(value: Date | string | number): number {\n if (value instanceof Date) return value.getTime();\n if (typeof value === 'number') return value;\n return new Date(value).getTime();\n}\n\nfunction pad(n: number, width: number): string {\n return String(n).padStart(width, '0');\n}\n\n/**\n * The format's tokens, longest first inside the alternation so `DD` beats `D`,\n * `HH` beats `H`, `mm` beats `m` and `SSS` beats `ss` beats `s`. Matched in one pass\n * so the output is never re-scanned: a sequential `.replace()` chain turned\n * `D days HH:mm:ss` into `1 day42 11:59:42`, its last `/s/g` step re-matching the\n * literal `s` inside `days`.\n */\nconst TOKEN = /(?<![A-Za-z])(?:SSS|DD|HH|mm|ss|D|H|m|s)(?![A-Za-z])/g;\n\n/** The unit each token's letter stands for. */\nconst UNIT_OF: Readonly<Record<string, WrDurationUnit>> = {\n D: 'day',\n H: 'hour',\n m: 'minute',\n s: 'second',\n S: 'millisecond',\n};\n\n/**\n * A unit the format does not show is carried into the next larger one it does:\n * `HH:mm:ss` with three days left reads `73:00:00`. Every unit was taken modulo\n * the next one whatever the format held, so the default format dropped whole days\n * and showed `00:59:59` for three days and an hour. The split itself is\n * `wrSplitDuration`, shared with `wrDuration`.\n */\nfunction formatRemaining(ms: number, fmt: string): string {\n const shown = new Set((fmt.match(TOKEN) ?? []).map(token => UNIT_OF[token[0]]));\n const value = wrSplitDuration(ms, shown);\n return fmt.replace(TOKEN, token => {\n const n = value[UNIT_OF[token[0]]] ?? 0;\n return token === 'SSS' ? pad(n, 3) : token.length === 2 ? pad(n, 2) : String(n);\n });\n}\n\n/**\n * Live-counting variant of `<wr-statistic>` that targets a future date\n * and ticks down to zero. The format string uses Day/Hour/Minute/Second\n * tokens (`D`, `H`, `m`, `s`, double for zero-padded, plus `SSS` for\n * milliseconds).\n *\n * @example\n * ```html\n * <wr-statistic-countdown\n * label=\"Launch in\"\n * [target]=\"launchDate\"\n * format=\"D days HH:mm:ss\"\n * (countdownEnd)=\"onLive()\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/statistic\n */\n@Component({\n selector: 'wr-statistic-countdown',\n templateUrl: './statistic-countdown.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-statistic' },\n})\nexport class WrStatisticCountdown {\n /** Target date / timestamp the countdown is running down to. */\n readonly target = input.required<Date | string | number>();\n\n /** Label rendered above the value. */\n readonly label = input<string>('');\n\n /**\n * Format string. Tokens: `D`/`DD` (days), `H`/`HH` (hours),\n * `m`/`mm` (minutes), `s`/`ss` (seconds), `SSS` (milliseconds).\n * Double-letter forms zero-pad to width 2. A unit the format leaves out is\n * carried into the next larger one it shows, so `HH:mm:ss` reads `73:00:00`\n * with three days and an hour left. @default 'HH:mm:ss'\n */\n readonly format = input<string>('HH:mm:ss');\n\n /** Optional text shown once the countdown reaches zero. */\n readonly endText = input<string | null>(null);\n\n /**\n * Tick interval in ms. Drop to ~16 for `SSS` (millisecond display). Floored\n * at one frame — `0` (or an unparseable value) asked `setInterval` to run as\n * fast as the browser would allow, which is a busy loop, not a countdown.\n * @default 1000\n */\n readonly tickMs = input(1000, { transform: (v: unknown): number => Math.max(16, wrNumAttr(1000)(v)) });\n\n /**\n * Fires once for each target that is reached, or that has already passed when\n * it is set, mount included, so an app reloaded after expiry still hears it.\n * A new future target counts down again and fires again.\n */\n readonly countdownEnd = output<void>();\n\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n private readonly targetMs = computed(() => toMs(this.target()));\n\n /**\n * Milliseconds left, or `null` when `target` does not parse to a date at all.\n * `new Date('nope').getTime()` is `NaN`, and `NaN` propagated all the way to\n * the screen as `NaN:NaN:NaN` — and, worse, `tick` compared it to `0` and so\n * never fired `countdownEnd`, while a guard that only clamped the text would\n * have fired it immediately for a target that was never reached.\n */\n private remainingMs(): number | null {\n const target = this.targetMs();\n return Number.isFinite(target) ? Math.max(0, target - Date.now()) : null;\n }\n\n /** Remaining milliseconds (live signal). */\n protected readonly remaining = signal(0);\n protected readonly finished = signal(false);\n\n protected readonly display = computed(() => {\n if (this.finished() && this.endText() != null) return this.endText()!;\n return formatRemaining(this.remaining(), this.format());\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('statistic');\n // Seed once synchronously so SSR / first paint shows a sane value.\n effect(() => {\n const ms = this.remainingMs();\n this.remaining.set(ms ?? 0);\n this.finished.set(ms === 0);\n // A target already past never crosses zero in `tick`, so it ends here.\n if (ms === 0) untracked(() => this.countdownEnd.emit());\n });\n\n if (!this.isBrowser) return;\n\n // The interval is REBUILT when `tickMs` changes, which is what makes the\n // input bindable rather than an authoring-time constant. Read once from\n // inside `afterNextRender` it was a plain, untracked read, so\n // `[tickMs]=\"precise() ? 16 : 1000\"` kept whatever period the first frame\n // saw and nothing looked wrong — the countdown still counted. Same shape\n // `wr-rotating-text` uses for its own rotation period; the `onCleanup` is\n // what keeps a period change from leaving the old interval running beside\n // the new one.\n effect(onCleanup => {\n if (this.finished()) return;\n const handle = setInterval(() => this.tick(), this.tickMs());\n onCleanup(() => clearInterval(handle));\n });\n }\n\n private tick(): void {\n const ms = this.remainingMs();\n if (ms === null) return;\n this.remaining.set(ms);\n if (ms === 0 && !this.finished()) {\n this.finished.set(true);\n this.countdownEnd.emit();\n }\n }\n}\n","@if (label()) {\n <div class=\"wr-statistic__label\">{{ label() }}</div>\n}\n<div class=\"wr-statistic__value\">\n <span class=\"wr-statistic__number\">{{ display() }}</span>\n</div>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Dashboard grid for `<wr-statistic>` cards. The column count follows the\n * group's OWN width — an intrinsic container-query grid sized by its box, not\n * a viewport media query — so it reflows correctly inside any column, card, or\n * split pane. Columns are never narrower than `min`; `columns` optionally caps\n * how many ever sit side by side on a wide container.\n *\n * @example\n * ```html\n * <wr-statistic-group [columns]=\"4\" min=\"11rem\">\n * <wr-statistic label=\"Active users\" [value]=\"12345\" />\n * <wr-statistic label=\"Revenue\" [value]=\"9512\" prefix=\"$\" [delta]=\"12.4\" />\n * <wr-statistic label=\"Churn\" [value]=\"1.8\" suffix=\"%\" [delta]=\"-0.4\" />\n * <wr-statistic label=\"Sessions\" [value]=\"48210\" />\n * </wr-statistic-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/statistic\n */\n@Component({\n selector: 'wr-statistic-group',\n template: '<div class=\"wr-statistic-group__grid\"><ng-content /></div>',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-statistic-group',\n '[style.--wr-statistic-group-min]': 'min()',\n '[style.--wr-statistic-group-columns]': 'columns() || null',\n },\n})\nexport class WrStatisticGroup {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('statistic');\n }\n\n /**\n * Minimum width of each column before the grid reflows to fewer columns.\n * Any CSS length — smaller packs more cards per row. @default '12rem'\n */\n readonly min = input<string>('12rem');\n\n /**\n * Cap on how many columns ever sit side by side on a wide container. `0`\n * (default) leaves it uncapped — fit as many `min`-wide columns as the\n * width allows. @default 0\n */\n readonly columns = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAM,gBAAgB;AA0BtB,IAAa,cAAb,MAAa,YAAW;CACL,WA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optional");
|
|
179
179
|
completedLabel = useI18nText(NO_OVERRIDE, "stepper.completed", "completed");
|
|
180
180
|
classes = computed(() => {
|
|
181
|
-
const parts = [
|
|
181
|
+
const parts = [`wr-stepper--${this.orientation()}`];
|
|
182
182
|
if (this.linear()) parts.push("wr-stepper--linear");
|
|
183
183
|
if (this.responsive()) parts.push("wr-stepper--responsive");
|
|
184
184
|
return parts.join(" ");
|
|
@@ -267,7 +267,10 @@ var WrStepper = class WrStepper {
|
|
|
267
267
|
}
|
|
268
268
|
},
|
|
269
269
|
outputs: { active: "activeChange" },
|
|
270
|
-
host: {
|
|
270
|
+
host: {
|
|
271
|
+
properties: { "class": "classes()" },
|
|
272
|
+
classAttribute: "wr-stepper"
|
|
273
|
+
},
|
|
271
274
|
providers: [{
|
|
272
275
|
provide: WR_STEPPER,
|
|
273
276
|
useExisting: forwardRef(() => WrStepper)
|
|
@@ -292,7 +295,10 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
292
295
|
args: [{
|
|
293
296
|
selector: "wr-stepper",
|
|
294
297
|
encapsulation: ViewEncapsulation.None,
|
|
295
|
-
host: {
|
|
298
|
+
host: {
|
|
299
|
+
class: "wr-stepper",
|
|
300
|
+
"[class]": "classes()"
|
|
301
|
+
},
|
|
296
302
|
providers: [{
|
|
297
303
|
provide: WR_STEPPER,
|
|
298
304
|
useExisting: forwardRef(() => WrStepper)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-stepper.mjs","names":[],"sources":["../../../projects/lib/stepper/tokens.ts","../../../projects/lib/stepper/step.ts","../../../projects/lib/stepper/stepper.ts","../../../projects/lib/stepper/stepper.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 { InjectionToken, type Signal } from '@angular/core';\n\n/** Surface a {@link WrStepper} provides for its child `<wr-step>`s. */\nexport interface WrStepperContext {\n /** Index of the currently visible step. */\n readonly active: Signal<number>;\n /** Linear mode — steps after the latest completed one are locked. */\n readonly linear: Signal<boolean>;\n}\n\nexport const WR_STEPPER = new InjectionToken<WrStepperContext>('WR_STEPPER');\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, inject, input, signal } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_STEPPER } from './tokens';\n\n/**\n * One step in a {@link WrStepper}. Project as a child:\n *\n * ```html\n * <wr-stepper>\n * <wr-step label=\"Account\"> … </wr-step>\n * <wr-step label=\"Profile\" description=\"Optional\"> … </wr-step>\n * </wr-stepper>\n * ```\n *\n * The stepper hides every step except the active one via a host class —\n * each step still mounts once, so component state survives navigation.\n *\n * @see https://ngwr.dev/reference/components/stepper\n */\n@Component({\n selector: 'wr-step',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-step',\n '[class.wr-step--active]': 'isActive()',\n },\n})\nexport class WrStep {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('stepper');\n }\n\n /** Header label. */\n readonly label = input<string>('');\n\n /** Secondary text shown under the label. */\n readonly description = input<string>('');\n\n /** Marks the step as optional in the header. */\n readonly optional = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Override completion state. When unset, the stepper auto-derives it\n * from the active index (any step before `active` is completed).\n */\n readonly completed = input<boolean | null>(null);\n\n /** Disables the header — also blocks header clicks. */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Stepper-assigned index. Set by the parent when contentChildren updates. */\n readonly _index = signal(-1);\n\n private readonly stepper = inject(WR_STEPPER);\n\n protected readonly isActive = computed(() => this._index() === this.stepper.active());\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 ViewEncapsulation,\n computed,\n contentChildren,\n effect,\n forwardRef,\n input,\n model,\n signal,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrStep } from './step';\nimport { WR_STEPPER, type WrStepperContext } from './tokens';\n\n/** A label with no consumer input to forward — see `optionalLabel` below. */\nconst NO_OVERRIDE = signal<string | null>(null).asReadonly();\n\n/**\n * Multi-step wizard container. Children are `<wr-step>` components — the\n * stepper renders one numbered header per step (with connectors) and the\n * body of the currently active one.\n *\n * Two-way bind `[(active)]` to the active step index. Set `linear=\"true\"`\n * to forbid jumping past incomplete steps.\n *\n * @example\n * ```html\n * <wr-stepper [(active)]=\"step\" linear>\n * <wr-step label=\"Account\">…</wr-step>\n * <wr-step label=\"Profile\">…</wr-step>\n * <wr-step label=\"Confirm\">…</wr-step>\n * </wr-stepper>\n * ```\n *\n * @see https://ngwr.dev/reference/components/stepper\n */\n@Component({\n selector: 'wr-stepper',\n templateUrl: './stepper.html',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n providers: [\n {\n provide: WR_STEPPER,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrStepper),\n },\n ],\n})\nexport class WrStepper implements WrStepperContext {\n /** Index of the currently visible step. */\n readonly active = model(0);\n\n /** Layout direction. @default 'horizontal' */\n readonly orientation = input<'horizontal' | 'vertical'>('horizontal');\n\n /** Lock steps after the latest completed one. @default false */\n readonly linear = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Drop a horizontal stepper to a vertical layout when its own box is too\n * narrow for the row (a container query on its own width, not the\n * viewport — so it adapts inside a narrow column or side panel). No effect\n * when `orientation` is already `vertical`. @default false\n */\n readonly responsive = input(false, { transform: coerceBooleanProperty });\n\n protected readonly steps = contentChildren(WrStep);\n\n /**\n * The \"optional\" badge sits INSIDE the header button's label span, so the word\n * is part of the step's accessible name — a hard-coded literal announced English\n * to every locale, not just showed it. Catalog-only rather than an input: the\n * badge is one word shared by every step, and an app that wants other wording\n * overrides `stepper.optional` once instead of on every `<wr-step>`.\n */\n protected readonly optionalLabel = useI18nText(NO_OVERRIDE, 'stepper.optional', 'optional');\n\n /**\n * The check mark that replaces a completed step's number is `aria-hidden`, so\n * the state it draws reached nobody who cannot see it. This word goes into the\n * header button's name instead, visually hidden. Catalog-only, for the reason\n * `optionalLabel` is.\n */\n protected readonly completedLabel = useI18nText(NO_OVERRIDE, 'stepper.completed', 'completed');\n\n protected readonly classes = computed(() => {\n const parts = ['wr-stepper', `wr-stepper--${this.orientation()}`];\n if (this.linear()) parts.push('wr-stepper--linear');\n if (this.responsive()) parts.push('wr-stepper--responsive');\n return parts.join(' ');\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('stepper');\n // Push each step's index down so it can compute its own active state.\n effect(() => {\n this.steps().forEach((step, i) => step._index.set(i));\n });\n\n // `active` is a plain `model`, so `[(active)]` and an `@if`-shrunk step list\n // both write into it unchecked — only `goTo` clamped. Out of range no step\n // matches `.wr-step--active`, and since `.wr-step` is `display: none` until it\n // does, the stepper renders its header row over an empty body with no header\n // carrying `aria-current=\"step\"`. Same guard as `wr-carousel`; the `last < 0`\n // return keeps it quiet until `contentChildren` resolves.\n effect(() => {\n const last = this.steps().length - 1;\n if (last < 0) return;\n const clamped = Math.min(Math.max(0, this.active()), last);\n if (clamped !== this.active()) this.active.set(clamped);\n });\n }\n\n /** Is the step at `index` considered completed? */\n protected isCompleted(index: number): boolean {\n const override = this.steps()[index]?.completed();\n if (override !== null && override !== undefined) return override;\n return index < this.active();\n }\n\n /** Is the step at `index` reachable for direct header clicks? */\n protected isReachable(index: number): boolean {\n if (this.steps()[index]?.disabled()) return false;\n if (!this.linear()) return true;\n if (index <= this.active()) return true;\n for (let i = 0; i < index; i++) {\n if (!this.isCompleted(i)) return false;\n }\n return true;\n }\n\n protected onHeaderClick(index: number): void {\n if (this.isReachable(index)) this.goTo(index);\n }\n\n // Imperative API\n\n goTo(index: number): void {\n const last = this.steps().length - 1;\n if (last < 0) return;\n const clamped = Math.min(Math.max(0, index), last);\n this.active.set(clamped);\n }\n\n next(): void {\n this.goTo(this.active() + 1);\n }\n\n prev(): void {\n this.goTo(this.active() - 1);\n }\n}\n","<ol class=\"wr-stepper__headers\" role=\"list\">\n @for (step of steps(); track $index) {\n <li\n class=\"wr-stepper__header\"\n [class.wr-stepper__header--active]=\"$index === active()\"\n [class.wr-stepper__header--completed]=\"isCompleted($index)\"\n [class.wr-stepper__header--reachable]=\"isReachable($index)\"\n [class.wr-stepper__header--disabled]=\"step.disabled()\"\n >\n <button\n type=\"button\"\n class=\"wr-stepper__header-button\"\n [disabled]=\"!isReachable($index) || step.disabled()\"\n [attr.aria-current]=\"$index === active() ? 'step' : null\"\n (click)=\"onHeaderClick($index)\"\n >\n <span class=\"wr-stepper__indicator\" aria-hidden=\"true\">\n @if (isCompleted($index)) {\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\">\n <path\n d=\"M3 7.5 L6 10.5 L11 4.5\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.75\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n } @else {\n {{ $index + 1 }}\n }\n </span>\n <span class=\"wr-stepper__label\">\n {{ step.label() }}\n @if (isCompleted($index)) {\n <span class=\"wr-stepper__sr-only\"> {{ completedLabel() }} </span>\n }\n @if (step.optional()) {\n <small class=\"wr-stepper__optional\">{{ optionalLabel() }}</small>\n }\n @if (step.description()) {\n <small class=\"wr-stepper__description\">{{ step.description() }}</small>\n }\n </span>\n </button>\n @if (!$last) {\n <span class=\"wr-stepper__connector\" aria-hidden=\"true\"></span>\n }\n </li>\n }\n</ol>\n\n<div class=\"wr-stepper__body\">\n <ng-content />\n</div>\n"],"mapp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;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EAbrB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAY,eAEP,kBAAkB;GAAI,MAC/B,EAAE,WAAW,YAAW;GAAE,WACrB,CACT;IACE,SAAS;IAET,aAAa,iBAAgB,SAAU;GACxC,CACF;GAAA,UAAA;EAAA,CAAA;CAoB0C,CAAA;CAAA,sBAAA,CAAA;CAAA,gBAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,cAAA;EAAA,CAAA;EAAA,aAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,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,GAAA,iBAAA,MAAM,GAAA,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-stepper.mjs","names":[],"sources":["../../../projects/lib/stepper/tokens.ts","../../../projects/lib/stepper/step.ts","../../../projects/lib/stepper/stepper.ts","../../../projects/lib/stepper/stepper.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 { InjectionToken, type Signal } from '@angular/core';\n\n/** Surface a {@link WrStepper} provides for its child `<wr-step>`s. */\nexport interface WrStepperContext {\n /** Index of the currently visible step. */\n readonly active: Signal<number>;\n /** Linear mode — steps after the latest completed one are locked. */\n readonly linear: Signal<boolean>;\n}\n\nexport const WR_STEPPER = new InjectionToken<WrStepperContext>('WR_STEPPER');\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, inject, input, signal } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_STEPPER } from './tokens';\n\n/**\n * One step in a {@link WrStepper}. Project as a child:\n *\n * ```html\n * <wr-stepper>\n * <wr-step label=\"Account\"> … </wr-step>\n * <wr-step label=\"Profile\" description=\"Optional\"> … </wr-step>\n * </wr-stepper>\n * ```\n *\n * The stepper hides every step except the active one via a host class —\n * each step still mounts once, so component state survives navigation.\n *\n * @see https://ngwr.dev/reference/components/stepper\n */\n@Component({\n selector: 'wr-step',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-step',\n '[class.wr-step--active]': 'isActive()',\n },\n})\nexport class WrStep {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('stepper');\n }\n\n /** Header label. */\n readonly label = input<string>('');\n\n /** Secondary text shown under the label. */\n readonly description = input<string>('');\n\n /** Marks the step as optional in the header. */\n readonly optional = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Override completion state. When unset, the stepper auto-derives it\n * from the active index (any step before `active` is completed).\n */\n readonly completed = input<boolean | null>(null);\n\n /** Disables the header — also blocks header clicks. */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Stepper-assigned index. Set by the parent when contentChildren updates. */\n readonly _index = signal(-1);\n\n private readonly stepper = inject(WR_STEPPER);\n\n protected readonly isActive = computed(() => this._index() === this.stepper.active());\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 ViewEncapsulation,\n computed,\n contentChildren,\n effect,\n forwardRef,\n input,\n model,\n signal,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrStep } from './step';\nimport { WR_STEPPER, type WrStepperContext } from './tokens';\n\n/** A label with no consumer input to forward — see `optionalLabel` below. */\nconst NO_OVERRIDE = signal<string | null>(null).asReadonly();\n\n/**\n * Multi-step wizard container. Children are `<wr-step>` components — the\n * stepper renders one numbered header per step (with connectors) and the\n * body of the currently active one.\n *\n * Two-way bind `[(active)]` to the active step index. Set `linear=\"true\"`\n * to forbid jumping past incomplete steps.\n *\n * @example\n * ```html\n * <wr-stepper [(active)]=\"step\" linear>\n * <wr-step label=\"Account\">…</wr-step>\n * <wr-step label=\"Profile\">…</wr-step>\n * <wr-step label=\"Confirm\">…</wr-step>\n * </wr-stepper>\n * ```\n *\n * @see https://ngwr.dev/reference/components/stepper\n */\n@Component({\n selector: 'wr-stepper',\n templateUrl: './stepper.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-stepper', '[class]': 'classes()' },\n providers: [\n {\n provide: WR_STEPPER,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrStepper),\n },\n ],\n})\nexport class WrStepper implements WrStepperContext {\n /** Index of the currently visible step. */\n readonly active = model(0);\n\n /** Layout direction. @default 'horizontal' */\n readonly orientation = input<'horizontal' | 'vertical'>('horizontal');\n\n /** Lock steps after the latest completed one. @default false */\n readonly linear = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Drop a horizontal stepper to a vertical layout when its own box is too\n * narrow for the row (a container query on its own width, not the\n * viewport — so it adapts inside a narrow column or side panel). No effect\n * when `orientation` is already `vertical`. @default false\n */\n readonly responsive = input(false, { transform: coerceBooleanProperty });\n\n protected readonly steps = contentChildren(WrStep);\n\n /**\n * The \"optional\" badge sits INSIDE the header button's label span, so the word\n * is part of the step's accessible name — a hard-coded literal announced English\n * to every locale, not just showed it. Catalog-only rather than an input: the\n * badge is one word shared by every step, and an app that wants other wording\n * overrides `stepper.optional` once instead of on every `<wr-step>`.\n */\n protected readonly optionalLabel = useI18nText(NO_OVERRIDE, 'stepper.optional', 'optional');\n\n /**\n * The check mark that replaces a completed step's number is `aria-hidden`, so\n * the state it draws reached nobody who cannot see it. This word goes into the\n * header button's name instead, visually hidden. Catalog-only, for the reason\n * `optionalLabel` is.\n */\n protected readonly completedLabel = useI18nText(NO_OVERRIDE, 'stepper.completed', 'completed');\n\n protected readonly classes = computed(() => {\n const parts = [`wr-stepper--${this.orientation()}`];\n if (this.linear()) parts.push('wr-stepper--linear');\n if (this.responsive()) parts.push('wr-stepper--responsive');\n return parts.join(' ');\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('stepper');\n // Push each step's index down so it can compute its own active state.\n effect(() => {\n this.steps().forEach((step, i) => step._index.set(i));\n });\n\n // `active` is a plain `model`, so `[(active)]` and an `@if`-shrunk step list\n // both write into it unchecked — only `goTo` clamped. Out of range no step\n // matches `.wr-step--active`, and since `.wr-step` is `display: none` until it\n // does, the stepper renders its header row over an empty body with no header\n // carrying `aria-current=\"step\"`. Same guard as `wr-carousel`; the `last < 0`\n // return keeps it quiet until `contentChildren` resolves.\n effect(() => {\n const last = this.steps().length - 1;\n if (last < 0) return;\n const clamped = Math.min(Math.max(0, this.active()), last);\n if (clamped !== this.active()) this.active.set(clamped);\n });\n }\n\n /** Is the step at `index` considered completed? */\n protected isCompleted(index: number): boolean {\n const override = this.steps()[index]?.completed();\n if (override !== null && override !== undefined) return override;\n return index < this.active();\n }\n\n /** Is the step at `index` reachable for direct header clicks? */\n protected isReachable(index: number): boolean {\n if (this.steps()[index]?.disabled()) return false;\n if (!this.linear()) return true;\n if (index <= this.active()) return true;\n for (let i = 0; i < index; i++) {\n if (!this.isCompleted(i)) return false;\n }\n return true;\n }\n\n protected onHeaderClick(index: number): void {\n if (this.isReachable(index)) this.goTo(index);\n }\n\n // Imperative API\n\n goTo(index: number): void {\n const last = this.steps().length - 1;\n if (last < 0) return;\n const clamped = Math.min(Math.max(0, index), last);\n this.active.set(clamped);\n }\n\n next(): void {\n this.goTo(this.active() + 1);\n }\n\n prev(): void {\n this.goTo(this.active() - 1);\n }\n}\n","<ol class=\"wr-stepper__headers\" role=\"list\">\n @for (step of steps(); track $index) {\n <li\n class=\"wr-stepper__header\"\n [class.wr-stepper__header--active]=\"$index === active()\"\n [class.wr-stepper__header--completed]=\"isCompleted($index)\"\n [class.wr-stepper__header--reachable]=\"isReachable($index)\"\n [class.wr-stepper__header--disabled]=\"step.disabled()\"\n >\n <button\n type=\"button\"\n class=\"wr-stepper__header-button\"\n [disabled]=\"!isReachable($index) || step.disabled()\"\n [attr.aria-current]=\"$index === active() ? 'step' : null\"\n (click)=\"onHeaderClick($index)\"\n >\n <span class=\"wr-stepper__indicator\" aria-hidden=\"true\">\n @if (isCompleted($index)) {\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\">\n <path\n d=\"M3 7.5 L6 10.5 L11 4.5\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.75\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n } @else {\n {{ $index + 1 }}\n }\n </span>\n <span class=\"wr-stepper__label\">\n {{ step.label() }}\n @if (isCompleted($index)) {\n <span class=\"wr-stepper__sr-only\"> {{ completedLabel() }} </span>\n }\n @if (step.optional()) {\n <small class=\"wr-stepper__optional\">{{ optionalLabel() }}</small>\n }\n @if (step.description()) {\n <small class=\"wr-stepper__description\">{{ step.description() }}</small>\n }\n </span>\n </button>\n @if (!$last) {\n <span class=\"wr-stepper__connector\" aria-hidden=\"true\"></span>\n }\n </li>\n }\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AAA,GAAA,kBAAA;CAAA,CAAA;;ADMa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EAbrB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAY,eAEP,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAc,WAAW;GAAW;GAAE,WAC1C,CACT;IACE,SAAS;IAET,aAAa,iBAAgB,SAAU;GACxC,CACF;GAAA,UAAA;EAAA,CAAA;CAoB0C,CAAA;CAAA,sBAAA,CAAA;CAAA,gBAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,cAAA;EAAA,CAAA;EAAA,aAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,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,GAAA,iBAAA,MAAM,GAAA,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -33,7 +33,7 @@ function probe(engine) {
|
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function wrCreateMemoryStorage() {
|
|
37
37
|
const map = /* @__PURE__ */ new Map();
|
|
38
38
|
return {
|
|
39
39
|
get length() {
|
|
@@ -59,8 +59,10 @@ function createMemoryStorage() {
|
|
|
59
59
|
const WR_STORAGE_ENGINE = new InjectionToken("WR_STORAGE_ENGINE", {
|
|
60
60
|
providedIn: "root",
|
|
61
61
|
factory: () => {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
try {
|
|
63
|
+
if (typeof localStorage !== "undefined" && probe(localStorage)) return localStorage;
|
|
64
|
+
} catch {}
|
|
65
|
+
return wrCreateMemoryStorage();
|
|
64
66
|
}
|
|
65
67
|
});
|
|
66
68
|
/**
|
|
@@ -251,6 +253,6 @@ function withStorage(options = {}) {
|
|
|
251
253
|
});
|
|
252
254
|
return wrFeature("storage", providers);
|
|
253
255
|
}
|
|
254
|
-
export { DEFAULT_WR_STORAGE_CONFIG, WR_STORAGE_CONFIG, WR_STORAGE_ENGINE, WrStorage,
|
|
256
|
+
export { DEFAULT_WR_STORAGE_CONFIG, WR_STORAGE_CONFIG, WR_STORAGE_ENGINE, WrStorage, withStorage, wrCreateMemoryStorage };
|
|
255
257
|
|
|
256
258
|
//# sourceMappingURL=ngwr-storage.mjs.map
|
|
@@ -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 createMemoryStorage(): 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 if (typeof localStorage === 'undefined') return createMemoryStorage();\n return probe(localStorage) ? localStorage : createMemoryStorage();\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;CACT;AACF;AAMA,SAAgB,sBAAmB;CACjC,MAAM,sBAAM,IAAI,IAAG;CACnB,OAAO;EACL,IAAI,SAAM;GACR,OAAO,IAAI;EACb;EACA,QAAK;GACH,IAAI,MAAK;EACX;EACA,QAAQ,KAAW;GACjB,OAAO,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,IAAK;EACxC;EACA,IAAI,GAAS;GACX,OAAO,MAAM,KAAK,IAAI,KAAI,CAAE,CAAC,CAAC,MAAM;EACtC;EACA,WAAW,KAAW;GACpB,IAAI,OAAO,GAAG;EAChB;EACA,QAAQ,KAAa,OAAa;GAChC,IAAI,IAAI,KAAK,KAAK;EACpB;CACD;AACH;AAq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AAO,iBAAiB,WAAW,OAAO;EAQ1C,KAAK,WAAW,gBAAe;GAC7B,OAAO,oBAAoB,WAAW,OAAO;GAC7C,KAAK,oBAAoB;EAC3B,CAAC;CACH;CAjPW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAS,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAT,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAS,CAAA;;AAAT,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA,EADrB,MAAA,Q;;;;;;;;ACnCD,SAAgB,YAAY,UAA4B,CAAA,GAAE;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"}
|
|
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;CACT;AACF;AAMA,SAAgB,wBAAqB;CACnC,MAAM,sBAAM,IAAI,IAAG;CACnB,OAAO;EACL,IAAI,SAAM;GACR,OAAO,IAAI;EACb;EACA,QAAK;GACH,IAAI,MAAK;EACX;EACA,QAAQ,KAAW;GACjB,OAAO,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,I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AI5C,IAAI,MAAM,QAAQ,MAAM;IAEtB,KAAK,WAAU;IACf;GACF;GACA,MAAM,IAAI,KAAK,OAAO;GACtB,IAAI,KAAK,CAAC,MAAM,IAAI,WAAW,CAAC,GAAG;GACnC,KAAK,OAAO,IAAI,MAAM,IAAI,MAAM,EAAE,MAAM,IAAI,MAAM,GAAG;EACvD;EAEA,OAAO,iBAAiB,WAAW,OAAO;EAQ1C,KAAK,WAAW,gBAAe;GAC7B,OAAO,oBAAoB,WAAW,OAAO;GAC7C,KAAK,oBAAoB;EAC3B,CAAC;CACH;CAjPW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAS,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAT,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAS,CAAA;;AAAT,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA,EADrB,MAAA,Q;;;;;;;;ACnCD,SAAgB,YAAY,UAA4B,CAAA,GAAE;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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
2
|
import { Component, ViewEncapsulation, computed, input, model, output, viewChild } from "@angular/core";
|
|
3
3
|
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
|
4
|
-
import {
|
|
4
|
+
import { wrCheckStyles, wrRandomId } from "ngwr/utils";
|
|
5
5
|
import { useFormFieldAria } from "ngwr/form";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
@@ -14,7 +14,7 @@ var WrSwitch = class WrSwitch {
|
|
|
14
14
|
if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("switch");
|
|
15
15
|
}
|
|
16
16
|
ariaLabel = input(null, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
17
|
-
id = input(
|
|
17
|
+
id = input(wrRandomId("wr-switch"), ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
|
|
18
18
|
disabled = input(false, {
|
|
19
19
|
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
20
20
|
transform: coerceBooleanProperty
|
|
@@ -29,7 +29,7 @@ var WrSwitch = class WrSwitch {
|
|
|
29
29
|
touch = output();
|
|
30
30
|
native = viewChild.required("native", ...ngDevMode ? [{ debugName: "native" }] : /* istanbul ignore next */ []);
|
|
31
31
|
classes = computed(() => {
|
|
32
|
-
const parts = [
|
|
32
|
+
const parts = [];
|
|
33
33
|
const size = this.size();
|
|
34
34
|
if (size !== "md") parts.push(`wr-switch--${size}`);
|
|
35
35
|
if (this.checked()) parts.push("wr-switch--checked");
|
|
@@ -115,10 +115,13 @@ var WrSwitch = class WrSwitch {
|
|
|
115
115
|
checked: "checkedChange",
|
|
116
116
|
touch: "touch"
|
|
117
117
|
},
|
|
118
|
-
host: {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
host: {
|
|
119
|
+
properties: {
|
|
120
|
+
"class": "classes()",
|
|
121
|
+
"attr.id": "null"
|
|
122
|
+
},
|
|
123
|
+
classAttribute: "wr-switch"
|
|
124
|
+
},
|
|
122
125
|
viewQueries: [{
|
|
123
126
|
propertyName: "native",
|
|
124
127
|
first: true,
|
|
@@ -142,6 +145,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
142
145
|
selector: "wr-switch",
|
|
143
146
|
encapsulation: ViewEncapsulation.None,
|
|
144
147
|
host: {
|
|
148
|
+
class: "wr-switch",
|
|
145
149
|
"[class]": "classes()",
|
|
146
150
|
"[attr.id]": "null"
|
|
147
151
|
},
|