ngwr 16.4.0 → 16.6.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/back-top/styles/_index.scss +6 -0
- package/breadcrumbs/styles/_rules.scss +34 -0
- package/cascader/styles/_rules.scss +7 -0
- package/charts/bar-chart/styles/_index.scss +494 -305
- package/charts/boxplot-chart/styles/_index.scss +114 -48
- package/charts/bullet-chart/styles/_index.scss +113 -42
- package/charts/calendar-heatmap/styles/_index.scss +111 -20
- package/charts/candlestick-chart/styles/_index.scss +61 -26
- package/charts/chart-legend/styles/_index.scss +120 -10
- package/charts/core/styles/_index.scss +201 -5
- package/charts/donut-chart/styles/_index.scss +76 -21
- package/charts/funnel-chart/styles/_index.scss +66 -38
- package/charts/gauge/styles/_index.scss +12 -1
- package/charts/heatmap-chart/styles/_index.scss +90 -53
- package/charts/line-chart/styles/_index.scss +143 -139
- package/charts/meter-group/styles/_index.scss +87 -25
- package/charts/radar-chart/styles/_index.scss +82 -40
- package/charts/scatter-chart/styles/_index.scss +117 -44
- package/charts/sparkline/styles/_index.scss +7 -1
- package/charts/treemap-chart/styles/_index.scss +94 -42
- package/charts/waterfall-chart/styles/_index.scss +150 -87
- package/color-picker/styles/_index.scss +7 -3
- package/copy-value/styles/_index.scss +21 -2
- package/counter/styles/_index.scss +1 -8
- package/date-picker/styles/_index.scss +15 -9
- package/date-stamp/styles/_index.scss +2 -1
- package/dialog/styles/_index.scss +43 -0
- package/drawer/styles/_index.scss +5 -1
- package/editor/styles/_index.scss +1 -8
- package/event-calendar/styles/_index.scss +2 -6
- package/fesm2022/ngwr-affix.mjs +1 -1
- package/fesm2022/ngwr-affix.mjs.map +1 -1
- package/fesm2022/ngwr-anchor.mjs +9 -2
- package/fesm2022/ngwr-anchor.mjs.map +1 -1
- package/fesm2022/ngwr-animations-aurora.mjs.map +1 -1
- package/fesm2022/ngwr-animations-blur-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-click-sparks.mjs.map +1 -1
- package/fesm2022/ngwr-animations-confetti.mjs.map +1 -1
- package/fesm2022/ngwr-animations-decode.mjs.map +1 -1
- package/fesm2022/ngwr-animations-destruct.mjs.map +1 -1
- package/fesm2022/ngwr-animations-dot-grid.mjs.map +1 -1
- package/fesm2022/ngwr-animations-falling-letters.mjs.map +1 -1
- package/fesm2022/ngwr-animations-flow-lines.mjs.map +1 -1
- package/fesm2022/ngwr-animations-fluid-cursor.mjs.map +1 -1
- package/fesm2022/ngwr-animations-glitch.mjs.map +1 -1
- package/fesm2022/ngwr-animations-glow-border.mjs.map +1 -1
- package/fesm2022/ngwr-animations-gradient-flow.mjs.map +1 -1
- package/fesm2022/ngwr-animations-marquee.mjs.map +1 -1
- package/fesm2022/ngwr-animations-orbit.mjs.map +1 -1
- package/fesm2022/ngwr-animations-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-ripple-grid.mjs.map +1 -1
- package/fesm2022/ngwr-animations-rotate-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-shimmer.mjs.map +1 -1
- package/fesm2022/ngwr-animations-spotlight.mjs.map +1 -1
- package/fesm2022/ngwr-animations-thread-lines.mjs.map +1 -1
- package/fesm2022/ngwr-animations-tilt.mjs +20 -13
- package/fesm2022/ngwr-animations-tilt.mjs.map +1 -1
- package/fesm2022/ngwr-animations-typewriter.mjs.map +1 -1
- package/fesm2022/ngwr-breadcrumbs.mjs +40 -7
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-button.mjs +12 -3
- package/fesm2022/ngwr-button.mjs.map +1 -1
- package/fesm2022/ngwr-carousel-testing.mjs +4 -1
- package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
- package/fesm2022/ngwr-carousel.mjs +27 -2
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-cascader-testing.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +72 -8
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart-testing.mjs +16 -14
- package/fesm2022/ngwr-charts-bar-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart.mjs +399 -141
- package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs +19 -5
- package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart.mjs +250 -56
- package/fesm2022/ngwr-charts-boxplot-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bullet-chart.mjs +118 -18
- package/fesm2022/ngwr-charts-bullet-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +266 -46
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs +21 -10
- package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-candlestick-chart.mjs +319 -72
- package/fesm2022/ngwr-charts-candlestick-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-chart-legend.mjs +211 -9
- package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
- package/fesm2022/ngwr-charts-core.mjs +311 -23
- package/fesm2022/ngwr-charts-core.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart.mjs +206 -27
- package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart-testing.mjs +4 -4
- package/fesm2022/ngwr-charts-funnel-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart.mjs +113 -10
- package/fesm2022/ngwr-charts-funnel-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-gauge-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-gauge.mjs +98 -12
- package/fesm2022/ngwr-charts-gauge.mjs.map +1 -1
- package/fesm2022/ngwr-charts-heatmap-chart.mjs +226 -31
- package/fesm2022/ngwr-charts-heatmap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart-testing.mjs +16 -4
- package/fesm2022/ngwr-charts-line-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart.mjs +407 -172
- package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group-testing.mjs +4 -4
- package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group.mjs +225 -31
- package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart-testing.mjs +2 -1
- package/fesm2022/ngwr-charts-radar-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart.mjs +255 -66
- package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart-testing.mjs +39 -18
- package/fesm2022/ngwr-charts-scatter-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart.mjs +431 -53
- package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-sparkline.mjs +19 -8
- package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
- package/fesm2022/ngwr-charts-treemap-chart.mjs +253 -44
- package/fesm2022/ngwr-charts-treemap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs +15 -7
- package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-waterfall-chart.mjs +151 -23
- package/fesm2022/ngwr-charts-waterfall-chart.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox.mjs +3 -2
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +65 -5
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu-testing.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +51 -24
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value-testing.mjs +5 -1
- package/fesm2022/ngwr-copy-value-testing.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value.mjs +38 -2
- package/fesm2022/ngwr-copy-value.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +105 -9
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +29 -11
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +9 -6
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +19 -3
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +35 -6
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +1 -0
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-event-calendar.mjs +20 -9
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +170 -3
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-graph.mjs +81 -13
- package/fesm2022/ngwr-graph.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +20 -0
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +20 -0
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +20 -0
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +20 -0
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +20 -0
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +20 -0
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +20 -0
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +20 -0
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +20 -0
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +20 -0
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +20 -0
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +20 -0
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +20 -0
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +20 -0
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +20 -0
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +20 -0
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +20 -0
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +20 -0
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +20 -0
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +20 -0
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +20 -0
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +20 -0
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +82 -11
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +24 -1
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +2 -2
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +10 -2
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-layout.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +20 -3
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +1 -1
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-loading-bar-router.mjs.map +1 -1
- package/fesm2022/ngwr-loading-bar.mjs +2 -2
- package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
- package/fesm2022/ngwr-mention.mjs +8 -0
- package/fesm2022/ngwr-mention.mjs.map +1 -1
- package/fesm2022/ngwr-meta.mjs +9 -6
- package/fesm2022/ngwr-meta.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +21 -2
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-page-header.mjs +21 -0
- package/fesm2022/ngwr-page-header.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +2 -0
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +8 -1
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm-testing.mjs +4 -1
- package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm.mjs +43 -6
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +114 -15
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-qr.mjs +6 -2
- package/fesm2022/ngwr-qr.mjs.map +1 -1
- package/fesm2022/ngwr-radio.mjs +71 -5
- package/fesm2022/ngwr-radio.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +12 -1
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-scroll.mjs +1 -3
- package/fesm2022/ngwr-scroll.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +20 -0
- package/fesm2022/ngwr-segmented.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +80 -9
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-sortable-list.mjs +16 -4
- package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
- package/fesm2022/ngwr-storage.mjs +1 -1
- package/fesm2022/ngwr-storage.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +2 -2
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +43 -7
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tabs-router.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +2 -2
- package/fesm2022/ngwr-textarea.mjs.map +1 -1
- package/fesm2022/ngwr-toast.mjs +28 -0
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +16 -11
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-tree-testing.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +49 -16
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-typography.mjs +20 -0
- package/fesm2022/ngwr-typography.mjs.map +1 -1
- package/fesm2022/ngwr-utils-router.mjs.map +1 -1
- package/fesm2022/ngwr-utils.mjs +46 -4
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-validators.mjs +33 -1
- package/fesm2022/ngwr-validators.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-window.mjs +16 -9
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/form/styles/_index.scss +37 -0
- package/graph/styles/_index.scss +1 -9
- package/i18n/ar.json +20 -0
- package/i18n/cs.json +20 -0
- package/i18n/de.json +20 -0
- package/i18n/en.json +20 -0
- package/i18n/es.json +20 -0
- package/i18n/fr.json +20 -0
- package/i18n/he.json +20 -0
- package/i18n/hi.json +20 -0
- package/i18n/id.json +20 -0
- package/i18n/it.json +20 -0
- package/i18n/ja.json +20 -0
- package/i18n/ko.json +20 -0
- package/i18n/nl.json +20 -0
- package/i18n/pl.json +20 -0
- package/i18n/pt.json +20 -0
- package/i18n/ru.json +20 -0
- package/i18n/sv.json +20 -0
- package/i18n/tr.json +20 -0
- package/i18n/uk.json +20 -0
- package/i18n/vi.json +20 -0
- package/i18n/zh-TW.json +20 -0
- package/i18n/zh.json +20 -0
- package/image-cropper/styles/_index.scss +1 -9
- package/input-number/styles/_index.scss +7 -0
- package/layout/styles/_index.scss +13 -1
- package/llms-full.txt +17 -17
- package/llms.txt +7 -3
- package/loading-bar/styles/_rules.scss +6 -0
- package/package.json +2 -2
- package/page-header/styles/_index.scss +18 -0
- package/popconfirm/styles/_index.scss +6 -0
- package/popover/styles/_index.scss +31 -13
- package/schematics/use/symbol-map.json +3 -0
- package/segmented/styles/_index.scss +7 -0
- package/select/styles/_index.scss +7 -0
- package/sidebar/styles/_index.scss +6 -0
- package/skills/ngwr/references/catalog.md +2 -2
- package/sortable-list/styles/_rules.scss +1 -9
- package/speed-dial/styles/_index.scss +6 -0
- package/stepper/styles/_index.scss +1 -9
- package/table/styles/_index.scss +49 -0
- package/theme/_index.scss +12 -1
- package/theme/styles/_colors.scss +11 -0
- package/theme/styles/_contrast.scss +6 -0
- package/theme/styles/_index.scss +1 -0
- package/theme/styles/_mixins.scss +45 -0
- package/theme/styles/_print.scss +17 -0
- package/toast/styles/_index.scss +7 -0
- package/tour/styles/_index.scss +14 -0
- package/tree/styles/_index.scss +1 -9
- package/types/ngwr-anchor.d.ts +3 -0
- package/types/ngwr-animations-aurora.d.ts +6 -0
- package/types/ngwr-animations-blur-reveal.d.ts +6 -0
- package/types/ngwr-animations-click-sparks.d.ts +6 -0
- package/types/ngwr-animations-confetti.d.ts +6 -0
- package/types/ngwr-animations-decode.d.ts +6 -0
- package/types/ngwr-animations-destruct.d.ts +6 -0
- package/types/ngwr-animations-dot-grid.d.ts +6 -0
- package/types/ngwr-animations-falling-letters.d.ts +6 -0
- package/types/ngwr-animations-flow-lines.d.ts +6 -0
- package/types/ngwr-animations-fluid-cursor.d.ts +6 -0
- package/types/ngwr-animations-glitch.d.ts +6 -0
- package/types/ngwr-animations-glow-border.d.ts +6 -0
- package/types/ngwr-animations-gradient-flow.d.ts +6 -0
- package/types/ngwr-animations-marquee.d.ts +6 -0
- package/types/ngwr-animations-orbit.d.ts +6 -0
- package/types/ngwr-animations-reveal.d.ts +6 -0
- package/types/ngwr-animations-ripple-grid.d.ts +6 -0
- package/types/ngwr-animations-rotate-reveal.d.ts +6 -0
- package/types/ngwr-animations-shimmer.d.ts +6 -0
- package/types/ngwr-animations-spotlight.d.ts +6 -0
- package/types/ngwr-animations-thread-lines.d.ts +6 -0
- package/types/ngwr-animations-tilt.d.ts +10 -0
- package/types/ngwr-animations-typewriter.d.ts +6 -0
- package/types/ngwr-breadcrumbs.d.ts +25 -0
- package/types/ngwr-button.d.ts +23 -3
- package/types/ngwr-carousel-testing.d.ts +6 -4
- package/types/ngwr-carousel.d.ts +16 -3
- package/types/ngwr-cascader-testing.d.ts +4 -3
- package/types/ngwr-cascader.d.ts +34 -3
- package/types/ngwr-charts-bar-chart-testing.d.ts +15 -13
- package/types/ngwr-charts-bar-chart.d.ts +220 -48
- package/types/ngwr-charts-boxplot-chart-testing.d.ts +9 -2
- package/types/ngwr-charts-boxplot-chart.d.ts +110 -19
- package/types/ngwr-charts-bullet-chart.d.ts +72 -12
- package/types/ngwr-charts-calendar-heatmap.d.ts +119 -15
- package/types/ngwr-charts-candlestick-chart-testing.d.ts +19 -9
- package/types/ngwr-charts-candlestick-chart.d.ts +195 -62
- package/types/ngwr-charts-chart-legend.d.ts +142 -5
- package/types/ngwr-charts-core.d.ts +275 -21
- package/types/ngwr-charts-donut-chart-testing.d.ts +11 -5
- package/types/ngwr-charts-donut-chart.d.ts +124 -16
- package/types/ngwr-charts-funnel-chart.d.ts +62 -6
- package/types/ngwr-charts-gauge-testing.d.ts +5 -1
- package/types/ngwr-charts-gauge.d.ts +72 -10
- package/types/ngwr-charts-heatmap-chart.d.ts +103 -20
- package/types/ngwr-charts-line-chart-testing.d.ts +16 -2
- package/types/ngwr-charts-line-chart.d.ts +215 -86
- package/types/ngwr-charts-meter-group.d.ts +98 -7
- package/types/ngwr-charts-radar-chart-testing.d.ts +14 -3
- package/types/ngwr-charts-radar-chart.d.ts +148 -28
- package/types/ngwr-charts-scatter-chart-testing.d.ts +22 -10
- package/types/ngwr-charts-scatter-chart.d.ts +188 -18
- package/types/ngwr-charts-sparkline.d.ts +26 -4
- package/types/ngwr-charts-treemap-chart.d.ts +121 -23
- package/types/ngwr-charts-waterfall-chart-testing.d.ts +8 -1
- package/types/ngwr-charts-waterfall-chart.d.ts +108 -21
- package/types/ngwr-checkbox.d.ts +1 -0
- package/types/ngwr-color-picker.d.ts +28 -0
- package/types/ngwr-context-menu-testing.d.ts +10 -9
- package/types/ngwr-context-menu.d.ts +18 -1
- package/types/ngwr-copy-value.d.ts +8 -0
- package/types/ngwr-date-picker.d.ts +53 -2
- package/types/ngwr-dialog.d.ts +64 -13
- package/types/ngwr-directives.d.ts +12 -4
- package/types/ngwr-drawer.d.ts +33 -2
- package/types/ngwr-dropdown-testing.d.ts +8 -5
- package/types/ngwr-dropdown.d.ts +29 -6
- package/types/ngwr-event-calendar.d.ts +4 -0
- package/types/ngwr-form.d.ts +85 -1
- package/types/ngwr-graph.d.ts +22 -6
- package/types/ngwr-i18n.d.ts +65 -5
- package/types/ngwr-input-number.d.ts +8 -0
- package/types/ngwr-input.d.ts +7 -0
- package/types/ngwr-layout.d.ts +1 -1
- package/types/ngwr-lightbox.d.ts +15 -0
- package/types/ngwr-loading-bar-router.d.ts +6 -0
- package/types/ngwr-overlay.d.ts +16 -1
- package/types/ngwr-page-header.d.ts +23 -1
- package/types/ngwr-popconfirm-testing.d.ts +11 -2
- package/types/ngwr-popconfirm.d.ts +29 -2
- package/types/ngwr-popover.d.ts +87 -13
- package/types/ngwr-radio.d.ts +47 -5
- package/types/ngwr-segmented.d.ts +7 -0
- package/types/ngwr-select.d.ts +57 -13
- package/types/ngwr-sortable-list.d.ts +20 -7
- package/types/ngwr-table.d.ts +59 -6
- package/types/ngwr-tabs-router.d.ts +6 -0
- package/types/ngwr-toast.d.ts +11 -0
- package/types/ngwr-tour.d.ts +21 -3
- package/types/ngwr-tree-testing.d.ts +1 -2
- package/types/ngwr-tree.d.ts +33 -2
- package/types/ngwr-typography.d.ts +7 -0
- package/types/ngwr-utils-router.d.ts +6 -0
- package/types/ngwr-utils.d.ts +56 -2
- package/types/ngwr-validators.d.ts +49 -1
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr-window.d.ts +14 -11
- package/typography/styles/_index.scss +4 -0
- package/window/styles/_index.scss +6 -19
|
@@ -57,6 +57,7 @@ var WrSortableList = class WrSortableList {
|
|
|
57
57
|
}, ...ngDevMode ? [{ debugName: "peers" }] : /* istanbul ignore next */ []);
|
|
58
58
|
dir = inject(Directionality, { optional: true });
|
|
59
59
|
rows = [];
|
|
60
|
+
positions = null;
|
|
60
61
|
grabbedIndex = signal(null, ...ngDevMode ? [{ debugName: "grabbedIndex" }] : /* istanbul ignore next */ []);
|
|
61
62
|
announcement = signal("", ...ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []);
|
|
62
63
|
uid = ++sortableListUid;
|
|
@@ -133,6 +134,20 @@ var WrSortableList = class WrSortableList {
|
|
|
133
134
|
this.sortRows();
|
|
134
135
|
return this.rows.indexOf(item);
|
|
135
136
|
}
|
|
137
|
+
positionOf(item) {
|
|
138
|
+
const items = this.items();
|
|
139
|
+
let cache = this.positions;
|
|
140
|
+
if (cache?.items !== items || cache.count !== this.rows.length) {
|
|
141
|
+
this.sortRows();
|
|
142
|
+
cache = {
|
|
143
|
+
items,
|
|
144
|
+
count: this.rows.length,
|
|
145
|
+
map: new Map(this.rows.map((row, index) => [row, index]))
|
|
146
|
+
};
|
|
147
|
+
this.positions = cache;
|
|
148
|
+
}
|
|
149
|
+
return cache.map.get(item) ?? -1;
|
|
150
|
+
}
|
|
136
151
|
sortRows() {
|
|
137
152
|
for (let i = this.rows.length - 1; i >= 0; i -= 1) if (!this.rows[i].host.nativeElement.isConnected) this.rows.splice(i, 1);
|
|
138
153
|
this.rows.sort((a, b) => follows(a.host.nativeElement, b.host.nativeElement) ? -1 : 1);
|
|
@@ -535,10 +550,7 @@ var WrSortableItem = class WrSortableItem {
|
|
|
535
550
|
list = inject(WR_SORTABLE_LIST);
|
|
536
551
|
drag = inject(CdkDrag);
|
|
537
552
|
host = inject(ElementRef);
|
|
538
|
-
index = computed(() => {
|
|
539
|
-
this.list.items();
|
|
540
|
-
return this.list.indexOf(this);
|
|
541
|
-
}, ...ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []);
|
|
553
|
+
index = computed(() => this.list.positionOf(this), ...ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []);
|
|
542
554
|
grabbed = computed(() => this.list.grabbedIndex() === this.index(), ...ngDevMode ? [{ debugName: "grabbed" }] : /* istanbul ignore next */ []);
|
|
543
555
|
constructor() {
|
|
544
556
|
if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("sortable-list");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-sortable-list.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/sortable-list/tokens/sortable-list.token.ts","../../../projects/lib/sortable-list/sortable-list.ts","../../../projects/lib/sortable-list/sortable-list.html","../../../projects/lib/sortable-list/sortable-item.ts","../../../projects/lib/sortable-list/drag-handle.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, type WritableSignal, signal } from '@angular/core';\n\nimport type { WrSortableList } from '../sortable-list';\nimport type { WrSortableListContext } from '../types';\n\n/**\n * Token a `<wr-sortable-item>` injects to find its parent `<wr-sortable-list>`.\n *\n * Rows arrive through `<ng-content>`, so nothing in the list's template can\n * bind to them and the child has to reach up — the same shape\n * `<wr-carousel-slide>` and `<wr-tab>` use.\n *\n * @internal\n */\nexport const WR_SORTABLE_LIST = new InjectionToken<WrSortableListContext>('WR_SORTABLE_LIST');\n\n/**\n * Every live `<wr-sortable-list>` of the application. A list reads its group\n * out of it, so two lists connect by name with no common ancestor: each column\n * of a board can sit in its own component.\n *\n * @internal\n */\nexport const WR_SORTABLE_LISTS = new InjectionToken<WritableSignal<readonly WrSortableList[]>>('WR_SORTABLE_LISTS', {\n providedIn: 'root',\n factory: () => signal<readonly WrSortableList[]>([]),\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 { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { type CdkDrag, type CdkDragDrop, CdkDropList, moveItemInArray } from '@angular/cdk/drag-drop';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n Injector,\n type WritableSignal,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n viewChild,\n} from '@angular/core';\n\nimport { wrReadI18nText, useI18nFormatter } from 'ngwr/i18n';\n\nimport { WR_SORTABLE_LIST, WR_SORTABLE_LISTS } from './tokens';\nimport type {\n WrSortableCanEnter,\n WrSortableListContext,\n WrSortableMoveEnd,\n WrSortableMoveEvent,\n WrSortableReorderEvent,\n} from './types';\n\n/** Whether `b` comes after `a` in the document. */\nfunction follows(a: HTMLElement, b: HTMLElement): boolean {\n // eslint-disable-next-line no-bitwise -- compareDocumentPosition answers with a bitmask\n return (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0;\n}\n\n/** Counted, not random: the list prerenders, so the id has to match on rehydration. */\nlet sortableListUid = 0;\n\n/**\n * Drag-to-reorder list. Wraps CDK's `cdkDropList` + `cdkDrag` with a\n * signal-based items binding — the source array is updated in place and\n * emitted via 2-way `[(items)]`.\n *\n * Write the loop yourself and project a `<wr-sortable-item>` per row. Until\n * v15 the list owned the loop and rendered one unnamed `<ng-template\n * let-row let-i=\"index\">`, which said nothing in the markup about where those\n * variables came from and gave a row no way to carry anything of its own. Put\n * `wrDragHandle` on an element inside a row to restrict drag start to a\n * handle; there is no input for it, the directive's presence is the switch.\n *\n * Every row is a tab stop: Space or Enter picks it up, the arrow keys move it,\n * Space or Enter drops it and Escape puts it back. CDK's `cdkDrag` ships no key\n * handling of its own, so without this the component's only function was\n * unreachable from a keyboard.\n *\n * Reading direction: a `horizontal` list follows the VISUAL order, so under\n * `dir=\"rtl\"` ArrowLeft moves the held row toward the higher index — the same\n * rule `wr-slider` applies to its track. A vertical list never mirrors.\n *\n * What that does NOT answer is WCAG 2.5.7, which asks for a POINTER alternative\n * to the drag. Click-to-pick-up is the obvious candidate and is not safe here:\n * the CDK's drag-drop bundle installs no click suppressor of any kind, so the\n * mouseup ending a drag still produces a click, and a row that grabbed itself on\n * click would be picking itself straight back up. A visible move-up /\n * move-down affordance is the remaining answer, and that is a design change.\n *\n * Lists that share a `group` exchange items, by drag and by keyboard. The\n * target list emits `move` once, and both lists write `[(items)]`; `reorder`\n * stays for a move inside one list. Lists find each other through a root\n * registry and are handed to `cdkDropListConnectedTo`, not through\n * `cdkDropListGroup`, which needs a common ancestor directive and so cannot\n * join lists that live in separate components.\n *\n * @example\n * ```html\n * <wr-sortable-list [(items)]=\"rows\" (reorder)=\"onReorder($event)\">\n * @for (row of rows(); track row.id) {\n * <wr-sortable-item>\n * <span wrDragHandle>≡</span>\n * {{ row.label }}\n * </wr-sortable-item>\n * }\n * </wr-sortable-list>\n * ```\n *\n * @see https://ngwr.dev/reference/components/sortable-list\n */\n@Component({\n selector: 'wr-sortable-list',\n templateUrl: './sortable-list.html',\n styleUrl: './sortable-list.scss',\n encapsulation: ViewEncapsulation.None,\n // On the host, not in the template: rows are projected, and a projected\n // `cdkDrag` resolves its drop list through the element injector, which\n // never passes through this component's own view.\n hostDirectives: [CdkDropList],\n host: {\n class: 'wr-sortable-list',\n '[class.wr-sortable-list--connected]': '!!group()',\n '[class.wr-sortable-list--empty]': 'items().length === 0',\n '[attr.id]': 'id() ?? fallbackId',\n },\n providers: [{ provide: WR_SORTABLE_LIST, useExisting: WrSortableList }],\n})\nexport class WrSortableList<T = unknown> implements WrSortableListContext {\n /** Items to render. Two-way — emits the reordered array on drop. */\n readonly items = model.required<T[]>();\n\n /** Layout direction. Drives CDK's `cdkDropListOrientation`. @default 'vertical' */\n readonly orientation = input<'vertical' | 'horizontal'>('vertical');\n\n /** Disable all dragging. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Locked axis — restrict drag movement to one axis even diagonally. */\n readonly lockAxis = input<'x' | 'y' | undefined>(undefined);\n\n /**\n * Delay (ms) before a drag begins after the pointer goes down. The touch\n * delay is the fix for the classic CDK touch snag: without it, the\n * `touch-action: none` CDK puts on each item blocks scrolling the list on a\n * phone. With a small touch delay, a quick swipe scrolls and a brief hold\n * starts the drag; mouse stays instant. Pass a single number to apply one\n * delay to both pointers. @default { touch: 150, mouse: 0 }\n */\n readonly dragStartDelay = input<number | { touch: number; mouse: number }>({ touch: 150, mouse: 0 });\n\n /**\n * Name of the group this list belongs to. Lists with the same group exchange\n * items, wherever they sit in the page. @default null\n */\n readonly group = input<string | null>(null);\n\n /**\n * Refuses an item coming from another list of the group, by drag and by\n * keyboard alike. An item can always return to the list it left.\n * @default null\n */\n readonly canEnter = input<WrSortableCanEnter<T> | null>(null);\n\n /**\n * Accessible name of the list. A keyboard move into this list announces it;\n * without one the announcement falls back to the list's position in the group.\n * @default null\n */\n readonly ariaLabel = input<string | null>(null);\n\n /** The host's `id`, and what tells the lists of a `move` apart. Generated when omitted. */\n readonly id = input<string>();\n\n /** Fired after a successful reorder with the new array + indices. Not fired for a move between lists. */\n readonly reorder = output<WrSortableReorderEvent<T>>();\n\n /**\n * Fired once on the list an item ARRIVED in from another list of the group,\n * after both lists have written `items`. The list it left emits nothing but\n * `itemsChange`.\n */\n readonly move = output<WrSortableMoveEvent<T>>();\n\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly dropList = inject<CdkDropList<WrSortableList<T>>>(CdkDropList, { self: true });\n private readonly lists = inject(WR_SORTABLE_LISTS) as unknown as WritableSignal<readonly WrSortableList<T>[]>;\n private readonly listEl = viewChild.required<ElementRef<HTMLElement>>('list');\n\n /** The other lists of this list's group. */\n private readonly peers = computed(() => {\n const group = this.group();\n return group ? this.lists().filter(list => list !== this && list.group() === group) : [];\n });\n\n /**\n * Ambient reading direction, for the keyboard path.\n *\n * Optional so a bare `TestBed` — or any consumer that never set a direction —\n * needs no provider; `Directionality` is root-provided, so `null` only ever\n * means \"nobody asked\", which is LTR. Nothing caches a direction-derived\n * value: `isRtl()` is read inside the key handler, so a runtime flip needs no\n * subscription to `Directionality.change`.\n *\n * The POINTER path already mirrors without this — `cdkDropList` injects\n * `Directionality` itself and feeds it to `DropListRef.withDirection`, so a\n * horizontal drag has always followed the visual order. The keyboard path was\n * the half that did not, which is why the two disagreed.\n */\n private readonly dir = inject(Directionality, { optional: true });\n\n /**\n * The rows, in projection order, which is the order the consumer's own loop\n * rendered them in — so a row's position here IS its index into `items()`.\n *\n * Collected on construction rather than through `contentChildren`, because\n * the keyboard path has to resolve an index DURING a keydown and a query\n * signal is only guaranteed current after change detection. A row that\n * Angular destroys drops out on the next lookup: the element is gone from\n * the DOM, so `indexOf` cannot find it and the stale entry is swept then.\n */\n private readonly rows: { readonly host: ElementRef<HTMLElement> }[] = [];\n\n /** Index of the row the keyboard is holding, or `null` when nothing is held. */\n readonly grabbedIndex = signal<number | null>(null);\n\n /** Live-region text. Written by the keyboard path only. */\n protected readonly announcement = signal('');\n\n private readonly uid = ++sortableListUid;\n\n /** Links every row to the key model via `aria-describedby`. */\n readonly keyHelpId = `wr-sortable-list-help-${this.uid}`;\n\n protected readonly fallbackId = `wr-sortable-list-${this.uid}`;\n\n private readonly keyHelp = wrReadI18nText(\n 'sortableList.keyHelp',\n 'Press Space to pick this item up, then use the arrow keys to move it. ' +\n 'Press Space again to drop it, or Escape to put it back.'\n );\n private readonly groupKeyHelp = wrReadI18nText(\n 'sortableList.groupKeyHelp',\n 'Press Space to pick this item up, then use the arrow keys to move it, within its list or into the next one. ' +\n 'Press Space again to drop it, or Escape to put it back.'\n );\n protected readonly resolvedKeyHelp = computed(() => (this.group() ? this.groupKeyHelp() : this.keyHelp()));\n\n private readonly grabbedText = useI18nFormatter('sortableList.grabbed', 'Grabbed. {{index}} of {{total}}.');\n private readonly movedText = useI18nFormatter('sortableList.moved', '{{index}} of {{total}}.');\n private readonly droppedText = useI18nFormatter('sortableList.dropped', 'Dropped. {{index}} of {{total}}.');\n private readonly cancelledText = wrReadI18nText('sortableList.cancelled', 'Move cancelled.');\n private readonly movedToText = useI18nFormatter('sortableList.movedTo', 'Moved to {{list}}. {{index}} of {{total}}.');\n private readonly listPositionText = useI18nFormatter('sortableList.listPosition', 'list {{index}} of {{total}}');\n\n /** Where the held row started, which can be another list. Escape puts it back there. */\n private grabOrigin: WrSortableMoveEnd<T> | null = null;\n\n /** True while a keyboard move is handing focus back — see `onRowFocusout`. */\n private restoringFocus = false;\n\n constructor() {\n this.lists.update(lists => [...lists, this]);\n inject(DestroyRef).onDestroy(() => this.lists.update(lists => lists.filter(list => list !== this)));\n\n const dropList = this.dropList;\n dropList.data = this;\n dropList.elementContainerSelector = '.wr-sortable-list__list';\n dropList.enterPredicate = (drag: CdkDrag<T>) => {\n const from = drag.dropContainer?.data as WrSortableList<T> | undefined;\n return !!from && this.accepts(drag.data, from);\n };\n dropList.dropped.subscribe((event: CdkDragDrop<WrSortableList<T>>) => this.onDrop(event));\n\n // Assigned, not bound: a host directive's inputs are out of a host binding's reach.\n effect(() => {\n dropList.id = this.id() ?? this.fallbackId;\n dropList.orientation = this.orientation();\n dropList.disabled = this.disabled();\n dropList.connectedTo = this.peers().map(list => list.dropList);\n });\n\n // The CDK resolves the selector above only on the list a drag STARTS in. A\n // list that only ever receives would append the placeholder to the host,\n // beside the rows' container rather than in it.\n afterNextRender(() => dropList._dropListRef.withElementContainer(this.listEl().nativeElement));\n }\n\n /** Rows whose pointer drag Escape cancelled; the drop that follows is ignored. */\n private readonly cancelledDrags = new WeakSet<object>();\n\n /** @internal A row's pointer drag was cancelled with Escape. */\n cancelDrag(drag: object): void {\n this.cancelledDrags.add(drag);\n }\n\n private onDrop(event: CdkDragDrop<WrSortableList<T>>): void {\n if (event.item && this.lists().some(list => list.cancelledDrags.delete(event.item))) return;\n if (event.previousContainer !== event.container) {\n const source = event.previousContainer.data;\n const item = source.removeAt(event.previousIndex);\n this.insertAt(item, event.currentIndex);\n this.move.emit({\n item,\n from: { list: source, index: event.previousIndex },\n to: { list: this, index: event.currentIndex },\n });\n return;\n }\n if (event.previousIndex === event.currentIndex) return;\n const next = this.items().slice();\n moveItemInArray(next, event.previousIndex, event.currentIndex);\n this.items.set(next);\n this.reorder.emit({\n items: next,\n previousIndex: event.previousIndex,\n currentIndex: event.currentIndex,\n item: next[event.currentIndex],\n });\n }\n\n /**\n * The keyboard reorder path: pick up, move, drop — deliberately a two-step\n * grab rather than \"an arrow moves the focused row\", so that arrowing through\n * a list a user is only reading can never rearrange it.\n *\n * Keys are handled only when the ROW itself is the event target; a button or\n * an input projected into the row template keeps every key it would normally\n * get.\n */\n /** @internal A row registering itself on construction. */\n register(item: { readonly host: ElementRef<HTMLElement> }): void {\n this.rows.push(item);\n }\n\n /**\n * @internal A row's position among its live siblings.\n *\n * Read off the DOM rather than off the registration order, because a row can\n * be added, removed or moved by the consumer's own loop and construction\n * order survives none of those. Rows whose element has left the document are\n * swept here, which is the only place that can tell.\n */\n indexOf(item: { readonly host: ElementRef<HTMLElement> }): number {\n this.sortRows();\n return this.rows.indexOf(item);\n }\n\n /**\n * Drops rows whose element has left the document and puts the rest into\n * document order.\n *\n * Its own method because `relocate` needs it too: that one focuses\n * `rows[to]` after the move, and without a re-sort it reached into an array\n * still ordered as the list looked BEFORE the move.\n */\n private sortRows(): void {\n for (let i = this.rows.length - 1; i >= 0; i -= 1) {\n if (!this.rows[i].host.nativeElement.isConnected) this.rows.splice(i, 1);\n }\n this.rows.sort((a, b) => (follows(a.host.nativeElement, b.host.nativeElement) ? -1 : 1));\n }\n\n /** @internal */\n onRowKeydown(event: KeyboardEvent, index: number): void {\n if (this.disabled() || event.target !== event.currentTarget) return;\n\n const grabbed = this.grabbedIndex();\n const horizontal = this.orientation() === 'horizontal';\n // The horizontal arrows name a SIDE of the row, so they follow the reading\n // direction: a horizontal list under `dir=\"rtl\"` paints index 0 at the right,\n // so the key that raises the index is ArrowLeft. Raising it on ArrowRight\n // regardless moved the held item away from the arrow the user pressed — the\n // one failure in this set a user cannot rationalise, because it inverts their\n // model of the list silently. The block arrows name a value's direction in a\n // column and never mirror, which is why only the horizontal pair is swapped.\n const rtl = this.dir?.value === 'rtl';\n const inlineForward = rtl ? 'ArrowLeft' : 'ArrowRight';\n const inlineBack = rtl ? 'ArrowRight' : 'ArrowLeft';\n const forward = horizontal ? inlineForward : 'ArrowDown';\n const back = horizontal ? inlineBack : 'ArrowUp';\n // The arrows of the other axis walk the group: columns sit side by side, so\n // a vertical list hands the row over on the inline pair, mirrored like above.\n const nextList = horizontal ? 'ArrowDown' : inlineForward;\n const previousList = horizontal ? 'ArrowUp' : inlineBack;\n\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n if (grabbed === null) this.grab(index);\n else this.drop();\n return;\n }\n\n if (grabbed === null) return;\n\n if (event.key === 'Escape') {\n event.preventDefault();\n // Held only while a row is grabbed — an Escape typed anywhere else has to\n // keep reaching whatever dialog or overlay the list is sitting in.\n event.stopPropagation();\n this.cancelGrab();\n return;\n }\n\n if (event.key === forward || event.key === back) {\n event.preventDefault();\n this.moveGrabbed(event.key === forward ? 1 : -1);\n return;\n }\n\n if (this.group() && (event.key === nextList || event.key === previousList)) {\n event.preventDefault();\n this.moveToList(event.key === nextList ? 1 : -1);\n }\n }\n\n /**\n * Focus leaving a held row ends the gesture as a drop rather than dropping the\n * change on the floor — `[(items)]` has already been written by then, so a\n * silent release would leave `reorder` never reporting a move that happened.\n * The guard is what makes it safe: moving a focused node in the DOM blurs it,\n * so every keyboard move fires this too.\n */\n /** @internal */\n onRowFocusout(): void {\n if (this.restoringFocus || this.grabbedIndex() === null) return;\n this.drop();\n }\n\n private grab(index: number): void {\n this.grabOrigin = { list: this, index };\n this.grabbedIndex.set(index);\n this.announcement.set(this.grabbedText(this.position(index)));\n }\n\n private moveGrabbed(delta: number): void {\n const from = this.grabbedIndex();\n if (from === null) return;\n const to = from + delta;\n if (to < 0 || to >= this.items().length) return;\n\n this.relocate(from, to);\n this.grabbedIndex.set(to);\n this.announcement.set(this.movedText(this.position(to)));\n }\n\n /**\n * Hands the held row to the nearest list of the group, in document order,\n * that takes it. A list that refuses is stepped over, since a drag can reach\n * any list of the group and the keyboard must not reach fewer.\n */\n private moveToList(step: 1 | -1): void {\n const from = this.grabbedIndex();\n const origin = this.grabOrigin;\n if (from === null || !origin) return;\n\n const group = this.groupLists();\n const item = this.items()[from];\n let at = group.indexOf(this) + step;\n while (group[at] && !group[at].accepts(item, origin.list)) at += step;\n const target = group[at];\n if (!target) return;\n\n this.grabbedIndex.set(null);\n this.grabOrigin = null;\n this.announcement.set('');\n this.removeAt(from);\n\n const to = Math.min(from, target.items().length);\n target.insertAt(item, to);\n target.grabOrigin = origin;\n target.grabbedIndex.set(to);\n const list =\n target.ariaLabel() ?? target.listPositionText({ index: group.indexOf(target) + 1, total: group.length });\n target.announcement.set(target.movedToText({ list, ...target.position(to) }));\n target.focusRow(to);\n }\n\n private drop(): void {\n const to = this.grabbedIndex();\n const origin = this.grabOrigin;\n this.grabbedIndex.set(null);\n this.grabOrigin = null;\n if (to === null || !origin) return;\n\n this.announcement.set(this.droppedText(this.position(to)));\n if (origin.list !== this) {\n this.move.emit({ item: this.items()[to], from: origin, to: { list: this, index: to } });\n return;\n }\n if (origin.index === to) return;\n // One event per gesture, the way a drag emits one on drop — not one per\n // arrow press, which would put a host that persists on `reorder` through a\n // write per keystroke. `[(items)]` still updates on every press, because\n // the rendered order has to follow the row the user is moving.\n this.reorder.emit({ items: this.items(), previousIndex: origin.index, currentIndex: to, item: this.items()[to] });\n }\n\n private cancelGrab(): void {\n const from = this.grabbedIndex();\n const origin = this.grabOrigin;\n if (from === null || !origin) return;\n this.grabbedIndex.set(null);\n this.grabOrigin = null;\n\n if (origin.list === this) {\n if (from !== origin.index) this.relocate(from, origin.index);\n this.announcement.set(this.cancelledText());\n return;\n }\n this.announcement.set('');\n origin.list.insertAt(this.removeAt(from), origin.index);\n origin.list.announcement.set(origin.list.cancelledText());\n origin.list.focusRow(origin.index);\n }\n\n /** Whether this list takes `item` from another list of the group. */\n private accepts(item: T, from: WrSortableList<T>): boolean {\n return !this.disabled() && (from === this || (this.canEnter()?.(item, from) ?? true));\n }\n\n /** This list and its peers, in document order. */\n private groupLists(): WrSortableList<T>[] {\n return [this, ...this.peers()].sort((a, b) => (follows(a.host.nativeElement, b.host.nativeElement) ? -1 : 1));\n }\n\n private removeAt(index: number): T {\n const next = this.items().slice();\n const [item] = next.splice(index, 1);\n this.items.set(next);\n return item;\n }\n\n private insertAt(item: T, index: number): void {\n const next = this.items().slice();\n next.splice(index, 0, item);\n this.items.set(next);\n }\n\n private relocate(from: number, to: number): void {\n const next = this.items().slice();\n moveItemInArray(next, from, to);\n this.items.set(next);\n this.focusRow(to);\n }\n\n private focusRow(to: number): void {\n // The row is the same DOM node moved to another slot, and moving a focused\n // node hands focus back to `<body>` — so it has to be taken again once the\n // move has rendered. `afterNextRender`, never a microtask: zoneless change\n // detection runs in a macrotask, so a microtask would fire while the row is\n // still at its old index and focus the wrong one. (jsdom keeps focus across\n // a node move, so no spec here can express that half.)\n this.restoringFocus = true;\n afterNextRender(\n () => {\n // Re-sorted FIRST. `this.rows` is only ever put into document order by\n // `indexOf`, and nothing calls it between the move and here — so the\n // array was still in the order it had BEFORE the move, and `rows[to]`\n // was whichever row used to be at that slot. `sortRows()` is the same\n // sweep-and-sort `indexOf` runs; after it, index `to` is the row the\n // move actually put there.\n this.sortRows();\n this.rows[to]?.host.nativeElement.focus();\n this.restoringFocus = false;\n },\n { injector: this.injector }\n );\n }\n\n private position(index: number): { index: number; total: number } {\n return { index: index + 1, total: this.items().length };\n }\n}\n\nexport type { WrSortableCanEnter, WrSortableMoveEnd, WrSortableMoveEvent, WrSortableReorderEvent } from './types';\n","<!--\n `role=\"list\"` on the container and `role=\"listitem\"` on each row rather than\n bare divs: every row is a tab stop, and a focusable element with no role at\n all is announced as loose text. The list role is what gives the reader the\n position of the row focus lands on.\n\n Rows arrive through `<ng-content>` — the consumer writes the loop, so the\n markup says what each row is instead of hiding it in an unnamed template.\n-->\n<div #list role=\"list\" class=\"wr-sortable-list__list\" [attr.aria-label]=\"ariaLabel()\">\n <ng-content />\n @if (items().length === 0) {\n <!-- A row of its own, so the list announces what it shows; hidden by `:empty` when nothing is projected. -->\n <div role=\"listitem\" class=\"wr-sortable-list__empty\"><ng-content select=\"[wrSortableListEmpty]\" /></div>\n }\n</div>\n\n<!--\n The key model, on every row rather than once on the container: focus lands on\n a row and never on the list itself, so a description hung on the list would\n never be read out.\n-->\n<p class=\"wr-sortable-list__sr-only\" [id]=\"keyHelpId\">{{ resolvedKeyHelp() }}</p>\n\n<!--\n Position announcements, written by the keyboard path only — a drag already\n gives sighted feedback, and announcing every pointer move would flood the\n region.\n-->\n<p class=\"wr-sortable-list__sr-only\" role=\"status\">{{ announcement() }}</p>\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 { CdkDrag } from '@angular/cdk/drag-drop';\nimport { DOCUMENT } from '@angular/common';\nimport { Component, DestroyRef, ElementRef, ViewEncapsulation, computed, effect, inject } from '@angular/core';\n\nimport { wrCheckStyles, wrWatchDragCancel } from 'ngwr/utils';\n\nimport { WR_SORTABLE_LIST } from './tokens';\n\n/**\n * One row of a {@link WrSortableList}. Write the loop yourself and put whatever\n * the row shows inside it.\n *\n * It replaced a single unnamed `<ng-template let-row let-i=\"index\">` that the\n * list rendered per item. Two things were wrong with that. The template had no\n * name, so nothing in the markup said what the context variables were or where\n * they came from — a reader had to open the component to learn that `let-row`\n * is the item and `let-i` the index. And a row could not carry anything of its\n * own: every per-row decision had to be an input on the LIST, or a branch\n * inside one template.\n *\n * The row is the tab stop, so the keyboard contract lives here: Space or Enter\n * picks it up, the arrows move it, Space or Enter drops it, Escape puts it\n * back. The list owns the array and the announcements, and this delegates to\n * it — an item knows its own position and nothing else.\n *\n * @example\n * ```html\n * <wr-sortable-list [(items)]=\"rows\">\n * @for (row of rows(); track row.id) {\n * <wr-sortable-item>\n * <span wrDragHandle>≡</span>\n * {{ row.label }}\n * </wr-sortable-item>\n * }\n * </wr-sortable-list>\n * ```\n *\n * @see https://ngwr.dev/reference/components/sortable-list\n */\n@Component({\n selector: 'wr-sortable-item',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n hostDirectives: [CdkDrag],\n host: {\n class: 'wr-sortable-list__item',\n role: 'listitem',\n '[class.wr-sortable-list__item--grabbed]': 'grabbed()',\n '[attr.tabindex]': 'list.disabled() ? null : 0',\n '[attr.aria-describedby]': 'list.disabled() ? null : list.keyHelpId',\n '(keydown)': 'onKeydown($event)',\n '(focusout)': 'list.onRowFocusout()',\n },\n})\nexport class WrSortableItem {\n /** @internal The list this row belongs to. Read by the host bindings above. */\n protected readonly list = inject(WR_SORTABLE_LIST);\n\n private readonly drag = inject(CdkDrag);\n\n /** @internal */\n readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Position among the list's rows, which IS the index into `items()`: the\n * consumer's own loop renders them in that order.\n *\n * `indexOf` resolves by DOCUMENT ORDER over a plain array and touches no\n * signal, so the `computed` needs a producer that changes whenever a position\n * can. That producer is the `items` ARRAY, not its length: a reorder keeps the\n * count, so a length-keyed index stayed on the slot the row had left, the\n * highlight stayed behind with it, and a second pick-up of the same row moved\n * its old neighbour instead. Host bindings run after the consumer's `@for`\n * has moved the nodes, so the recomputation reads the new order.\n */\n protected readonly index = computed(() => {\n this.list.items();\n return this.list.indexOf(this);\n });\n\n protected readonly grabbed = computed(() => this.list.grabbedIndex() === this.index());\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('sortable-list');\n this.list.register(this);\n\n // Assigned rather than bound, because these belong to the LIST and a host\n // binding cannot reach another directive's input. `CdkDrag` reads all\n // three as plain properties on every gesture, so writing them from an\n // effect is enough and a runtime change takes effect on the next drag.\n effect(() => {\n this.drag.disabled = this.list.disabled();\n this.drag.lockAxis = this.list.lockAxis() ?? null;\n this.drag.dragStartDelay = this.list.dragStartDelay();\n });\n\n // Escape cancels a pointer drag; CDK has no cancel of its own.\n const doc = inject(DOCUMENT);\n let stopCancel: (() => void) | null = null;\n this.drag.started.subscribe(event => {\n stopCancel?.();\n stopCancel = wrWatchDragCancel(doc, event.event, () => this.list.cancelDrag(this.drag));\n });\n this.drag.ended.subscribe(() => {\n stopCancel?.();\n stopCancel = null;\n });\n inject(DestroyRef).onDestroy(() => stopCancel?.());\n\n // What a connected list's `canEnter` is asked about.\n effect(() => {\n this.drag.data = this.list.items()[this.index()];\n });\n }\n\n /**\n * @internal Resolves the position at the moment of the key, off the DOM,\n * rather than through the cached `index`: nothing has to have rendered\n * between two presses for the answer to be right.\n */\n protected onKeydown(event: KeyboardEvent): void {\n this.list.onRowKeydown(event, this.list.indexOf(this));\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 { CdkDragHandle } from '@angular/cdk/drag-drop';\nimport { Directive } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Drag handle for {@link WrSortableList} (and any nested `cdkDrag`).\n * Composes CDK's `cdkDragHandle` via `hostDirectives` so consumers don't\n * need to import the CDK selector directly.\n *\n * @example\n * ```html\n * <wr-sortable-list [(items)]=\"rows\">\n * @for (row of rows(); track row.id) {\n * <wr-sortable-item>\n * <span wrDragHandle class=\"grip\">≡</span>\n * <span>{{ row.label }}</span>\n * </wr-sortable-item>\n * }\n * </wr-sortable-list>\n * ```\n */\n@Directive({\n selector: '[wrDragHandle]',\n hostDirectives: [CdkDragHandle],\n host: { class: 'wr-drag-handle' },\n})\nexport class WrDragHandle {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('sortable-list');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAa,mBAAmB,IAAI,eAAsC,kBAAkB;AAS5F,MAAa,oBAAoB,IAAI,eAA0D,qBAAqB;CAClH,YAAY;CACZ,eAAe,OAAkC,CAAA,CAAE;AACpD,CAAA;;;;;;;ACOD,SAAS,QAAQ,GAAgB,GAAc;CAE7C,QAAQ,EAAE,wBAAwB,CAAC,IAAI,KAAK,iCAAiC;AAC/E;AAGA,IAAI,kBAAkB;AAoEtB,IAAa,iBAAb,MAAa,eAAc;CAEhB,QAAQ,MAAM,SAAe,GAAA,YAAA,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CACvB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,eAAe;CAClF;CAHW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAY,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAZ,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAY,cAAA;EAAA,UAAA;EAAA,MAAA,EAAA,gBAAA,iBAAA;EAAA,gBAAA,CAAA,EAAA,WAAA,GAAA,cAAA,CAAA;EAAA,UAAA;CAAA,CAAA;;AAAZ,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAY,YAAA,CAAA;EALxB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,gBAAgB,CAAC,aAAa;GAC9B,MAAM,EAAE,OAAO,iBAAgB;EAChC,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-sortable-list.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/sortable-list/tokens/sortable-list.token.ts","../../../projects/lib/sortable-list/sortable-list.ts","../../../projects/lib/sortable-list/sortable-list.html","../../../projects/lib/sortable-list/sortable-item.ts","../../../projects/lib/sortable-list/drag-handle.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, type WritableSignal, signal } from '@angular/core';\n\nimport type { WrSortableList } from '../sortable-list';\nimport type { WrSortableListContext } from '../types';\n\n/**\n * Token a `<wr-sortable-item>` injects to find its parent `<wr-sortable-list>`.\n *\n * Rows arrive through `<ng-content>`, so nothing in the list's template can\n * bind to them and the child has to reach up — the same shape\n * `<wr-carousel-slide>` and `<wr-tab>` use.\n *\n * @internal\n */\nexport const WR_SORTABLE_LIST = new InjectionToken<WrSortableListContext>('WR_SORTABLE_LIST');\n\n/**\n * Every live `<wr-sortable-list>` of the application. A list reads its group\n * out of it, so two lists connect by name with no common ancestor: each column\n * of a board can sit in its own component.\n *\n * @internal\n */\nexport const WR_SORTABLE_LISTS = new InjectionToken<WritableSignal<readonly WrSortableList[]>>('WR_SORTABLE_LISTS', {\n providedIn: 'root',\n factory: () => signal<readonly WrSortableList[]>([]),\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 { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { type CdkDrag, type CdkDragDrop, CdkDropList, moveItemInArray } from '@angular/cdk/drag-drop';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n Injector,\n type WritableSignal,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n viewChild,\n} from '@angular/core';\n\nimport { wrReadI18nText, useI18nFormatter } from 'ngwr/i18n';\n\nimport { WR_SORTABLE_LIST, WR_SORTABLE_LISTS } from './tokens';\nimport type {\n WrSortableCanEnter,\n WrSortableListContext,\n WrSortableMoveEnd,\n WrSortableMoveEvent,\n WrSortableReorderEvent,\n} from './types';\n\n/** Whether `b` comes after `a` in the document. */\nfunction follows(a: HTMLElement, b: HTMLElement): boolean {\n // eslint-disable-next-line no-bitwise -- compareDocumentPosition answers with a bitmask\n return (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0;\n}\n\n/** Counted, not random: the list prerenders, so the id has to match on rehydration. */\nlet sortableListUid = 0;\n\n/**\n * Drag-to-reorder list. Wraps CDK's `cdkDropList` + `cdkDrag` with a\n * signal-based items binding — the source array is updated in place and\n * emitted via 2-way `[(items)]`.\n *\n * Write the loop yourself and project a `<wr-sortable-item>` per row. Until\n * v15 the list owned the loop and rendered one unnamed `<ng-template\n * let-row let-i=\"index\">`, which said nothing in the markup about where those\n * variables came from and gave a row no way to carry anything of its own. Put\n * `wrDragHandle` on an element inside a row to restrict drag start to a\n * handle; there is no input for it, the directive's presence is the switch.\n *\n * Every row is a tab stop: Space or Enter picks it up, the arrow keys move it,\n * Space or Enter drops it and Escape puts it back. CDK's `cdkDrag` ships no key\n * handling of its own, so without this the component's only function was\n * unreachable from a keyboard.\n *\n * Reading direction: a `horizontal` list follows the VISUAL order, so under\n * `dir=\"rtl\"` ArrowLeft moves the held row toward the higher index — the same\n * rule `wr-slider` applies to its track. A vertical list never mirrors.\n *\n * What that does NOT answer is WCAG 2.5.7, which asks for a POINTER alternative\n * to the drag. Click-to-pick-up is the obvious candidate and is not safe here:\n * the CDK's drag-drop bundle installs no click suppressor of any kind, so the\n * mouseup ending a drag still produces a click, and a row that grabbed itself on\n * click would be picking itself straight back up. A visible move-up /\n * move-down affordance is the remaining answer, and that is a design change.\n *\n * Lists that share a `group` exchange items, by drag and by keyboard. The\n * target list emits `move` once, and both lists write `[(items)]`; `reorder`\n * stays for a move inside one list. Lists find each other through a root\n * registry and are handed to `cdkDropListConnectedTo`, not through\n * `cdkDropListGroup`, which needs a common ancestor directive and so cannot\n * join lists that live in separate components.\n *\n * @example\n * ```html\n * <wr-sortable-list [(items)]=\"rows\" (reorder)=\"onReorder($event)\">\n * @for (row of rows(); track row.id) {\n * <wr-sortable-item>\n * <span wrDragHandle>≡</span>\n * {{ row.label }}\n * </wr-sortable-item>\n * }\n * </wr-sortable-list>\n * ```\n *\n * @see https://ngwr.dev/reference/components/sortable-list\n */\n@Component({\n selector: 'wr-sortable-list',\n templateUrl: './sortable-list.html',\n styleUrl: './sortable-list.scss',\n encapsulation: ViewEncapsulation.None,\n // On the host, not in the template: rows are projected, and a projected\n // `cdkDrag` resolves its drop list through the element injector, which\n // never passes through this component's own view.\n hostDirectives: [CdkDropList],\n host: {\n class: 'wr-sortable-list',\n '[class.wr-sortable-list--connected]': '!!group()',\n '[class.wr-sortable-list--empty]': 'items().length === 0',\n '[attr.id]': 'id() ?? fallbackId',\n },\n providers: [{ provide: WR_SORTABLE_LIST, useExisting: WrSortableList }],\n})\nexport class WrSortableList<T = unknown> implements WrSortableListContext {\n /** Items to render. Two-way — emits the reordered array on drop. */\n readonly items = model.required<T[]>();\n\n /** Layout direction. Drives CDK's `cdkDropListOrientation`. @default 'vertical' */\n readonly orientation = input<'vertical' | 'horizontal'>('vertical');\n\n /** Disable all dragging. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Locked axis — restrict drag movement to one axis even diagonally. */\n readonly lockAxis = input<'x' | 'y' | undefined>(undefined);\n\n /**\n * Delay (ms) before a drag begins after the pointer goes down. The touch\n * delay is the fix for the classic CDK touch snag: without it, the\n * `touch-action: none` CDK puts on each item blocks scrolling the list on a\n * phone. With a small touch delay, a quick swipe scrolls and a brief hold\n * starts the drag; mouse stays instant. Pass a single number to apply one\n * delay to both pointers. @default { touch: 150, mouse: 0 }\n */\n readonly dragStartDelay = input<number | { touch: number; mouse: number }>({ touch: 150, mouse: 0 });\n\n /**\n * Name of the group this list belongs to. Lists with the same group exchange\n * items, wherever they sit in the page. @default null\n */\n readonly group = input<string | null>(null);\n\n /**\n * Refuses an item coming from another list of the group, by drag and by\n * keyboard alike. An item can always return to the list it left.\n * @default null\n */\n readonly canEnter = input<WrSortableCanEnter<T> | null>(null);\n\n /**\n * Accessible name of the list. A keyboard move into this list announces it;\n * without one the announcement falls back to the list's position in the group.\n * @default null\n */\n readonly ariaLabel = input<string | null>(null);\n\n /** The host's `id`, and what tells the lists of a `move` apart. Generated when omitted. */\n readonly id = input<string>();\n\n /** Fired after a successful reorder with the new array + indices. Not fired for a move between lists. */\n readonly reorder = output<WrSortableReorderEvent<T>>();\n\n /**\n * Fired once on the list an item ARRIVED in from another list of the group,\n * after both lists have written `items`. The list it left emits nothing but\n * `itemsChange`.\n */\n readonly move = output<WrSortableMoveEvent<T>>();\n\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly dropList = inject<CdkDropList<WrSortableList<T>>>(CdkDropList, { self: true });\n private readonly lists = inject(WR_SORTABLE_LISTS) as unknown as WritableSignal<readonly WrSortableList<T>[]>;\n private readonly listEl = viewChild.required<ElementRef<HTMLElement>>('list');\n\n /** The other lists of this list's group. */\n private readonly peers = computed(() => {\n const group = this.group();\n return group ? this.lists().filter(list => list !== this && list.group() === group) : [];\n });\n\n /**\n * Ambient reading direction, for the keyboard path.\n *\n * Optional so a bare `TestBed` — or any consumer that never set a direction —\n * needs no provider; `Directionality` is root-provided, so `null` only ever\n * means \"nobody asked\", which is LTR. Nothing caches a direction-derived\n * value: `isRtl()` is read inside the key handler, so a runtime flip needs no\n * subscription to `Directionality.change`.\n *\n * The POINTER path already mirrors without this — `cdkDropList` injects\n * `Directionality` itself and feeds it to `DropListRef.withDirection`, so a\n * horizontal drag has always followed the visual order. The keyboard path was\n * the half that did not, which is why the two disagreed.\n */\n private readonly dir = inject(Directionality, { optional: true });\n\n /**\n * The rows, in projection order, which is the order the consumer's own loop\n * rendered them in — so a row's position here IS its index into `items()`.\n *\n * Collected on construction rather than through `contentChildren`, because\n * the keyboard path has to resolve an index DURING a keydown and a query\n * signal is only guaranteed current after change detection. A row that\n * Angular destroys drops out on the next lookup: the element is gone from\n * the DOM, so `indexOf` cannot find it and the stale entry is swept then.\n */\n private readonly rows: { readonly host: ElementRef<HTMLElement> }[] = [];\n\n /** Row positions for one `items` array and row count, so a change sorts once however many rows ask. */\n private positions: {\n readonly items: unknown;\n readonly count: number;\n readonly map: Map<unknown, number>;\n } | null = null;\n\n /** Index of the row the keyboard is holding, or `null` when nothing is held. */\n readonly grabbedIndex = signal<number | null>(null);\n\n /** Live-region text. Written by the keyboard path only. */\n protected readonly announcement = signal('');\n\n private readonly uid = ++sortableListUid;\n\n /** Links every row to the key model via `aria-describedby`. */\n readonly keyHelpId = `wr-sortable-list-help-${this.uid}`;\n\n protected readonly fallbackId = `wr-sortable-list-${this.uid}`;\n\n private readonly keyHelp = wrReadI18nText(\n 'sortableList.keyHelp',\n 'Press Space to pick this item up, then use the arrow keys to move it. ' +\n 'Press Space again to drop it, or Escape to put it back.'\n );\n private readonly groupKeyHelp = wrReadI18nText(\n 'sortableList.groupKeyHelp',\n 'Press Space to pick this item up, then use the arrow keys to move it, within its list or into the next one. ' +\n 'Press Space again to drop it, or Escape to put it back.'\n );\n protected readonly resolvedKeyHelp = computed(() => (this.group() ? this.groupKeyHelp() : this.keyHelp()));\n\n private readonly grabbedText = useI18nFormatter('sortableList.grabbed', 'Grabbed. {{index}} of {{total}}.');\n private readonly movedText = useI18nFormatter('sortableList.moved', '{{index}} of {{total}}.');\n private readonly droppedText = useI18nFormatter('sortableList.dropped', 'Dropped. {{index}} of {{total}}.');\n private readonly cancelledText = wrReadI18nText('sortableList.cancelled', 'Move cancelled.');\n private readonly movedToText = useI18nFormatter('sortableList.movedTo', 'Moved to {{list}}. {{index}} of {{total}}.');\n private readonly listPositionText = useI18nFormatter('sortableList.listPosition', 'list {{index}} of {{total}}');\n\n /** Where the held row started, which can be another list. Escape puts it back there. */\n private grabOrigin: WrSortableMoveEnd<T> | null = null;\n\n /** True while a keyboard move is handing focus back — see `onRowFocusout`. */\n private restoringFocus = false;\n\n constructor() {\n this.lists.update(lists => [...lists, this]);\n inject(DestroyRef).onDestroy(() => this.lists.update(lists => lists.filter(list => list !== this)));\n\n const dropList = this.dropList;\n dropList.data = this;\n dropList.elementContainerSelector = '.wr-sortable-list__list';\n dropList.enterPredicate = (drag: CdkDrag<T>) => {\n const from = drag.dropContainer?.data as WrSortableList<T> | undefined;\n return !!from && this.accepts(drag.data, from);\n };\n dropList.dropped.subscribe((event: CdkDragDrop<WrSortableList<T>>) => this.onDrop(event));\n\n // Assigned, not bound: a host directive's inputs are out of a host binding's reach.\n effect(() => {\n dropList.id = this.id() ?? this.fallbackId;\n dropList.orientation = this.orientation();\n dropList.disabled = this.disabled();\n dropList.connectedTo = this.peers().map(list => list.dropList);\n });\n\n // The CDK resolves the selector above only on the list a drag STARTS in. A\n // list that only ever receives would append the placeholder to the host,\n // beside the rows' container rather than in it.\n afterNextRender(() => dropList._dropListRef.withElementContainer(this.listEl().nativeElement));\n }\n\n /** Rows whose pointer drag Escape cancelled; the drop that follows is ignored. */\n private readonly cancelledDrags = new WeakSet<object>();\n\n /** @internal A row's pointer drag was cancelled with Escape. */\n cancelDrag(drag: object): void {\n this.cancelledDrags.add(drag);\n }\n\n private onDrop(event: CdkDragDrop<WrSortableList<T>>): void {\n if (event.item && this.lists().some(list => list.cancelledDrags.delete(event.item))) return;\n if (event.previousContainer !== event.container) {\n const source = event.previousContainer.data;\n const item = source.removeAt(event.previousIndex);\n this.insertAt(item, event.currentIndex);\n this.move.emit({\n item,\n from: { list: source, index: event.previousIndex },\n to: { list: this, index: event.currentIndex },\n });\n return;\n }\n if (event.previousIndex === event.currentIndex) return;\n const next = this.items().slice();\n moveItemInArray(next, event.previousIndex, event.currentIndex);\n this.items.set(next);\n this.reorder.emit({\n items: next,\n previousIndex: event.previousIndex,\n currentIndex: event.currentIndex,\n item: next[event.currentIndex],\n });\n }\n\n /**\n * The keyboard reorder path: pick up, move, drop — deliberately a two-step\n * grab rather than \"an arrow moves the focused row\", so that arrowing through\n * a list a user is only reading can never rearrange it.\n *\n * Keys are handled only when the ROW itself is the event target; a button or\n * an input projected into the row template keeps every key it would normally\n * get.\n */\n /** @internal A row registering itself on construction. */\n register(item: { readonly host: ElementRef<HTMLElement> }): void {\n this.rows.push(item);\n }\n\n /**\n * @internal A row's position among its live siblings.\n *\n * Read off the DOM rather than off the registration order, because a row can\n * be added, removed or moved by the consumer's own loop and construction\n * order survives none of those. Rows whose element has left the document are\n * swept here, which is the only place that can tell.\n */\n indexOf(item: { readonly host: ElementRef<HTMLElement> }): number {\n this.sortRows();\n return this.rows.indexOf(item);\n }\n\n /**\n * @internal The same answer as `indexOf`, served from a map that is rebuilt\n * only when `items` or the number of rows changes. Reads `items`, so a\n * `computed` that calls it follows every reorder.\n */\n positionOf(item: { readonly host: ElementRef<HTMLElement> }): number {\n const items = this.items();\n let cache = this.positions;\n if (cache?.items !== items || cache.count !== this.rows.length) {\n this.sortRows();\n cache = {\n items,\n count: this.rows.length,\n map: new Map(this.rows.map((row, index) => [row, index] as const)),\n };\n this.positions = cache;\n }\n return cache.map.get(item) ?? -1;\n }\n\n /**\n * Drops rows whose element has left the document and puts the rest into\n * document order.\n *\n * Its own method because `relocate` needs it too: that one focuses\n * `rows[to]` after the move, and without a re-sort it reached into an array\n * still ordered as the list looked BEFORE the move.\n */\n private sortRows(): void {\n for (let i = this.rows.length - 1; i >= 0; i -= 1) {\n if (!this.rows[i].host.nativeElement.isConnected) this.rows.splice(i, 1);\n }\n this.rows.sort((a, b) => (follows(a.host.nativeElement, b.host.nativeElement) ? -1 : 1));\n }\n\n /** @internal */\n onRowKeydown(event: KeyboardEvent, index: number): void {\n if (this.disabled() || event.target !== event.currentTarget) return;\n\n const grabbed = this.grabbedIndex();\n const horizontal = this.orientation() === 'horizontal';\n // The horizontal arrows name a SIDE of the row, so they follow the reading\n // direction: a horizontal list under `dir=\"rtl\"` paints index 0 at the right,\n // so the key that raises the index is ArrowLeft. Raising it on ArrowRight\n // regardless moved the held item away from the arrow the user pressed — the\n // one failure in this set a user cannot rationalise, because it inverts their\n // model of the list silently. The block arrows name a value's direction in a\n // column and never mirror, which is why only the horizontal pair is swapped.\n const rtl = this.dir?.value === 'rtl';\n const inlineForward = rtl ? 'ArrowLeft' : 'ArrowRight';\n const inlineBack = rtl ? 'ArrowRight' : 'ArrowLeft';\n const forward = horizontal ? inlineForward : 'ArrowDown';\n const back = horizontal ? inlineBack : 'ArrowUp';\n // The arrows of the other axis walk the group: columns sit side by side, so\n // a vertical list hands the row over on the inline pair, mirrored like above.\n const nextList = horizontal ? 'ArrowDown' : inlineForward;\n const previousList = horizontal ? 'ArrowUp' : inlineBack;\n\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n if (grabbed === null) this.grab(index);\n else this.drop();\n return;\n }\n\n if (grabbed === null) return;\n\n if (event.key === 'Escape') {\n event.preventDefault();\n // Held only while a row is grabbed — an Escape typed anywhere else has to\n // keep reaching whatever dialog or overlay the list is sitting in.\n event.stopPropagation();\n this.cancelGrab();\n return;\n }\n\n if (event.key === forward || event.key === back) {\n event.preventDefault();\n this.moveGrabbed(event.key === forward ? 1 : -1);\n return;\n }\n\n if (this.group() && (event.key === nextList || event.key === previousList)) {\n event.preventDefault();\n this.moveToList(event.key === nextList ? 1 : -1);\n }\n }\n\n /**\n * Focus leaving a held row ends the gesture as a drop rather than dropping the\n * change on the floor — `[(items)]` has already been written by then, so a\n * silent release would leave `reorder` never reporting a move that happened.\n * The guard is what makes it safe: moving a focused node in the DOM blurs it,\n * so every keyboard move fires this too.\n */\n /** @internal */\n onRowFocusout(): void {\n if (this.restoringFocus || this.grabbedIndex() === null) return;\n this.drop();\n }\n\n private grab(index: number): void {\n this.grabOrigin = { list: this, index };\n this.grabbedIndex.set(index);\n this.announcement.set(this.grabbedText(this.position(index)));\n }\n\n private moveGrabbed(delta: number): void {\n const from = this.grabbedIndex();\n if (from === null) return;\n const to = from + delta;\n if (to < 0 || to >= this.items().length) return;\n\n this.relocate(from, to);\n this.grabbedIndex.set(to);\n this.announcement.set(this.movedText(this.position(to)));\n }\n\n /**\n * Hands the held row to the nearest list of the group, in document order,\n * that takes it. A list that refuses is stepped over, since a drag can reach\n * any list of the group and the keyboard must not reach fewer.\n */\n private moveToList(step: 1 | -1): void {\n const from = this.grabbedIndex();\n const origin = this.grabOrigin;\n if (from === null || !origin) return;\n\n const group = this.groupLists();\n const item = this.items()[from];\n let at = group.indexOf(this) + step;\n while (group[at] && !group[at].accepts(item, origin.list)) at += step;\n const target = group[at];\n if (!target) return;\n\n this.grabbedIndex.set(null);\n this.grabOrigin = null;\n this.announcement.set('');\n this.removeAt(from);\n\n const to = Math.min(from, target.items().length);\n target.insertAt(item, to);\n target.grabOrigin = origin;\n target.grabbedIndex.set(to);\n const list =\n target.ariaLabel() ?? target.listPositionText({ index: group.indexOf(target) + 1, total: group.length });\n target.announcement.set(target.movedToText({ list, ...target.position(to) }));\n target.focusRow(to);\n }\n\n private drop(): void {\n const to = this.grabbedIndex();\n const origin = this.grabOrigin;\n this.grabbedIndex.set(null);\n this.grabOrigin = null;\n if (to === null || !origin) return;\n\n this.announcement.set(this.droppedText(this.position(to)));\n if (origin.list !== this) {\n this.move.emit({ item: this.items()[to], from: origin, to: { list: this, index: to } });\n return;\n }\n if (origin.index === to) return;\n // One event per gesture, the way a drag emits one on drop — not one per\n // arrow press, which would put a host that persists on `reorder` through a\n // write per keystroke. `[(items)]` still updates on every press, because\n // the rendered order has to follow the row the user is moving.\n this.reorder.emit({ items: this.items(), previousIndex: origin.index, currentIndex: to, item: this.items()[to] });\n }\n\n private cancelGrab(): void {\n const from = this.grabbedIndex();\n const origin = this.grabOrigin;\n if (from === null || !origin) return;\n this.grabbedIndex.set(null);\n this.grabOrigin = null;\n\n if (origin.list === this) {\n if (from !== origin.index) this.relocate(from, origin.index);\n this.announcement.set(this.cancelledText());\n return;\n }\n this.announcement.set('');\n origin.list.insertAt(this.removeAt(from), origin.index);\n origin.list.announcement.set(origin.list.cancelledText());\n origin.list.focusRow(origin.index);\n }\n\n /** Whether this list takes `item` from another list of the group. */\n private accepts(item: T, from: WrSortableList<T>): boolean {\n return !this.disabled() && (from === this || (this.canEnter()?.(item, from) ?? true));\n }\n\n /** This list and its peers, in document order. */\n private groupLists(): WrSortableList<T>[] {\n return [this, ...this.peers()].sort((a, b) => (follows(a.host.nativeElement, b.host.nativeElement) ? -1 : 1));\n }\n\n private removeAt(index: number): T {\n const next = this.items().slice();\n const [item] = next.splice(index, 1);\n this.items.set(next);\n return item;\n }\n\n private insertAt(item: T, index: number): void {\n const next = this.items().slice();\n next.splice(index, 0, item);\n this.items.set(next);\n }\n\n private relocate(from: number, to: number): void {\n const next = this.items().slice();\n moveItemInArray(next, from, to);\n this.items.set(next);\n this.focusRow(to);\n }\n\n private focusRow(to: number): void {\n // The row is the same DOM node moved to another slot, and moving a focused\n // node hands focus back to `<body>` — so it has to be taken again once the\n // move has rendered. `afterNextRender`, never a microtask: zoneless change\n // detection runs in a macrotask, so a microtask would fire while the row is\n // still at its old index and focus the wrong one. (jsdom keeps focus across\n // a node move, so no spec here can express that half.)\n this.restoringFocus = true;\n afterNextRender(\n () => {\n // Re-sorted FIRST. `this.rows` is only ever put into document order by\n // `indexOf`, and nothing calls it between the move and here — so the\n // array was still in the order it had BEFORE the move, and `rows[to]`\n // was whichever row used to be at that slot. `sortRows()` is the same\n // sweep-and-sort `indexOf` runs; after it, index `to` is the row the\n // move actually put there.\n this.sortRows();\n this.rows[to]?.host.nativeElement.focus();\n this.restoringFocus = false;\n },\n { injector: this.injector }\n );\n }\n\n private position(index: number): { index: number; total: number } {\n return { index: index + 1, total: this.items().length };\n }\n}\n\nexport type { WrSortableCanEnter, WrSortableMoveEnd, WrSortableMoveEvent, WrSortableReorderEvent } from './types';\n","<!--\n `role=\"list\"` on the container and `role=\"listitem\"` on each row rather than\n bare divs: every row is a tab stop, and a focusable element with no role at\n all is announced as loose text. The list role is what gives the reader the\n position of the row focus lands on.\n\n Rows arrive through `<ng-content>` — the consumer writes the loop, so the\n markup says what each row is instead of hiding it in an unnamed template.\n-->\n<div #list role=\"list\" class=\"wr-sortable-list__list\" [attr.aria-label]=\"ariaLabel()\">\n <ng-content />\n @if (items().length === 0) {\n <!-- A row of its own, so the list announces what it shows; hidden by `:empty` when nothing is projected. -->\n <div role=\"listitem\" class=\"wr-sortable-list__empty\"><ng-content select=\"[wrSortableListEmpty]\" /></div>\n }\n</div>\n\n<!--\n The key model, on every row rather than once on the container: focus lands on\n a row and never on the list itself, so a description hung on the list would\n never be read out.\n-->\n<p class=\"wr-sortable-list__sr-only\" [id]=\"keyHelpId\">{{ resolvedKeyHelp() }}</p>\n\n<!--\n Position announcements, written by the keyboard path only — a drag already\n gives sighted feedback, and announcing every pointer move would flood the\n region.\n-->\n<p class=\"wr-sortable-list__sr-only\" role=\"status\">{{ announcement() }}</p>\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 { CdkDrag } from '@angular/cdk/drag-drop';\nimport { DOCUMENT } from '@angular/common';\nimport { Component, DestroyRef, ElementRef, ViewEncapsulation, computed, effect, inject } from '@angular/core';\n\nimport { wrCheckStyles, wrWatchDragCancel } from 'ngwr/utils';\n\nimport { WR_SORTABLE_LIST } from './tokens';\n\n/**\n * One row of a {@link WrSortableList}. Write the loop yourself and put whatever\n * the row shows inside it.\n *\n * It replaced a single unnamed `<ng-template let-row let-i=\"index\">` that the\n * list rendered per item. Two things were wrong with that. The template had no\n * name, so nothing in the markup said what the context variables were or where\n * they came from — a reader had to open the component to learn that `let-row`\n * is the item and `let-i` the index. And a row could not carry anything of its\n * own: every per-row decision had to be an input on the LIST, or a branch\n * inside one template.\n *\n * The row is the tab stop, so the keyboard contract lives here: Space or Enter\n * picks it up, the arrows move it, Space or Enter drops it, Escape puts it\n * back. The list owns the array and the announcements, and this delegates to\n * it — an item knows its own position and nothing else.\n *\n * @example\n * ```html\n * <wr-sortable-list [(items)]=\"rows\">\n * @for (row of rows(); track row.id) {\n * <wr-sortable-item>\n * <span wrDragHandle>≡</span>\n * {{ row.label }}\n * </wr-sortable-item>\n * }\n * </wr-sortable-list>\n * ```\n *\n * @see https://ngwr.dev/reference/components/sortable-list\n */\n@Component({\n selector: 'wr-sortable-item',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n hostDirectives: [CdkDrag],\n host: {\n class: 'wr-sortable-list__item',\n role: 'listitem',\n '[class.wr-sortable-list__item--grabbed]': 'grabbed()',\n '[attr.tabindex]': 'list.disabled() ? null : 0',\n '[attr.aria-describedby]': 'list.disabled() ? null : list.keyHelpId',\n '(keydown)': 'onKeydown($event)',\n '(focusout)': 'list.onRowFocusout()',\n },\n})\nexport class WrSortableItem {\n /** @internal The list this row belongs to. Read by the host bindings above. */\n protected readonly list = inject(WR_SORTABLE_LIST);\n\n private readonly drag = inject(CdkDrag);\n\n /** @internal */\n readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Position among the list's rows, which IS the index into `items()`: the\n * consumer's own loop renders them in that order.\n *\n * `positionOf` resolves by DOCUMENT ORDER and is keyed on the `items` ARRAY,\n * not its length: a reorder keeps the count, so a length-keyed index stayed\n * on the slot the row had left, the highlight stayed behind with it, and a\n * second pick-up of the same row moved its old neighbour instead. Host\n * bindings run after the consumer's `@for` has moved the nodes, so the\n * recomputation reads the new order.\n */\n protected readonly index = computed(() => this.list.positionOf(this));\n\n protected readonly grabbed = computed(() => this.list.grabbedIndex() === this.index());\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('sortable-list');\n this.list.register(this);\n\n // Assigned rather than bound, because these belong to the LIST and a host\n // binding cannot reach another directive's input. `CdkDrag` reads all\n // three as plain properties on every gesture, so writing them from an\n // effect is enough and a runtime change takes effect on the next drag.\n effect(() => {\n this.drag.disabled = this.list.disabled();\n this.drag.lockAxis = this.list.lockAxis() ?? null;\n this.drag.dragStartDelay = this.list.dragStartDelay();\n });\n\n // Escape cancels a pointer drag; CDK has no cancel of its own.\n const doc = inject(DOCUMENT);\n let stopCancel: (() => void) | null = null;\n this.drag.started.subscribe(event => {\n stopCancel?.();\n stopCancel = wrWatchDragCancel(doc, event.event, () => this.list.cancelDrag(this.drag));\n });\n this.drag.ended.subscribe(() => {\n stopCancel?.();\n stopCancel = null;\n });\n inject(DestroyRef).onDestroy(() => stopCancel?.());\n\n // What a connected list's `canEnter` is asked about.\n effect(() => {\n this.drag.data = this.list.items()[this.index()];\n });\n }\n\n /**\n * @internal Resolves the position at the moment of the key, off the DOM,\n * rather than through the cached `index`: nothing has to have rendered\n * between two presses for the answer to be right.\n */\n protected onKeydown(event: KeyboardEvent): void {\n this.list.onRowKeydown(event, this.list.indexOf(this));\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 { CdkDragHandle } from '@angular/cdk/drag-drop';\nimport { Directive } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Drag handle for {@link WrSortableList} (and any nested `cdkDrag`).\n * Composes CDK's `cdkDragHandle` via `hostDirectives` so consumers don't\n * need to import the CDK selector directly.\n *\n * @example\n * ```html\n * <wr-sortable-list [(items)]=\"rows\">\n * @for (row of rows(); track row.id) {\n * <wr-sortable-item>\n * <span wrDragHandle class=\"grip\">≡</span>\n * <span>{{ row.label }}</span>\n * </wr-sortable-item>\n * }\n * </wr-sortable-list>\n * ```\n */\n@Directive({\n selector: '[wrDragHandle]',\n hostDirectives: [CdkDragHandle],\n host: { class: 'wr-drag-handle' },\n})\nexport class WrDragHandle {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('sortable-list');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAa,mBAAmB,IAAI,eAAsC,kBAAkB;AAS5F,MAAa,oBAAoB,IAAI,eAA0D,qBAAqB;CAClH,YAAY;CACZ,eAAe,OAAkC,CAAA,CAAE;AACpD,CAAA;;;;;;;ACOD,SAAS,QAAQ,GAAgB,GAAc;CAE7C,QAAQ,EAAE,wBAAwB,CAAC,IAAI,KAAK,iCAAiC;AAC/E;AAGA,IAAI,kBAAkB;AAoEtB,IAAa,iBAAb,MAAa,eAAc;CAEhB,QAAQ,MAAM,SAAe,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAG7B,cAAc,MAAiC,YAAW,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAG1D,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI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3C,mBAAmB;IACnB,2BAA2B;IAC3B,aAAa;IACb,cAAc;GACf;EACF,CAAA;;;;;;;;;;AC1BD,IAAa,eAAb,MAAa,aAAY;CACvB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,eAAe;CAClF;CAHW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAY,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAZ,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAY,cAAA;EAAA,UAAA;EAAA,MAAA,EAAA,gBAAA,iBAAA;EAAA,gBAAA,CAAA,EAAA,WAAA,GAAA,cAAA,CAAA;EAAA,UAAA;CAAA,CAAA;;AAAZ,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAY,YAAA,CAAA;EALxB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,gBAAgB,CAAC,aAAa;GAC9B,MAAM,EAAE,OAAO,iBAAgB;EAChC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-storage.mjs","names":[],"sources":["../../../projects/lib/storage/storage-config.ts","../../../projects/lib/storage/storage-engine.ts","../../../projects/lib/storage/storage.ts","../../../projects/lib/storage/with-storage.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageConfigResolved } from './types';\n\nexport const DEFAULT_WR_STORAGE_CONFIG: WrStorageConfigResolved = {\n prefix: '',\n json: true,\n ttl: 0,\n};\n\nexport const WR_STORAGE_CONFIG = new InjectionToken<WrStorageConfigResolved>('WR_STORAGE_CONFIG', {\n providedIn: 'root',\n factory: () => DEFAULT_WR_STORAGE_CONFIG,\n});\n\nexport type { WrStorageConfig, WrStorageConfigResolved } from './types';\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageEngine } from './types';\n\n/**\n * Probe a `Storage` candidate to confirm it's writable. Safari private\n * mode, disabled cookies, and storage-blocked iframes all throw on\n * `setItem` — fall back to memory in those cases.\n */\nfunction probe(engine: WrStorageEngine): boolean {\n try {\n const k = '__wr_storage_probe__';\n engine.setItem(k, '1');\n engine.removeItem(k);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * In-memory implementation of `Storage`. Used as the SSR / private-mode\n * fallback. Exported so consumers can opt into it explicitly for tests.\n */\nexport function wrCreateMemoryStorage(): WrStorageEngine {\n const map = new Map<string, string>();\n return {\n get length(): number {\n return map.size;\n },\n clear(): void {\n map.clear();\n },\n getItem(key: string): string | null {\n return map.has(key) ? map.get(key)! : null;\n },\n key(i: number): string | null {\n return Array.from(map.keys())[i] ?? null;\n },\n removeItem(key: string): void {\n map.delete(key);\n },\n setItem(key: string, value: string): void {\n map.set(key, value);\n },\n };\n}\n\n/**\n * Injection token for the active storage engine. Provide it at BOOTSTRAP to\n * swap engines (e.g. `sessionStorage` for a tab-only app):\n *\n * ```ts\n * providers: [{ provide: WR_STORAGE_ENGINE, useValue: sessionStorage }]\n * ```\n *\n * Not at an arbitrary injector level: `WrStorage` is root-provided and reads\n * the token in a field initializer, so the singleton resolves its engine once\n * and a token re-provided on a lazy route or in a component's `providers`\n * reaches no existing `inject(WrStorage)` — every read and write still goes to\n * the engine the root instance already took, with nothing thrown and nothing\n * logged. A feature that genuinely needs its own engine provides its own\n * `WrStorage` beside it.\n *\n * The default factory returns `localStorage` in the browser when it's\n * actually writable, an in-memory map otherwise.\n */\nexport const WR_STORAGE_ENGINE = new InjectionToken<WrStorageEngine>('WR_STORAGE_ENGINE', {\n providedIn: 'root',\n factory: () => {\n try {\n // The getter itself throws a SecurityError when the browser blocks storage.\n if (typeof localStorage !== 'undefined' && probe(localStorage)) return localStorage;\n } catch {\n // Fall through to memory.\n }\n return wrCreateMemoryStorage();\n },\n});\n\nexport type { WrStorageEngine } from './types';\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Service,\n PLATFORM_ID,\n type Signal,\n type WritableSignal,\n inject,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WR_STORAGE_CONFIG } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\nimport type { WrStorageEnvelope } from './types';\n\nfunction isEnvelope(x: unknown): x is WrStorageEnvelope {\n return x !== null && typeof x === 'object' && 'v' in x;\n}\n\n/**\n * One key's signal. `sig.set` persists, so a refresh from storage goes through\n * `write`, the setter the signal was born with.\n */\ninterface Watcher {\n readonly sig: WritableSignal<unknown>;\n readonly fallback: unknown;\n readonly write: (value: unknown) => void;\n}\n\n/**\n * Reactive key/value storage on top of any `Storage`-compatible engine.\n *\n * - **Swap engines** through {@link WR_STORAGE_ENGINE} or\n * `provideWr(withStorage(...))`. Default: `localStorage` with an in-memory\n * fallback for SSR / private mode.\n * - **Namespacing** via `prefix` (config) — every key is transparently\n * prefixed on read / write.\n * - **TTL** per-call or default — values past their expiry are removed\n * lazily on the next `get` / `watch` read.\n * - **Reactive watch** — `watch(key)` returns a `Signal` that updates on\n * local writes and cross-tab `storage` events. `signal(key, default)` is the\n * writable twin: `set` and `update` persist as they go.\n * - **On-disk format** — values are wrapped in a {@link WrStorageEnvelope}\n * (`{\"v\":…,\"e\":…}`) while `json` is on. Anything reading the same key from\n * outside Angular has to unwrap it.\n *\n * SSR-safe: the default engine factory returns an in-memory shim when\n * `localStorage` is unavailable, so reads always work.\n *\n * @example\n * ```ts\n * const store = inject(WrStorage);\n *\n * store.set('user', { name: 'Ada' });\n * store.get<{ name: string }>('user'); // { name: 'Ada' }\n *\n * store.set('cart', items, { ttl: 60_000 }); // expires in 60s\n *\n * const theme = store.watch<'light' | 'dark'>('theme', 'light');\n * effect(() => console.log('theme is', theme()));\n *\n * const density = store.signal<'compact' | 'comfortable'>('density', 'comfortable');\n * density.set('compact'); // stored, and every tab follows\n * ```\n *\n * @see https://ngwr.dev/reference/services/storage\n */\n@Service()\nexport class WrStorage {\n private readonly engine = inject(WR_STORAGE_ENGINE);\n private readonly config = inject(WR_STORAGE_CONFIG);\n private readonly destroyRef = inject(DestroyRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /**\n * Per-key watchers. Shared so multiple `watch(k)` and `signal(k)` calls reuse\n * one signal.\n *\n * The fallback is kept alongside the signal because every refresh has to read\n * the key the same way `watch` first did. Refreshing without it made `get` and\n * `watch` disagree about what an ABSENT key means: after a `remove()` the\n * signal went to `null` while `get(key, fallback)` still answered with the\n * default, so a consumer watching `'theme'` with a `'light'` fallback got no\n * theme at all rather than the light one.\n */\n private readonly watchers = new Map<string, Watcher>();\n private listenerInstalled = false;\n\n // Public API\n\n /**\n * Is `key` present? A raw presence check: it does not parse the envelope, so\n * an EXPIRED entry still answers `true` until something reads it — `get()`\n * is what notices the TTL and removes the key on its way out. Branch on\n * `get() !== null` when the answer has to respect expiry; this one is for\n * \"is there anything under this key at all\", quota accounting included.\n */\n has(key: string): boolean {\n return this.engine.getItem(this.fullKey(key)) !== null;\n }\n\n /**\n * Read `key`. Returns `fallback` (default `null`) when the key is\n * missing or expired. Expired values are also removed as a side effect.\n */\n get<T = unknown>(key: string, fallback: T | null = null): T | null {\n const fk = this.fullKey(key);\n const raw = this.engine.getItem(fk);\n if (raw === null) return fallback;\n\n if (!this.config.json) return raw as unknown as T;\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // Non-JSON value written by external code — return as-is.\n return raw as unknown as T;\n }\n\n if (!isEnvelope(parsed)) return parsed as T;\n\n if (parsed.e !== undefined && parsed.e < Date.now()) {\n this.remove(key);\n return fallback;\n }\n return parsed.v as T;\n }\n\n /**\n * Write `value` at `key`. Per-call `ttl` (ms) overrides the config\n * default. JSON-serializable values only when `json` is on (the default).\n *\n * What lands in the engine is a {@link WrStorageEnvelope} —\n * `{\"v\":<value>}`, plus `\"e\"` when a TTL applies — not the bare value. Code\n * outside Angular that reads the same key has to unwrap it; see the envelope's\n * own docs for the exact format.\n */\n set<T = unknown>(key: string, value: T, opts?: { ttl?: number }): void {\n if (this.persist(key, value, opts)) this.notify(key);\n }\n\n /** Remove `key`. No-op when absent. */\n remove(key: string): void {\n this.engine.removeItem(this.fullKey(key));\n this.notify(key);\n }\n\n /**\n * Clear every key owned by this prefix. When `prefix` is empty this\n * defers to `engine.clear()` (clears everything — be careful with\n * shared storage).\n */\n clear(): void {\n const p = this.config.prefix;\n if (p) {\n for (const fk of this.rawKeys()) this.engine.removeItem(fk);\n } else {\n this.engine.clear();\n }\n // Refresh every active watcher — they may have just been cleared.\n this.refreshAll();\n }\n\n /** All known keys under our prefix, with the prefix stripped. */\n keys(): readonly string[] {\n const p = this.config.prefix;\n return this.rawKeys().map(k => (p ? k.slice(p.length) : k));\n }\n\n /**\n * Reactive read of `key`. Updates when this instance writes to the key,\n * when `clear()` runs, and when another tab updates `localStorage`\n * under the same prefix. Returned signal is shared per key — calling\n * `watch(k)` twice returns the same signal.\n */\n watch<T = unknown>(key: string, fallback: T | null = null): Signal<T | null> {\n return (this.watcher(key, fallback).sig as WritableSignal<T | null>).asReadonly();\n }\n\n /**\n * Writable twin of {@link watch}: `set` and `update` store the value, then\n * the signal takes it. The signal is the one `watch(key)` reads, so a\n * `set()`, `remove()` or `clear()` on this instance moves it too, and so does\n * a write from another tab; a key another tab removes goes back to\n * `defaultValue`. Shared per key, so a second `signal(key)` is the same\n * signal and the first call's default stands.\n *\n * A `set` to the value it already holds (`Object.is`) writes nothing, like a\n * plain signal. A write the engine refuses (quota, storage disabled) is\n * logged and dropped exactly as `set()` does, and nothing throws: the signal\n * keeps the new value for this tab, and the next load reads what was stored\n * before.\n *\n * On the server it reads the engine as `watch()` does, so with the default\n * in-memory engine it holds `defaultValue`, and no `storage` listener is\n * installed. Hydration: the server renders that default and the browser\n * instance reads `localStorage` when it is created, so the first client\n * render can differ from the server markup, as with `watch()`.\n */\n signal<T>(key: string, defaultValue: T): WritableSignal<T> {\n return this.watcher(key, defaultValue).sig as WritableSignal<T>;\n }\n\n // Internals\n\n private fullKey(key: string): string {\n return this.config.prefix + key;\n }\n\n private watcher(key: string, fallback: unknown): Watcher {\n const existing = this.watchers.get(key);\n if (existing) return existing;\n\n const sig = signal<unknown>(this.get(key, fallback));\n const write = sig.set.bind(sig);\n sig.set = value => {\n if (Object.is(value, untracked(sig))) return;\n this.persist(key, value);\n write(value);\n };\n sig.update = fn => sig.set(fn(untracked(sig)));\n\n const entry: Watcher = { sig, fallback, write };\n this.watchers.set(key, entry);\n this.installCrossTabListener();\n return entry;\n }\n\n /** Serialize and store. `false` when nothing landed in the engine. */\n private persist<T>(key: string, value: T, opts?: { ttl?: number }): boolean {\n const fk = this.fullKey(key);\n let serialized: string;\n\n if (this.config.json) {\n const ttl = opts?.ttl ?? this.config.ttl;\n const env: WrStorageEnvelope<T> = ttl ? { v: value, e: Date.now() + ttl } : { v: value };\n try {\n serialized = JSON.stringify(env);\n } catch (err) {\n // eslint-disable-next-line no-console -- intentional diagnostic for unserialisable values\n console.warn('[ngwr/storage] value not JSON-serializable', err);\n return false;\n }\n } else {\n serialized = String(value);\n }\n\n try {\n this.engine.setItem(fk, serialized);\n } catch (err) {\n // Quota exceeded / disabled / cleared mid-write — log + carry on.\n // eslint-disable-next-line no-console -- intentional diagnostic on storage write failure\n console.warn('[ngwr/storage] setItem failed', err);\n return false;\n }\n return true;\n }\n\n private notify(key: string): void {\n const entry = this.watchers.get(key);\n if (entry) entry.write(this.get(key, entry.fallback));\n }\n\n private refreshAll(): void {\n for (const [k, entry] of this.watchers) entry.write(this.get(k, entry.fallback));\n }\n\n private rawKeys(): string[] {\n const p = this.config.prefix;\n const out: string[] = [];\n for (let i = 0; i < this.engine.length; i++) {\n const k = this.engine.key(i);\n if (k === null) continue;\n if (!p || k.startsWith(p)) out.push(k);\n }\n return out;\n }\n\n private installCrossTabListener(): void {\n if (!this.isBrowser || this.listenerInstalled) return;\n this.listenerInstalled = true;\n\n const handler = (event: StorageEvent): void => {\n // `storage` only fires for `localStorage` / `sessionStorage`, and\n // only for changes from OTHER tabs. Local writes are handled by\n // `notify()` in `set`/`remove`/`clear`.\n if (event.key === null) {\n // Storage cleared from another tab.\n this.refreshAll();\n return;\n }\n const p = this.config.prefix;\n if (p && !event.key.startsWith(p)) return;\n this.notify(p ? event.key.slice(p.length) : event.key);\n };\n\n window.addEventListener('storage', handler);\n\n // The listener belongs to THIS injector. Root-provided it lives as long as\n // the page, but a route or component that lists `WrStorage` in its own\n // `providers` used to leave the handler on the window after its injector was\n // gone — still driving the watcher signals of a destroyed instance, and\n // holding the instance and every signal in it reachable for the life of the\n // page. Same bug `WrHotkey` already fixed once.\n this.destroyRef.onDestroy(() => {\n window.removeEventListener('storage', handler);\n this.listenerInstalled = false;\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { Provider } from '@angular/core';\n\nimport { type WrFeature, wrFeature } from 'ngwr/utils';\n\nimport { DEFAULT_WR_STORAGE_CONFIG, WR_STORAGE_CONFIG, type WrStorageConfigResolved } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\nimport type { WrStorageOptions } from './types';\n\n/**\n * Configure {@link WrStorage}, as a feature of `provideWr()`. All fields\n * optional — merged with defaults.\n *\n * Bootstrap only: {@link WrStorage} is root-provided and resolves its engine\n * and config once, from the root injector — see {@link WR_STORAGE_ENGINE}.\n *\n * @example Override the engine globally (e.g. session storage)\n * ```ts\n * import { provideWr } from 'ngwr';\n * import { withStorage } from 'ngwr/storage';\n *\n * providers: [provideWr(withStorage({ engine: sessionStorage }))]\n * ```\n *\n * @example Lazy engine factory (e.g. wrap localStorage with encryption)\n * ```ts\n * provideWr(withStorage({ engine: () => new EncryptedStorage(localStorage, key) }))\n * ```\n *\n * @example Namespace + auto-expire\n * ```ts\n * provideWr(withStorage({ prefix: 'myapp:', ttl: 24 * 60 * 60 * 1000 }))\n * ```\n */\nexport function withStorage(options: WrStorageOptions = {}): WrFeature<'storage'> {\n const { engine, ...config } = options;\n\n const merged: WrStorageConfigResolved = { ...DEFAULT_WR_STORAGE_CONFIG, ...config };\n\n const providers: Provider[] = [{ provide: WR_STORAGE_CONFIG, useValue: merged }];\n\n if (engine !== undefined) {\n providers.push(\n typeof engine === 'function'\n ? { provide: WR_STORAGE_ENGINE, useFactory: engine }\n : { provide: WR_STORAGE_ENGINE, useValue: engine }\n );\n }\n\n return wrFeature('storage', providers);\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAa,4BAAqD;CAChE,QAAQ;CACR,MAAM;CACN,KAAK;AACN;AAED,MAAa,oBAAoB,IAAI,eAAwC,qBAAqB;CAChG,YAAY;CACZ,eAAe;AAChB,CAAA;;;;;;;ACJD,SAAS,MAAM,QAAuB;CACpC,IAAI;EACF,MAAM,IAAI;EACV,OAAO,QAAQ,GAAG,GAAG;EACrB,OAAO,WAAW,CAAC;EACnB,OAAO;CACT,QAAQ;EACN,OAAO;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,IAAK;EACxC;EACA,IAAI,GAAS;GACX,OAAO,MAAM,KAAK,IAAI,KAAI,CAAE,CAAC,CAAC,MAAM;EACtC;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B,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"}
|
|
1
|
+
{"version":3,"file":"ngwr-storage.mjs","names":[],"sources":["../../../projects/lib/storage/storage-config.ts","../../../projects/lib/storage/storage-engine.ts","../../../projects/lib/storage/storage.ts","../../../projects/lib/storage/with-storage.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageConfigResolved } from './types';\n\nexport const DEFAULT_WR_STORAGE_CONFIG: WrStorageConfigResolved = {\n prefix: '',\n json: true,\n ttl: 0,\n};\n\nexport const WR_STORAGE_CONFIG = new InjectionToken<WrStorageConfigResolved>('WR_STORAGE_CONFIG', {\n providedIn: 'root',\n factory: () => DEFAULT_WR_STORAGE_CONFIG,\n});\n\nexport type { WrStorageConfig, WrStorageConfigResolved } from './types';\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageEngine } from './types';\n\n/**\n * Probe a `Storage` candidate to confirm it's writable. Safari private\n * mode, disabled cookies, and storage-blocked iframes all throw on\n * `setItem` — fall back to memory in those cases.\n */\nfunction probe(engine: WrStorageEngine): boolean {\n try {\n const k = '__wr_storage_probe__';\n engine.setItem(k, '1');\n engine.removeItem(k);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * In-memory implementation of `Storage`. Used as the SSR / private-mode\n * fallback. Exported so consumers can opt into it explicitly for tests.\n */\nexport function wrCreateMemoryStorage(): WrStorageEngine {\n const map = new Map<string, string>();\n return {\n get length(): number {\n return map.size;\n },\n clear(): void {\n map.clear();\n },\n getItem(key: string): string | null {\n return map.has(key) ? map.get(key)! : null;\n },\n key(i: number): string | null {\n return Array.from(map.keys())[i] ?? null;\n },\n removeItem(key: string): void {\n map.delete(key);\n },\n setItem(key: string, value: string): void {\n map.set(key, value);\n },\n };\n}\n\n/**\n * Injection token for the active storage engine. Provide it at BOOTSTRAP to\n * swap engines (e.g. `sessionStorage` for a tab-only app):\n *\n * ```ts\n * providers: [{ provide: WR_STORAGE_ENGINE, useValue: sessionStorage }]\n * ```\n *\n * Not at an arbitrary injector level: `WrStorage` is root-provided and reads\n * the token in a field initializer, so the singleton resolves its engine once\n * and a token re-provided on a lazy route or in a component's `providers`\n * reaches no existing `inject(WrStorage)` — every read and write still goes to\n * the engine the root instance already took, with nothing thrown and nothing\n * logged. A feature that genuinely needs its own engine provides its own\n * `WrStorage` beside it.\n *\n * The default factory returns `localStorage` in the browser when it's\n * actually writable, an in-memory map otherwise.\n */\nexport const WR_STORAGE_ENGINE = new InjectionToken<WrStorageEngine>('WR_STORAGE_ENGINE', {\n providedIn: 'root',\n factory: () => {\n try {\n // The getter itself throws a SecurityError when the browser blocks storage.\n if (typeof localStorage !== 'undefined' && probe(localStorage)) return localStorage;\n } catch {\n // Fall through to memory.\n }\n return wrCreateMemoryStorage();\n },\n});\n\nexport type { WrStorageEngine } from './types';\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Service,\n PLATFORM_ID,\n type Signal,\n type WritableSignal,\n inject,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WR_STORAGE_CONFIG } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\nimport type { WrStorageEnvelope } from './types';\n\nfunction isEnvelope(x: unknown): x is WrStorageEnvelope {\n return x !== null && typeof x === 'object' && 'v' in x;\n}\n\n/**\n * One key's signal. `sig.set` persists, so a refresh from storage goes through\n * `write`, the setter the signal was born with.\n */\ninterface Watcher {\n readonly sig: WritableSignal<unknown>;\n readonly fallback: unknown;\n readonly write: (value: unknown) => void;\n}\n\n/**\n * Reactive key/value storage on top of any `Storage`-compatible engine.\n *\n * - **Swap engines** through {@link WR_STORAGE_ENGINE} or\n * `provideWr(withStorage(...))`. Default: `localStorage` with an in-memory\n * fallback for SSR / private mode.\n * - **Namespacing** via `prefix` (config) — every key is transparently\n * prefixed on read / write.\n * - **TTL** per-call or default — values past their expiry are removed\n * lazily on the next `get` / `watch` read.\n * - **Reactive watch** — `watch(key)` returns a `Signal` that updates on\n * local writes and cross-tab `storage` events. `signal(key, default)` is the\n * writable twin: `set` and `update` persist as they go.\n * - **On-disk format** — values are wrapped in a {@link WrStorageEnvelope}\n * (`{\"v\":…,\"e\":…}`) while `json` is on. Anything reading the same key from\n * outside Angular has to unwrap it.\n *\n * SSR-safe: the default engine factory returns an in-memory shim when\n * `localStorage` is unavailable, so reads always work.\n *\n * @example\n * ```ts\n * const store = inject(WrStorage);\n *\n * store.set('user', { name: 'Ada' });\n * store.get<{ name: string }>('user'); // { name: 'Ada' }\n *\n * store.set('cart', items, { ttl: 60_000 }); // expires in 60s\n *\n * const theme = store.watch<'light' | 'dark'>('theme', 'light');\n * effect(() => console.log('theme is', theme()));\n *\n * const density = store.signal<'compact' | 'comfortable'>('density', 'comfortable');\n * density.set('compact'); // stored, and every tab follows\n * ```\n *\n * @see https://ngwr.dev/reference/services/storage\n */\n@Service()\nexport class WrStorage {\n private readonly engine = inject(WR_STORAGE_ENGINE);\n private readonly config = inject(WR_STORAGE_CONFIG);\n private readonly destroyRef = inject(DestroyRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /**\n * Per-key watchers. Shared so multiple `watch(k)` and `signal(k)` calls reuse\n * one signal.\n *\n * The fallback is kept alongside the signal because every refresh has to read\n * the key the same way `watch` first did. Refreshing without it made `get` and\n * `watch` disagree about what an ABSENT key means: after a `remove()` the\n * signal went to `null` while `get(key, fallback)` still answered with the\n * default, so a consumer watching `'theme'` with a `'light'` fallback got no\n * theme at all rather than the light one.\n */\n private readonly watchers = new Map<string, Watcher>();\n private listenerInstalled = false;\n\n // Public API\n\n /**\n * Is `key` present? A raw presence check: it does not parse the envelope, so\n * an EXPIRED entry still answers `true` until something reads it — `get()`\n * is what notices the TTL and removes the key on its way out. Branch on\n * `get() !== null` when the answer has to respect expiry; this one is for\n * \"is there anything under this key at all\", quota accounting included.\n */\n has(key: string): boolean {\n return this.engine.getItem(this.fullKey(key)) !== null;\n }\n\n /**\n * Read `key`. Returns `fallback` (default `null`) when the key is\n * missing or expired. Expired values are also removed as a side effect.\n */\n get<T = unknown>(key: string, fallback: T | null = null): T | null {\n const fk = this.fullKey(key);\n const raw = this.engine.getItem(fk);\n if (raw === null) return fallback;\n\n if (!this.config.json) return raw as unknown as T;\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // Non-JSON value written by external code — return as-is.\n return raw as unknown as T;\n }\n\n if (!isEnvelope(parsed)) return parsed as T;\n\n if (parsed.e !== undefined && parsed.e < Date.now()) {\n // Watchers are written untracked: a read inside a computed or template must not write signals.\n untracked(() => this.remove(key));\n return fallback;\n }\n return parsed.v as T;\n }\n\n /**\n * Write `value` at `key`. Per-call `ttl` (ms) overrides the config\n * default. JSON-serializable values only when `json` is on (the default).\n *\n * What lands in the engine is a {@link WrStorageEnvelope} —\n * `{\"v\":<value>}`, plus `\"e\"` when a TTL applies — not the bare value. Code\n * outside Angular that reads the same key has to unwrap it; see the envelope's\n * own docs for the exact format.\n */\n set<T = unknown>(key: string, value: T, opts?: { ttl?: number }): void {\n if (this.persist(key, value, opts)) this.notify(key);\n }\n\n /** Remove `key`. No-op when absent. */\n remove(key: string): void {\n this.engine.removeItem(this.fullKey(key));\n this.notify(key);\n }\n\n /**\n * Clear every key owned by this prefix. When `prefix` is empty this\n * defers to `engine.clear()` (clears everything — be careful with\n * shared storage).\n */\n clear(): void {\n const p = this.config.prefix;\n if (p) {\n for (const fk of this.rawKeys()) this.engine.removeItem(fk);\n } else {\n this.engine.clear();\n }\n // Refresh every active watcher — they may have just been cleared.\n this.refreshAll();\n }\n\n /** All known keys under our prefix, with the prefix stripped. */\n keys(): readonly string[] {\n const p = this.config.prefix;\n return this.rawKeys().map(k => (p ? k.slice(p.length) : k));\n }\n\n /**\n * Reactive read of `key`. Updates when this instance writes to the key,\n * when `clear()` runs, and when another tab updates `localStorage`\n * under the same prefix. Returned signal is shared per key — calling\n * `watch(k)` twice returns the same signal.\n */\n watch<T = unknown>(key: string, fallback: T | null = null): Signal<T | null> {\n return (this.watcher(key, fallback).sig as WritableSignal<T | null>).asReadonly();\n }\n\n /**\n * Writable twin of {@link watch}: `set` and `update` store the value, then\n * the signal takes it. The signal is the one `watch(key)` reads, so a\n * `set()`, `remove()` or `clear()` on this instance moves it too, and so does\n * a write from another tab; a key another tab removes goes back to\n * `defaultValue`. Shared per key, so a second `signal(key)` is the same\n * signal and the first call's default stands.\n *\n * A `set` to the value it already holds (`Object.is`) writes nothing, like a\n * plain signal. A write the engine refuses (quota, storage disabled) is\n * logged and dropped exactly as `set()` does, and nothing throws: the signal\n * keeps the new value for this tab, and the next load reads what was stored\n * before.\n *\n * On the server it reads the engine as `watch()` does, so with the default\n * in-memory engine it holds `defaultValue`, and no `storage` listener is\n * installed. Hydration: the server renders that default and the browser\n * instance reads `localStorage` when it is created, so the first client\n * render can differ from the server markup, as with `watch()`.\n */\n signal<T>(key: string, defaultValue: T): WritableSignal<T> {\n return this.watcher(key, defaultValue).sig as WritableSignal<T>;\n }\n\n // Internals\n\n private fullKey(key: string): string {\n return this.config.prefix + key;\n }\n\n private watcher(key: string, fallback: unknown): Watcher {\n const existing = this.watchers.get(key);\n if (existing) return existing;\n\n const sig = signal<unknown>(this.get(key, fallback));\n const write = sig.set.bind(sig);\n sig.set = value => {\n if (Object.is(value, untracked(sig))) return;\n this.persist(key, value);\n write(value);\n };\n sig.update = fn => sig.set(fn(untracked(sig)));\n\n const entry: Watcher = { sig, fallback, write };\n this.watchers.set(key, entry);\n this.installCrossTabListener();\n return entry;\n }\n\n /** Serialize and store. `false` when nothing landed in the engine. */\n private persist<T>(key: string, value: T, opts?: { ttl?: number }): boolean {\n const fk = this.fullKey(key);\n let serialized: string;\n\n if (this.config.json) {\n const ttl = opts?.ttl ?? this.config.ttl;\n const env: WrStorageEnvelope<T> = ttl ? { v: value, e: Date.now() + ttl } : { v: value };\n try {\n serialized = JSON.stringify(env);\n } catch (err) {\n // eslint-disable-next-line no-console -- intentional diagnostic for unserialisable values\n console.warn('[ngwr/storage] value not JSON-serializable', err);\n return false;\n }\n } else {\n serialized = String(value);\n }\n\n try {\n this.engine.setItem(fk, serialized);\n } catch (err) {\n // Quota exceeded / disabled / cleared mid-write — log + carry on.\n // eslint-disable-next-line no-console -- intentional diagnostic on storage write failure\n console.warn('[ngwr/storage] setItem failed', err);\n return false;\n }\n return true;\n }\n\n private notify(key: string): void {\n const entry = this.watchers.get(key);\n if (entry) entry.write(this.get(key, entry.fallback));\n }\n\n private refreshAll(): void {\n for (const [k, entry] of this.watchers) entry.write(this.get(k, entry.fallback));\n }\n\n private rawKeys(): string[] {\n const p = this.config.prefix;\n const out: string[] = [];\n for (let i = 0; i < this.engine.length; i++) {\n const k = this.engine.key(i);\n if (k === null) continue;\n if (!p || k.startsWith(p)) out.push(k);\n }\n return out;\n }\n\n private installCrossTabListener(): void {\n if (!this.isBrowser || this.listenerInstalled) return;\n this.listenerInstalled = true;\n\n const handler = (event: StorageEvent): void => {\n // `storage` only fires for `localStorage` / `sessionStorage`, and\n // only for changes from OTHER tabs. Local writes are handled by\n // `notify()` in `set`/`remove`/`clear`.\n if (event.key === null) {\n // Storage cleared from another tab.\n this.refreshAll();\n return;\n }\n const p = this.config.prefix;\n if (p && !event.key.startsWith(p)) return;\n this.notify(p ? event.key.slice(p.length) : event.key);\n };\n\n window.addEventListener('storage', handler);\n\n // The listener belongs to THIS injector. Root-provided it lives as long as\n // the page, but a route or component that lists `WrStorage` in its own\n // `providers` used to leave the handler on the window after its injector was\n // gone — still driving the watcher signals of a destroyed instance, and\n // holding the instance and every signal in it reachable for the life of the\n // page. Same bug `WrHotkey` already fixed once.\n this.destroyRef.onDestroy(() => {\n window.removeEventListener('storage', handler);\n this.listenerInstalled = false;\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { Provider } from '@angular/core';\n\nimport { type WrFeature, wrFeature } from 'ngwr/utils';\n\nimport { DEFAULT_WR_STORAGE_CONFIG, WR_STORAGE_CONFIG, type WrStorageConfigResolved } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\nimport type { WrStorageOptions } from './types';\n\n/**\n * Configure {@link WrStorage}, as a feature of `provideWr()`. All fields\n * optional — merged with defaults.\n *\n * Bootstrap only: {@link WrStorage} is root-provided and resolves its engine\n * and config once, from the root injector — see {@link WR_STORAGE_ENGINE}.\n *\n * @example Override the engine globally (e.g. session storage)\n * ```ts\n * import { provideWr } from 'ngwr';\n * import { withStorage } from 'ngwr/storage';\n *\n * providers: [provideWr(withStorage({ engine: sessionStorage }))]\n * ```\n *\n * @example Lazy engine factory (e.g. wrap localStorage with encryption)\n * ```ts\n * provideWr(withStorage({ engine: () => new EncryptedStorage(localStorage, key) }))\n * ```\n *\n * @example Namespace + auto-expire\n * ```ts\n * provideWr(withStorage({ prefix: 'myapp:', ttl: 24 * 60 * 60 * 1000 }))\n * ```\n */\nexport function withStorage(options: WrStorageOptions = {}): WrFeature<'storage'> {\n const { engine, ...config } = options;\n\n const merged: WrStorageConfigResolved = { ...DEFAULT_WR_STORAGE_CONFIG, ...config };\n\n const providers: Provider[] = [{ provide: WR_STORAGE_CONFIG, useValue: merged }];\n\n if (engine !== undefined) {\n providers.push(\n typeof engine === 'function'\n ? { provide: WR_STORAGE_ENGINE, useFactory: engine }\n : { provide: WR_STORAGE_ENGINE, useValue: engine }\n );\n }\n\n return wrFeature('storage', providers);\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAa,4BAAqD;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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AAS;AACvC"}
|
package/fesm2022/ngwr-switch.mjs
CHANGED
|
@@ -130,7 +130,7 @@ var WrSwitch = class WrSwitch {
|
|
|
130
130
|
isSignal: true
|
|
131
131
|
}],
|
|
132
132
|
ngImport: i0,
|
|
133
|
-
template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n",
|
|
133
|
+
template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-required]=\"fieldAria.ariaRequired()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n",
|
|
134
134
|
encapsulation: i0.ViewEncapsulation.None
|
|
135
135
|
});
|
|
136
136
|
};
|
|
@@ -149,7 +149,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
149
149
|
"[class]": "classes()",
|
|
150
150
|
"[attr.id]": "null"
|
|
151
151
|
},
|
|
152
|
-
template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n"
|
|
152
|
+
template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-required]=\"fieldAria.ariaRequired()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n"
|
|
153
153
|
}]
|
|
154
154
|
}],
|
|
155
155
|
ctorParameters: () => [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-switch.mjs","names":[],"sources":["../../../projects/lib/switch/switch.ts","../../../projects/lib/switch/switch.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n type ElementRef,\n ViewEncapsulation,\n computed,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\nimport type { FormCheckboxControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Boolean toggle with an iOS-style slider.\n *\n * A signal-forms native control: it implements `FormCheckboxControl`, so\n * `[formField]` binds straight to its `checked` model — no\n * `ControlValueAccessor` in between. `[(checked)]` works standalone.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-switch [formField]=\"form.notifications\">Notifications</wr-switch>\n *\n * <!-- standalone two-way binding -->\n * <wr-switch [(checked)]=\"enabled\">Notifications</wr-switch>\n * ```\n *\n * @see https://ngwr.dev/reference/components/switch\n */\nexport type WrSwitchSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-switch',\n templateUrl: './switch.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-switch',\n '[class]': 'classes()',\n // The `id` input belongs to the native input, not to this element — a static\n // `id=\"x\"` would otherwise be written here too and leave the document with\n // two elements sharing it, which is what broke `<label for>`.\n '[attr.id]': 'null',\n },\n})\nexport class WrSwitch implements FormCheckboxControl {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('switch');\n }\n\n /**\n * Accessible name for a switch used WITHOUT projected text. The wrapping\n * `<label>` names the control whenever content is projected; with none, the\n * label is empty and the input has no name at all.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /**\n * Stable id used to associate the native input with its label. Lands on the\n * inner `<input>`; the host never keeps it.\n */\n readonly id = input<string>(wrRandomId('wr-switch'));\n\n /**\n * Disable the switch. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse edits while staying focusable and submittable. Bound automatically\n * from the field's readonly state when used with `[formField]`.\n *\n * A native checkbox ignores the `readonly` attribute, so this cancels the\n * click's activation behaviour instead — which covers Space too, since the key\n * arrives as a click — and mirrors the state as `aria-readonly`, which role\n * `switch` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrSwitchSize>('md');\n\n /** On / off state. Bound by `[formField]`, or two-way via `[(checked)]`. */\n readonly checked = model<boolean>(false);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n private readonly native = viewChild.required<ElementRef<HTMLInputElement>>('native');\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-switch--${size}`);\n if (this.checked()) parts.push('wr-switch--checked');\n if (this.disabled()) parts.push('wr-switch--disabled');\n else if (this.readonly()) parts.push('wr-switch--readonly');\n return parts.join(' ');\n });\n\n /**\n * Focus the switch — what Signal Forms calls to focus this control. The native\n * input takes it, since the host has no tab stop of its own; a disabled switch\n * refuses, as a disabled input always does.\n */\n focus(options?: FocusOptions): void {\n this.native().nativeElement.focus(options);\n }\n\n // Template handlers\n\n /**\n * Cancel the toggle while readonly. `change` never fires for a click whose\n * default was prevented, so this is the only guard the pointer and Space paths\n * need; `onInputChange` keeps its own for a synthetic `change`.\n */\n protected onInputClick(event: Event): void {\n if (this.readonly()) event.preventDefault();\n }\n\n protected onInputChange(event: Event): void {\n if (this.readonly()) {\n // A synthetic `change` cannot be prevented — put the DOM back instead.\n (event.target as HTMLInputElement).checked = this.checked();\n return;\n }\n this.checked.set((event.target as HTMLInputElement).checked);\n }\n\n protected onInputBlur(): void {\n this.touch.emit();\n }\n}\n","<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n"],"mappings":";;;;;;;;;;;AAwDA,IAAa,WAAb,MAAa,SAAQ;CACnB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,QAAQ;CAC3E;CAOS,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAMtC,KAAK,MAAc,WAAW,WAAW,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAQ3C,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAa1D,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAGhD,YAAY,iBAAgB;CAGtC,OAAO,MAAoB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAGhC,UAAU,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAG/B,QAAQ,OAAM;CAEN,SAAS,UAAU,SAAuC,UAAS,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAA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IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,MAAA;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,SAAA;GAAA,SAAA;GAAA,OAAA;EAAA;EAAA,MAAA;GAAA,YAAA;IAAA,SAAA;IAAA,WAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,aAAA,CAAA;GAAA,cAAA;GAAA,OAAA;GAAA,WAAA,CAAA,QAAA;GAAA,aAAA;GAAA,UAAA;EAAA,CAAA;EAAA,UAAA;EAAA,UCxDrB;
|
|
1
|
+
{"version":3,"file":"ngwr-switch.mjs","names":[],"sources":["../../../projects/lib/switch/switch.ts","../../../projects/lib/switch/switch.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n type ElementRef,\n ViewEncapsulation,\n computed,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\nimport type { FormCheckboxControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Boolean toggle with an iOS-style slider.\n *\n * A signal-forms native control: it implements `FormCheckboxControl`, so\n * `[formField]` binds straight to its `checked` model — no\n * `ControlValueAccessor` in between. `[(checked)]` works standalone.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-switch [formField]=\"form.notifications\">Notifications</wr-switch>\n *\n * <!-- standalone two-way binding -->\n * <wr-switch [(checked)]=\"enabled\">Notifications</wr-switch>\n * ```\n *\n * @see https://ngwr.dev/reference/components/switch\n */\nexport type WrSwitchSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-switch',\n templateUrl: './switch.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-switch',\n '[class]': 'classes()',\n // The `id` input belongs to the native input, not to this element — a static\n // `id=\"x\"` would otherwise be written here too and leave the document with\n // two elements sharing it, which is what broke `<label for>`.\n '[attr.id]': 'null',\n },\n})\nexport class WrSwitch implements FormCheckboxControl {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('switch');\n }\n\n /**\n * Accessible name for a switch used WITHOUT projected text. The wrapping\n * `<label>` names the control whenever content is projected; with none, the\n * label is empty and the input has no name at all.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /**\n * Stable id used to associate the native input with its label. Lands on the\n * inner `<input>`; the host never keeps it.\n */\n readonly id = input<string>(wrRandomId('wr-switch'));\n\n /**\n * Disable the switch. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse edits while staying focusable and submittable. Bound automatically\n * from the field's readonly state when used with `[formField]`.\n *\n * A native checkbox ignores the `readonly` attribute, so this cancels the\n * click's activation behaviour instead — which covers Space too, since the key\n * arrives as a click — and mirrors the state as `aria-readonly`, which role\n * `switch` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrSwitchSize>('md');\n\n /** On / off state. Bound by `[formField]`, or two-way via `[(checked)]`. */\n readonly checked = model<boolean>(false);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n private readonly native = viewChild.required<ElementRef<HTMLInputElement>>('native');\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-switch--${size}`);\n if (this.checked()) parts.push('wr-switch--checked');\n if (this.disabled()) parts.push('wr-switch--disabled');\n else if (this.readonly()) parts.push('wr-switch--readonly');\n return parts.join(' ');\n });\n\n /**\n * Focus the switch — what Signal Forms calls to focus this control. The native\n * input takes it, since the host has no tab stop of its own; a disabled switch\n * refuses, as a disabled input always does.\n */\n focus(options?: FocusOptions): void {\n this.native().nativeElement.focus(options);\n }\n\n // Template handlers\n\n /**\n * Cancel the toggle while readonly. `change` never fires for a click whose\n * default was prevented, so this is the only guard the pointer and Space paths\n * need; `onInputChange` keeps its own for a synthetic `change`.\n */\n protected onInputClick(event: Event): void {\n if (this.readonly()) event.preventDefault();\n }\n\n protected onInputChange(event: Event): void {\n if (this.readonly()) {\n // A synthetic `change` cannot be prevented — put the DOM back instead.\n (event.target as HTMLInputElement).checked = this.checked();\n return;\n }\n this.checked.set((event.target as HTMLInputElement).checked);\n }\n\n protected onInputBlur(): void {\n this.touch.emit();\n }\n}\n","<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-required]=\"fieldAria.ariaRequired()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n"],"mappings":";;;;;;;;;;;AAwDA,IAAa,WAAb,MAAa,SAAQ;CACnB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,QAAQ;CAC3E;CAOS,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,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