ngwr 10.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/action-sheet/styles/_index.scss +6 -1
- package/badge/styles/_index.scss +1 -1
- package/badge/styles/_tag.scss +2 -2
- package/border-glow/styles/_index.scss +5 -0
- package/button/styles/_index.scss +6 -6
- package/calendar/styles/_index.scss +9 -1
- package/circular-text/styles/_index.scss +6 -1
- package/density/styles/_index.scss +3 -1
- package/dialog/styles/_index.scss +1 -2
- package/drag-drop/styles/_index.scss +20 -7
- package/event-calendar/styles/_index.scss +284 -0
- package/falling-text/styles/_index.scss +5 -0
- package/fesm2022/ngwr-alert.mjs +8 -3
- package/fesm2022/ngwr-alert.mjs.map +1 -1
- package/fesm2022/ngwr-back-top.mjs +6 -4
- package/fesm2022/ngwr-back-top.mjs.map +1 -1
- package/fesm2022/ngwr-border-glow.mjs +12 -9
- package/fesm2022/ngwr-border-glow.mjs.map +1 -1
- package/fesm2022/ngwr-breadcrumbs.mjs +2 -2
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +5 -3
- package/fesm2022/ngwr-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-card.mjs +2 -2
- package/fesm2022/ngwr-card.mjs.map +1 -1
- package/fesm2022/ngwr-carousel.mjs +17 -4
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +31 -4
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox.mjs +12 -3
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-circular-text.mjs +2 -2
- package/fesm2022/ngwr-circular-text.mjs.map +1 -1
- package/fesm2022/ngwr-command-palette.mjs +7 -3
- package/fesm2022/ngwr-command-palette.mjs.map +1 -1
- package/fesm2022/ngwr-counter.mjs +9 -1
- package/fesm2022/ngwr-counter.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +23 -6
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-descriptions.mjs +5 -4
- package/fesm2022/ngwr-descriptions.mjs.map +1 -1
- package/fesm2022/ngwr-drag-drop.mjs +2 -2
- package/fesm2022/ngwr-drag-drop.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +4 -0
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-event-calendar.mjs +723 -0
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -0
- package/fesm2022/ngwr-falling-text.mjs +2 -2
- package/fesm2022/ngwr-falling-text.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +2 -2
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +258 -42
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-fuzzy-text.mjs +15 -1
- package/fesm2022/ngwr-fuzzy-text.mjs.map +1 -1
- package/fesm2022/ngwr-gauge.mjs +8 -3
- package/fesm2022/ngwr-gauge.mjs.map +1 -1
- package/fesm2022/ngwr-glitch-text.mjs +2 -2
- package/fesm2022/ngwr-glitch-text.mjs.map +1 -1
- package/fesm2022/ngwr-gradient-text.mjs +2 -2
- package/fesm2022/ngwr-gradient-text.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +73 -5
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +73 -5
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +20 -2
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-icon.mjs +5 -0
- package/fesm2022/ngwr-icon.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +19 -3
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +48 -6
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-knob.mjs +8 -3
- package/fesm2022/ngwr-knob.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +32 -3
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-line-chart.mjs +3 -3
- package/fesm2022/ngwr-line-chart.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +2 -2
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-loading-bar.mjs +2 -2
- package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
- package/fesm2022/ngwr-marquee.mjs +2 -2
- package/fesm2022/ngwr-marquee.mjs.map +1 -1
- package/fesm2022/ngwr-media.mjs +3 -0
- package/fesm2022/ngwr-media.mjs.map +1 -1
- package/fesm2022/ngwr-meter-group.mjs +14 -3
- package/fesm2022/ngwr-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-page-header.mjs +2 -2
- package/fesm2022/ngwr-page-header.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +1 -1
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-progress.mjs +8 -2
- package/fesm2022/ngwr-progress.mjs.map +1 -1
- package/fesm2022/ngwr-qr.mjs.map +1 -1
- package/fesm2022/ngwr-rating.mjs +6 -4
- package/fesm2022/ngwr-rating.mjs.map +1 -1
- package/fesm2022/ngwr-result.mjs +19 -12
- package/fesm2022/ngwr-result.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +2 -2
- package/fesm2022/ngwr-segmented.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +28 -8
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-shiny-text.mjs +4 -6
- package/fesm2022/ngwr-shiny-text.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +11 -3
- package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
- package/fesm2022/ngwr-spotlight-card.mjs +2 -2
- package/fesm2022/ngwr-spotlight-card.mjs.map +1 -1
- package/fesm2022/ngwr-squircle.mjs +1 -1
- package/fesm2022/ngwr-squircle.mjs.map +1 -1
- package/fesm2022/ngwr-star-border.mjs +2 -2
- package/fesm2022/ngwr-star-border.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +10 -3
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +233 -19
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tabs.mjs +21 -4
- package/fesm2022/ngwr-tabs.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +20 -4
- package/fesm2022/ngwr-textarea.mjs.map +1 -1
- package/fesm2022/ngwr-tilt-card.mjs +2 -2
- package/fesm2022/ngwr-tilt-card.mjs.map +1 -1
- package/fesm2022/ngwr-toolbar.mjs +2 -2
- package/fesm2022/ngwr-toolbar.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +264 -0
- package/fesm2022/ngwr-tour.mjs.map +1 -0
- package/fesm2022/ngwr-transfer.mjs +184 -0
- package/fesm2022/ngwr-transfer.mjs.map +1 -0
- package/fesm2022/ngwr-tree.mjs +23 -6
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-typewriter.mjs +2 -2
- package/fesm2022/ngwr-typewriter.mjs.map +1 -1
- package/fesm2022/ngwr-validators.mjs +118 -2
- package/fesm2022/ngwr-validators.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +2 -2
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-virtual-scroll.mjs +2 -2
- package/fesm2022/ngwr-virtual-scroll.mjs.map +1 -1
- package/fesm2022/ngwr-waves.mjs +2 -2
- package/fesm2022/ngwr-waves.mjs.map +1 -1
- package/form/styles/_index.scss +8 -4
- package/glitch-text/styles/_index.scss +5 -0
- package/gradient-text/styles/_index.scss +5 -0
- package/i18n/en.json +74 -6
- package/i18n/ru.json +74 -6
- package/icon/styles/_index.scss +5 -0
- package/keyboard/styles/_index.scss +5 -0
- package/llms-full.txt +123 -62
- package/llms.txt +29 -8
- package/loading-bar/styles/_index.scss +5 -0
- package/marquee/styles/_index.scss +7 -2
- package/overlay/styles/_index.scss +5 -0
- package/package.json +13 -1
- package/popover/styles/_index.scss +48 -12
- package/pull-to-refresh/styles/_index.scss +5 -0
- package/result/styles/_index.scss +3 -3
- package/schematics/icon-set/index.js +80 -34
- package/schematics/icon-set/schema.json +8 -3
- package/schematics/ng-add/index.js +5 -2
- package/schematics/page/templates.js +17 -21
- package/schematics/provider/index.js +31 -13
- package/schematics/provider/schema.json +40 -24
- package/schematics/use/index.js +5 -1
- package/schematics/use/schema.json +8 -3
- package/schematics/use/symbol-map.json +6 -177
- package/segmented/styles/_index.scss +1 -1
- package/select/styles/_index.scss +7 -3
- package/shiny-text/styles/_index.scss +5 -0
- package/speed-dial/styles/_index.scss +12 -1
- package/spotlight-card/styles/_index.scss +5 -0
- package/squircle/styles/_index.scss +5 -0
- package/star-border/styles/_index.scss +5 -0
- package/statistic/styles/_index.scss +2 -2
- package/styles/_animations.scss +6 -0
- package/styles.scss +3 -0
- package/table/styles/_index.scss +100 -2
- package/theme/styles/_colors.scss +43 -1
- package/theme/styles/_dark.scss +18 -6
- package/theme/styles/_focus.scss +2 -8
- package/tilt-card/styles/_index.scss +5 -0
- package/toast/styles/_index.scss +6 -3
- package/tour/styles/_index.scss +63 -0
- package/transfer/styles/_index.scss +105 -0
- package/types/ngwr-alert.d.ts +4 -1
- package/types/ngwr-avatar.d.ts +1 -1
- package/types/ngwr-back-top.d.ts +3 -2
- package/types/ngwr-badge.d.ts +1 -1
- package/types/ngwr-border-glow.d.ts +0 -1
- package/types/ngwr-carousel.d.ts +10 -1
- package/types/ngwr-cascader.d.ts +12 -1
- package/types/ngwr-checkbox.d.ts +9 -1
- package/types/ngwr-command-palette.d.ts +4 -1
- package/types/ngwr-date-picker.d.ts +9 -1
- package/types/ngwr-density.d.ts +1 -1
- package/types/ngwr-divider.d.ts +1 -1
- package/types/ngwr-event-calendar.d.ts +358 -0
- package/types/ngwr-form.d.ts +177 -20
- package/types/ngwr-fuzzy-text.d.ts +8 -0
- package/types/ngwr-gauge.d.ts +4 -1
- package/types/ngwr-i18n.d.ts +15 -0
- package/types/ngwr-input-number.d.ts +8 -1
- package/types/ngwr-input.d.ts +50 -20
- package/types/ngwr-knob.d.ts +4 -1
- package/types/ngwr-lightbox.d.ts +7 -1
- package/types/ngwr-line-chart.d.ts +1 -1
- package/types/ngwr-media.d.ts +1 -1
- package/types/ngwr-meter-group.d.ts +9 -1
- package/types/ngwr-page-header.d.ts +2 -2
- package/types/ngwr-pagination.d.ts +1 -1
- package/types/ngwr-progress.d.ts +4 -1
- package/types/ngwr-rating.d.ts +3 -2
- package/types/ngwr-result.d.ts +12 -6
- package/types/ngwr-segmented.d.ts +6 -0
- package/types/ngwr-select.d.ts +13 -7
- package/types/ngwr-shiny-text.d.ts +2 -4
- package/types/ngwr-speed-dial.d.ts +7 -1
- package/types/ngwr-squircle.d.ts +1 -1
- package/types/ngwr-switch.d.ts +7 -1
- package/types/ngwr-table.d.ts +126 -6
- package/types/ngwr-tabs.d.ts +1 -4
- package/types/ngwr-textarea.d.ts +8 -1
- package/types/ngwr-toolbar.d.ts +2 -2
- package/types/ngwr-tour.d.ts +132 -0
- package/types/ngwr-transfer.d.ts +118 -0
- package/types/ngwr-tree.d.ts +10 -2
- package/types/ngwr-validators.d.ts +62 -2
- package/types/ngwr-version.d.ts +2 -2
- package/typewriter/styles/_index.scss +5 -0
- package/typography/styles/_index.scss +3 -3
- package/virtual-scroll/styles/_index.scss +6 -1
- package/waves/styles/_index.scss +5 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';
|
|
2
|
+
import { ScrollStrategyOptions } from '@angular/cdk/overlay';
|
|
3
|
+
import { ComponentPortal } from '@angular/cdk/portal';
|
|
4
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
5
|
+
import * as i0 from '@angular/core';
|
|
6
|
+
import { InjectionToken, inject, computed, ViewEncapsulation, Component, EnvironmentInjector, DOCUMENT, PLATFORM_ID, signal, Injector, Service } from '@angular/core';
|
|
7
|
+
import { WR_OVERLAY } from 'ngwr/overlay';
|
|
8
|
+
import { WrButton } from 'ngwr/button';
|
|
9
|
+
import { readI18nText, useI18nFormatter } from 'ngwr/i18n';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @license
|
|
13
|
+
*
|
|
14
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
15
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
16
|
+
*/
|
|
17
|
+
/** Provided by `WrTour` when it attaches the popup portal. */
|
|
18
|
+
const WR_TOUR_STEP = new InjectionToken('WR_TOUR_STEP');
|
|
19
|
+
/**
|
|
20
|
+
* The card a tour shows next to the spotlit element. Rendered by `WrTour` into
|
|
21
|
+
* a CDK overlay — not something you place yourself.
|
|
22
|
+
*
|
|
23
|
+
* @see https://ngwr.dev/reference/services/tour
|
|
24
|
+
*/
|
|
25
|
+
class WrTourPopup {
|
|
26
|
+
tour = inject(WR_TOUR_STEP);
|
|
27
|
+
// `readI18nText`, not `useI18nText`: these have no consumer-facing input to
|
|
28
|
+
// forward, and the popup is rebuilt for every step, so resolving once at
|
|
29
|
+
// construction is enough.
|
|
30
|
+
nextLabel = readI18nText('tour.next', 'Next');
|
|
31
|
+
backLabel = readI18nText('tour.back', 'Back');
|
|
32
|
+
doneLabel = readI18nText('tour.done', 'Done');
|
|
33
|
+
skipLabel = readI18nText('tour.skip', 'Skip tour');
|
|
34
|
+
/** `Step {{current}} of {{total}}` — also the dialog's accessible name. */
|
|
35
|
+
progress = useI18nFormatter('tour.progress', 'Step {{current}} of {{total}}');
|
|
36
|
+
isLast = computed(() => this.tour.index() >= this.tour.total() - 1, /* @ts-ignore */
|
|
37
|
+
...(ngDevMode ? [{ debugName: "isLast" }] : /* istanbul ignore next */ []));
|
|
38
|
+
isFirst = computed(() => this.tour.index() <= 0, /* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [{ debugName: "isFirst" }] : /* istanbul ignore next */ []));
|
|
40
|
+
progressText = computed(() => this.progress({ current: this.tour.index() + 1, total: this.tour.total() }), /* @ts-ignore */
|
|
41
|
+
...(ngDevMode ? [{ debugName: "progressText" }] : /* istanbul ignore next */ []));
|
|
42
|
+
ariaLabel = computed(() => {
|
|
43
|
+
const title = this.tour.step()?.title;
|
|
44
|
+
return title ? `${title} — ${this.progressText()}` : this.progressText();
|
|
45
|
+
}, /* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
47
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrTourPopup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
48
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: WrTourPopup, isStandalone: true, selector: "wr-tour-popup", host: { attributes: { "role": "dialog", "aria-modal": "true" }, properties: { "attr.aria-label": "ariaLabel()" }, classAttribute: "wr-tour-popup" }, ngImport: i0, template: "@let step = tour.step();\n\n<p class=\"wr-tour-popup__progress\">{{ progressText() }}</p>\n\n@if (step?.title; as title) {\n <h2 class=\"wr-tour-popup__title\">{{ title }}</h2>\n}\n\n<p class=\"wr-tour-popup__content\">{{ step?.content }}</p>\n\n<div class=\"wr-tour-popup__actions\">\n <button wr-btn type=\"button\" size=\"sm\" color=\"medium\" outlined (click)=\"tour.stop()\">\n {{ skipLabel }}\n </button>\n\n <span class=\"wr-tour-popup__spacer\"></span>\n\n @if (!isFirst()) {\n <button wr-btn type=\"button\" size=\"sm\" outlined (click)=\"tour.prev()\">{{ backLabel }}</button>\n }\n <button wr-btn type=\"button\" size=\"sm\" color=\"primary\" (click)=\"tour.next()\">\n {{ isLast() ? doneLabel : nextLabel }}\n </button>\n</div>\n", dependencies: [{ kind: "component", type: WrButton, selector: "wr-btn, button[wr-btn], a[wr-btn]", inputs: ["color", "size", "shape", "icon", "iconPosition", "disabled", "outlined", "block", "loading", "isDisabledWhenLoading"] }], encapsulation: i0.ViewEncapsulation.None });
|
|
49
|
+
}
|
|
50
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrTourPopup, decorators: [{
|
|
51
|
+
type: Component,
|
|
52
|
+
args: [{ selector: 'wr-tour-popup', encapsulation: ViewEncapsulation.None, host: { class: 'wr-tour-popup', role: 'dialog', 'aria-modal': 'true', '[attr.aria-label]': 'ariaLabel()' }, imports: [WrButton], template: "@let step = tour.step();\n\n<p class=\"wr-tour-popup__progress\">{{ progressText() }}</p>\n\n@if (step?.title; as title) {\n <h2 class=\"wr-tour-popup__title\">{{ title }}</h2>\n}\n\n<p class=\"wr-tour-popup__content\">{{ step?.content }}</p>\n\n<div class=\"wr-tour-popup__actions\">\n <button wr-btn type=\"button\" size=\"sm\" color=\"medium\" outlined (click)=\"tour.stop()\">\n {{ skipLabel }}\n </button>\n\n <span class=\"wr-tour-popup__spacer\"></span>\n\n @if (!isFirst()) {\n <button wr-btn type=\"button\" size=\"sm\" outlined (click)=\"tour.prev()\">{{ backLabel }}</button>\n }\n <button wr-btn type=\"button\" size=\"sm\" color=\"primary\" (click)=\"tour.next()\">\n {{ isLast() ? doneLabel : nextLabel }}\n </button>\n</div>\n" }]
|
|
53
|
+
}] });
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @license
|
|
57
|
+
*
|
|
58
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
59
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
60
|
+
*/
|
|
61
|
+
/** Fallback order per preferred side — the opposite side first, then the sides. */
|
|
62
|
+
const FALLBACKS = {
|
|
63
|
+
bottom: ['bottom', 'top', 'right', 'left'],
|
|
64
|
+
top: ['top', 'bottom', 'right', 'left'],
|
|
65
|
+
left: ['left', 'right', 'bottom', 'top'],
|
|
66
|
+
right: ['right', 'left', 'bottom', 'top'],
|
|
67
|
+
};
|
|
68
|
+
const CONNECTED = {
|
|
69
|
+
bottom: { originX: 'center', originY: 'bottom', overlayX: 'center', overlayY: 'top' },
|
|
70
|
+
top: { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom' },
|
|
71
|
+
left: { originX: 'start', originY: 'center', overlayX: 'end', overlayY: 'center' },
|
|
72
|
+
right: { originX: 'end', originY: 'center', overlayX: 'start', overlayY: 'center' },
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Guided product tour: a spotlight over one element at a time plus a popup
|
|
76
|
+
* explaining it.
|
|
77
|
+
*
|
|
78
|
+
* Steps are data, not markup — call `start()` with an array and the service owns
|
|
79
|
+
* the overlay, the cut-out, focus and the keyboard. A step whose target is not
|
|
80
|
+
* on the page is skipped rather than shown floating, so a tour survives a
|
|
81
|
+
* feature being hidden behind a flag or a permission.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* private readonly tour = inject(WrTour);
|
|
86
|
+
*
|
|
87
|
+
* showMeAround(): void {
|
|
88
|
+
* this.tour.start([
|
|
89
|
+
* { target: '[data-tour="search"]', title: 'Search', content: 'Find anything by name.' },
|
|
90
|
+
* { target: '[data-tour="filters"]', content: 'Narrow the list down.', placement: 'right' },
|
|
91
|
+
* ]);
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @see https://ngwr.dev/reference/services/tour
|
|
96
|
+
*/
|
|
97
|
+
class WrTour {
|
|
98
|
+
overlay = inject(WR_OVERLAY);
|
|
99
|
+
scrollStrategies = inject(ScrollStrategyOptions);
|
|
100
|
+
injector = inject(EnvironmentInjector);
|
|
101
|
+
focusTrapFactory = inject(ConfigurableFocusTrapFactory);
|
|
102
|
+
document = inject(DOCUMENT);
|
|
103
|
+
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
104
|
+
steps = signal([], /* @ts-ignore */
|
|
105
|
+
...(ngDevMode ? [{ debugName: "steps" }] : /* istanbul ignore next */ []));
|
|
106
|
+
cursor = signal(-1, /* @ts-ignore */
|
|
107
|
+
...(ngDevMode ? [{ debugName: "cursor" }] : /* istanbul ignore next */ []));
|
|
108
|
+
overlayRef = null;
|
|
109
|
+
spotlight = null;
|
|
110
|
+
detachKeydown = null;
|
|
111
|
+
detachReposition = null;
|
|
112
|
+
restoreFocus = null;
|
|
113
|
+
/** Whether a tour is running. */
|
|
114
|
+
active = computed(() => this.cursor() >= 0, /* @ts-ignore */
|
|
115
|
+
...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
116
|
+
/** Zero-based index of the current step, `-1` when idle. */
|
|
117
|
+
index = computed(() => this.cursor(), /* @ts-ignore */
|
|
118
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
119
|
+
/** How many steps this tour has. */
|
|
120
|
+
total = computed(() => this.steps().length, /* @ts-ignore */
|
|
121
|
+
...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
|
|
122
|
+
/** The step being shown, or `null` when idle. */
|
|
123
|
+
step = computed(() => this.steps()[this.cursor()] ?? null, /* @ts-ignore */
|
|
124
|
+
...(ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []));
|
|
125
|
+
/**
|
|
126
|
+
* Begin a tour. Restarts if one is already running. A no-op under SSR — a
|
|
127
|
+
* tour is a client-side affordance and there is nothing to spotlight on the
|
|
128
|
+
* server.
|
|
129
|
+
*/
|
|
130
|
+
start(steps) {
|
|
131
|
+
if (!this.isBrowser || steps.length === 0)
|
|
132
|
+
return;
|
|
133
|
+
this.stop();
|
|
134
|
+
this.steps.set(steps);
|
|
135
|
+
this.restoreFocus = this.document.activeElement;
|
|
136
|
+
this.goTo(0, 1);
|
|
137
|
+
}
|
|
138
|
+
/** Advance; finishes the tour past the last step. */
|
|
139
|
+
next() {
|
|
140
|
+
this.goTo(this.cursor() + 1, 1);
|
|
141
|
+
}
|
|
142
|
+
/** Go back; stays put on the first step. */
|
|
143
|
+
prev() {
|
|
144
|
+
this.goTo(this.cursor() - 1, -1);
|
|
145
|
+
}
|
|
146
|
+
/** End the tour and return focus where it was. */
|
|
147
|
+
stop() {
|
|
148
|
+
this.teardownStep();
|
|
149
|
+
this.steps.set([]);
|
|
150
|
+
this.cursor.set(-1);
|
|
151
|
+
this.restoreFocus?.focus?.();
|
|
152
|
+
this.restoreFocus = null;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Move to `index`, skipping steps whose target is not in the DOM. `direction`
|
|
156
|
+
* says which way to keep skipping, so a missing step never traps the tour
|
|
157
|
+
* between two dead ends.
|
|
158
|
+
*/
|
|
159
|
+
goTo(index, direction) {
|
|
160
|
+
const steps = this.steps();
|
|
161
|
+
let i = index;
|
|
162
|
+
while (i >= 0 && i < steps.length && this.resolve(steps[i]) === null)
|
|
163
|
+
i += direction;
|
|
164
|
+
if (i < 0) {
|
|
165
|
+
// Ran off the start while going back — stay where we were.
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (i >= steps.length) {
|
|
169
|
+
this.stop();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
this.teardownStep();
|
|
173
|
+
this.cursor.set(i);
|
|
174
|
+
this.openStep(steps[i]);
|
|
175
|
+
}
|
|
176
|
+
resolve(step) {
|
|
177
|
+
if (typeof step.target !== 'string')
|
|
178
|
+
return step.target.isConnected ? step.target : null;
|
|
179
|
+
return this.document.querySelector(step.target);
|
|
180
|
+
}
|
|
181
|
+
openStep(step) {
|
|
182
|
+
const target = this.resolve(step);
|
|
183
|
+
if (!target)
|
|
184
|
+
return;
|
|
185
|
+
target.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' });
|
|
186
|
+
// The cut-out is a bare element sized to the target with an enormous spread
|
|
187
|
+
// shadow: everything outside it dims, the target itself stays untouched.
|
|
188
|
+
// Cheaper and far more robust than a clip-path polygon, and it needs no
|
|
189
|
+
// recompute when the page reflows beyond moving the box.
|
|
190
|
+
const spotlight = this.document.createElement('div');
|
|
191
|
+
spotlight.className = 'wr-tour__spotlight';
|
|
192
|
+
spotlight.setAttribute('aria-hidden', 'true');
|
|
193
|
+
this.document.body.appendChild(spotlight);
|
|
194
|
+
this.spotlight = spotlight;
|
|
195
|
+
this.placeSpotlight(target);
|
|
196
|
+
const placement = step.placement ?? 'bottom';
|
|
197
|
+
const positionStrategy = this.overlay
|
|
198
|
+
.position()
|
|
199
|
+
.flexibleConnectedTo(target)
|
|
200
|
+
.withPositions(FALLBACKS[placement].map(side => ({
|
|
201
|
+
...CONNECTED[side],
|
|
202
|
+
offsetY: side === 'bottom' ? 12 : side === 'top' ? -12 : 0,
|
|
203
|
+
offsetX: side === 'right' ? 12 : side === 'left' ? -12 : 0,
|
|
204
|
+
})))
|
|
205
|
+
.withPush(true);
|
|
206
|
+
this.overlayRef = this.overlay.create({
|
|
207
|
+
positionStrategy,
|
|
208
|
+
scrollStrategy: this.scrollStrategies.reposition(),
|
|
209
|
+
panelClass: 'wr-tour-overlay',
|
|
210
|
+
});
|
|
211
|
+
const portal = new ComponentPortal(WrTourPopup, null, Injector.create({ parent: this.injector, providers: [{ provide: WR_TOUR_STEP, useValue: this }] }));
|
|
212
|
+
const ref = this.overlayRef.attach(portal);
|
|
213
|
+
const trap = this.focusTrapFactory.create(ref.location.nativeElement);
|
|
214
|
+
void trap.focusInitialElementWhenReady();
|
|
215
|
+
const onKey = (event) => {
|
|
216
|
+
if (event.key === 'Escape') {
|
|
217
|
+
event.preventDefault();
|
|
218
|
+
this.stop();
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
this.document.addEventListener('keydown', onKey);
|
|
222
|
+
this.detachKeydown = () => this.document.removeEventListener('keydown', onKey);
|
|
223
|
+
const reposition = () => this.placeSpotlight(target);
|
|
224
|
+
window.addEventListener('scroll', reposition, true);
|
|
225
|
+
window.addEventListener('resize', reposition);
|
|
226
|
+
this.detachReposition = () => {
|
|
227
|
+
window.removeEventListener('scroll', reposition, true);
|
|
228
|
+
window.removeEventListener('resize', reposition);
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
placeSpotlight(target) {
|
|
232
|
+
const el = this.spotlight;
|
|
233
|
+
if (!el)
|
|
234
|
+
return;
|
|
235
|
+
const r = target.getBoundingClientRect();
|
|
236
|
+
const pad = 6;
|
|
237
|
+
el.style.top = `${r.top - pad}px`;
|
|
238
|
+
el.style.left = `${r.left - pad}px`;
|
|
239
|
+
el.style.width = `${r.width + pad * 2}px`;
|
|
240
|
+
el.style.height = `${r.height + pad * 2}px`;
|
|
241
|
+
}
|
|
242
|
+
teardownStep() {
|
|
243
|
+
this.detachKeydown?.();
|
|
244
|
+
this.detachKeydown = null;
|
|
245
|
+
this.detachReposition?.();
|
|
246
|
+
this.detachReposition = null;
|
|
247
|
+
this.overlayRef?.dispose();
|
|
248
|
+
this.overlayRef = null;
|
|
249
|
+
this.spotlight?.remove();
|
|
250
|
+
this.spotlight = null;
|
|
251
|
+
}
|
|
252
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrTour, deps: [], target: i0.ɵɵFactoryTarget.Service });
|
|
253
|
+
static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.0", ngImport: i0, type: WrTour });
|
|
254
|
+
}
|
|
255
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrTour, decorators: [{
|
|
256
|
+
type: Service
|
|
257
|
+
}] });
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Generated bundle index. Do not edit.
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
export { WrTour, WrTourPopup };
|
|
264
|
+
//# sourceMappingURL=ngwr-tour.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngwr-tour.mjs","sources":["../../../projects/lib/tour/tour-popup.ts","../../../projects/lib/tour/tour-popup.html","../../../projects/lib/tour/tour.ts","../../../projects/lib/tour/ngwr-tour.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 { Component, InjectionToken, ViewEncapsulation, computed, inject } from '@angular/core';\n\nimport { WrButton } from 'ngwr/button';\nimport { readI18nText, useI18nFormatter } from 'ngwr/i18n';\n\nimport type { WrTourStep } from './interfaces';\n\n/** What the popup needs from the running tour, without importing the service (cycle). */\nexport interface WrTourController {\n readonly index: () => number;\n readonly total: () => number;\n readonly step: () => WrTourStep | null;\n next(): void;\n prev(): void;\n stop(): void;\n}\n\n/** Provided by `WrTour` when it attaches the popup portal. */\nexport const WR_TOUR_STEP = new InjectionToken<WrTourController>('WR_TOUR_STEP');\n\n/**\n * The card a tour shows next to the spotlit element. Rendered by `WrTour` into\n * a CDK overlay — not something you place yourself.\n *\n * @see https://ngwr.dev/reference/services/tour\n */\n@Component({\n selector: 'wr-tour-popup',\n templateUrl: './tour-popup.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-tour-popup', role: 'dialog', 'aria-modal': 'true', '[attr.aria-label]': 'ariaLabel()' },\n imports: [WrButton],\n})\nexport class WrTourPopup {\n protected readonly tour = inject(WR_TOUR_STEP);\n\n // `readI18nText`, not `useI18nText`: these have no consumer-facing input to\n // forward, and the popup is rebuilt for every step, so resolving once at\n // construction is enough.\n protected readonly nextLabel = readI18nText('tour.next', 'Next');\n protected readonly backLabel = readI18nText('tour.back', 'Back');\n protected readonly doneLabel = readI18nText('tour.done', 'Done');\n protected readonly skipLabel = readI18nText('tour.skip', 'Skip tour');\n\n /** `Step {{current}} of {{total}}` — also the dialog's accessible name. */\n protected readonly progress = useI18nFormatter('tour.progress', 'Step {{current}} of {{total}}');\n\n protected readonly isLast = computed(() => this.tour.index() >= this.tour.total() - 1);\n protected readonly isFirst = computed(() => this.tour.index() <= 0);\n\n protected readonly progressText = computed(() =>\n this.progress({ current: this.tour.index() + 1, total: this.tour.total() })\n );\n\n protected readonly ariaLabel = computed(() => {\n const title = this.tour.step()?.title;\n return title ? `${title} — ${this.progressText()}` : this.progressText();\n });\n}\n","@let step = tour.step();\n\n<p class=\"wr-tour-popup__progress\">{{ progressText() }}</p>\n\n@if (step?.title; as title) {\n <h2 class=\"wr-tour-popup__title\">{{ title }}</h2>\n}\n\n<p class=\"wr-tour-popup__content\">{{ step?.content }}</p>\n\n<div class=\"wr-tour-popup__actions\">\n <button wr-btn type=\"button\" size=\"sm\" color=\"medium\" outlined (click)=\"tour.stop()\">\n {{ skipLabel }}\n </button>\n\n <span class=\"wr-tour-popup__spacer\"></span>\n\n @if (!isFirst()) {\n <button wr-btn type=\"button\" size=\"sm\" outlined (click)=\"tour.prev()\">{{ backLabel }}</button>\n }\n <button wr-btn type=\"button\" size=\"sm\" color=\"primary\" (click)=\"tour.next()\">\n {{ isLast() ? doneLabel : nextLabel }}\n </button>\n</div>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';\nimport { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { ComponentPortal } from '@angular/cdk/portal';\nimport { isPlatformBrowser } from '@angular/common';\nimport { DOCUMENT, EnvironmentInjector, Injector, PLATFORM_ID, Service, computed, inject, signal } from '@angular/core';\n\nimport { WR_OVERLAY } from 'ngwr/overlay';\n\nimport type { WrTourPlacement, WrTourStep } from './interfaces';\nimport { WR_TOUR_STEP, WrTourPopup } from './tour-popup';\n\n/** Fallback order per preferred side — the opposite side first, then the sides. */\nconst FALLBACKS: Record<WrTourPlacement, readonly WrTourPlacement[]> = {\n bottom: ['bottom', 'top', 'right', 'left'],\n top: ['top', 'bottom', 'right', 'left'],\n left: ['left', 'right', 'bottom', 'top'],\n right: ['right', 'left', 'bottom', 'top'],\n};\n\nconst CONNECTED: Record<\n WrTourPlacement,\n {\n originX: 'start' | 'center' | 'end';\n originY: 'top' | 'center' | 'bottom';\n overlayX: 'start' | 'center' | 'end';\n overlayY: 'top' | 'center' | 'bottom';\n }\n> = {\n bottom: { originX: 'center', originY: 'bottom', overlayX: 'center', overlayY: 'top' },\n top: { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom' },\n left: { originX: 'start', originY: 'center', overlayX: 'end', overlayY: 'center' },\n right: { originX: 'end', originY: 'center', overlayX: 'start', overlayY: 'center' },\n};\n\n/**\n * Guided product tour: a spotlight over one element at a time plus a popup\n * explaining it.\n *\n * Steps are data, not markup — call `start()` with an array and the service owns\n * the overlay, the cut-out, focus and the keyboard. A step whose target is not\n * on the page is skipped rather than shown floating, so a tour survives a\n * feature being hidden behind a flag or a permission.\n *\n * @example\n * ```ts\n * private readonly tour = inject(WrTour);\n *\n * showMeAround(): void {\n * this.tour.start([\n * { target: '[data-tour=\"search\"]', title: 'Search', content: 'Find anything by name.' },\n * { target: '[data-tour=\"filters\"]', content: 'Narrow the list down.', placement: 'right' },\n * ]);\n * }\n * ```\n *\n * @see https://ngwr.dev/reference/services/tour\n */\n@Service()\nexport class WrTour {\n private readonly overlay = inject(WR_OVERLAY);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly injector = inject(EnvironmentInjector);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly document = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n private readonly steps = signal<readonly WrTourStep[]>([]);\n private readonly cursor = signal(-1);\n\n private overlayRef: OverlayRef | null = null;\n private spotlight: HTMLElement | null = null;\n private detachKeydown: (() => void) | null = null;\n private detachReposition: (() => void) | null = null;\n private restoreFocus: HTMLElement | null = null;\n\n /** Whether a tour is running. */\n readonly active = computed(() => this.cursor() >= 0);\n\n /** Zero-based index of the current step, `-1` when idle. */\n readonly index = computed(() => this.cursor());\n\n /** How many steps this tour has. */\n readonly total = computed(() => this.steps().length);\n\n /** The step being shown, or `null` when idle. */\n readonly step = computed<WrTourStep | null>(() => this.steps()[this.cursor()] ?? null);\n\n /**\n * Begin a tour. Restarts if one is already running. A no-op under SSR — a\n * tour is a client-side affordance and there is nothing to spotlight on the\n * server.\n */\n start(steps: readonly WrTourStep[]): void {\n if (!this.isBrowser || steps.length === 0) return;\n this.stop();\n this.steps.set(steps);\n this.restoreFocus = this.document.activeElement as HTMLElement | null;\n this.goTo(0, 1);\n }\n\n /** Advance; finishes the tour past the last step. */\n next(): void {\n this.goTo(this.cursor() + 1, 1);\n }\n\n /** Go back; stays put on the first step. */\n prev(): void {\n this.goTo(this.cursor() - 1, -1);\n }\n\n /** End the tour and return focus where it was. */\n stop(): void {\n this.teardownStep();\n this.steps.set([]);\n this.cursor.set(-1);\n this.restoreFocus?.focus?.();\n this.restoreFocus = null;\n }\n\n /**\n * Move to `index`, skipping steps whose target is not in the DOM. `direction`\n * says which way to keep skipping, so a missing step never traps the tour\n * between two dead ends.\n */\n private goTo(index: number, direction: 1 | -1): void {\n const steps = this.steps();\n let i = index;\n while (i >= 0 && i < steps.length && this.resolve(steps[i]) === null) i += direction;\n\n if (i < 0) {\n // Ran off the start while going back — stay where we were.\n return;\n }\n if (i >= steps.length) {\n this.stop();\n return;\n }\n\n this.teardownStep();\n this.cursor.set(i);\n this.openStep(steps[i]);\n }\n\n private resolve(step: WrTourStep): HTMLElement | null {\n if (typeof step.target !== 'string') return step.target.isConnected ? step.target : null;\n return this.document.querySelector<HTMLElement>(step.target);\n }\n\n private openStep(step: WrTourStep): void {\n const target = this.resolve(step);\n if (!target) return;\n\n target.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' });\n\n // The cut-out is a bare element sized to the target with an enormous spread\n // shadow: everything outside it dims, the target itself stays untouched.\n // Cheaper and far more robust than a clip-path polygon, and it needs no\n // recompute when the page reflows beyond moving the box.\n const spotlight = this.document.createElement('div');\n spotlight.className = 'wr-tour__spotlight';\n spotlight.setAttribute('aria-hidden', 'true');\n this.document.body.appendChild(spotlight);\n this.spotlight = spotlight;\n this.placeSpotlight(target);\n\n const placement = step.placement ?? 'bottom';\n const positionStrategy = this.overlay\n .position()\n .flexibleConnectedTo(target)\n .withPositions(\n FALLBACKS[placement].map(side => ({\n ...CONNECTED[side],\n offsetY: side === 'bottom' ? 12 : side === 'top' ? -12 : 0,\n offsetX: side === 'right' ? 12 : side === 'left' ? -12 : 0,\n }))\n )\n .withPush(true);\n\n this.overlayRef = this.overlay.create({\n positionStrategy,\n scrollStrategy: this.scrollStrategies.reposition(),\n panelClass: 'wr-tour-overlay',\n });\n\n const portal = new ComponentPortal(\n WrTourPopup,\n null,\n Injector.create({ parent: this.injector, providers: [{ provide: WR_TOUR_STEP, useValue: this }] })\n );\n const ref = this.overlayRef.attach(portal);\n\n const trap = this.focusTrapFactory.create(ref.location.nativeElement as HTMLElement);\n void trap.focusInitialElementWhenReady();\n\n const onKey = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.stop();\n }\n };\n this.document.addEventListener('keydown', onKey);\n this.detachKeydown = () => this.document.removeEventListener('keydown', onKey);\n\n const reposition = (): void => this.placeSpotlight(target);\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n this.detachReposition = () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n };\n }\n\n private placeSpotlight(target: HTMLElement): void {\n const el = this.spotlight;\n if (!el) return;\n const r = target.getBoundingClientRect();\n const pad = 6;\n el.style.top = `${r.top - pad}px`;\n el.style.left = `${r.left - pad}px`;\n el.style.width = `${r.width + pad * 2}px`;\n el.style.height = `${r.height + pad * 2}px`;\n }\n\n private teardownStep(): void {\n this.detachKeydown?.();\n this.detachKeydown = null;\n this.detachReposition?.();\n this.detachReposition = null;\n this.overlayRef?.dispose();\n this.overlayRef = null;\n this.spotlight?.remove();\n this.spotlight = null;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;AAKG;AAmBH;AACO,MAAM,YAAY,GAAG,IAAI,cAAc,CAAmB,cAAc,CAAC;AAEhF;;;;;AAKG;MAQU,WAAW,CAAA;AACH,IAAA,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC;;;;AAK3B,IAAA,SAAS,GAAG,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC;AAC7C,IAAA,SAAS,GAAG,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC;AAC7C,IAAA,SAAS,GAAG,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC;AAC7C,IAAA,SAAS,GAAG,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC;;AAGlD,IAAA,QAAQ,GAAG,gBAAgB,CAAC,eAAe,EAAE,+BAA+B,CAAC;IAE7E,MAAM,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC;+EAAC;AACnE,IAAA,OAAO,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC;gFAAC;AAEhD,IAAA,YAAY,GAAG,QAAQ,CAAC,MACzC,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;qFAC5E;AAEkB,IAAA,SAAS,GAAG,QAAQ,CAAC,MAAK;QAC3C,MAAM,KAAK,GAAG,IAA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dk/coercion';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { input, model, output, signal, computed, ViewEncapsulation, Component } from '@angular/core';
|
|
4
|
+
import { WrButton } from 'ngwr/button';
|
|
5
|
+
import { WrCheckbox } from 'ngwr/checkbox';
|
|
6
|
+
import { useI18nText, useI18nFormatter } from 'ngwr/i18n';
|
|
7
|
+
import { WrInput } from 'ngwr/input';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @license
|
|
11
|
+
*
|
|
12
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
13
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Dual-listbox picker: two panes and the buttons that move rows between them.
|
|
17
|
+
*
|
|
18
|
+
* The full item set is `[items]` and the RIGHT pane is the value — `[(value)]`
|
|
19
|
+
* holds the chosen `WrTransferItem['value']`s, everything else stays left. The
|
|
20
|
+
* checked state inside each pane is transient staging, deliberately not part of
|
|
21
|
+
* the value: what a form cares about is which rows ended up on the right.
|
|
22
|
+
*
|
|
23
|
+
* A signal-forms native control (`FormValueControl<readonly unknown[]>`), so
|
|
24
|
+
* `[formField]` binds straight to `value`; `[(ngModel)]` and reactive forms keep
|
|
25
|
+
* working through Angular's bridge, and `[(value)]` is the standalone shape.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```html
|
|
29
|
+
* <!-- Standalone -->
|
|
30
|
+
* <wr-transfer [items]="permissions" [(value)]="granted" />
|
|
31
|
+
*
|
|
32
|
+
* <!-- Searchable, with pane titles -->
|
|
33
|
+
* <wr-transfer
|
|
34
|
+
* searchable
|
|
35
|
+
* sourceTitle="Available"
|
|
36
|
+
* targetTitle="Granted"
|
|
37
|
+
* [items]="permissions"
|
|
38
|
+
* [formField]="form.granted"
|
|
39
|
+
* />
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @see https://ngwr.dev/reference/components/transfer
|
|
43
|
+
*/
|
|
44
|
+
class WrTransfer {
|
|
45
|
+
/** Every row, in either pane. Membership of the right pane is `value`. */
|
|
46
|
+
items = input([], /* @ts-ignore */
|
|
47
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
48
|
+
/**
|
|
49
|
+
* Values currently in the RIGHT pane. Two-way bindable; bound automatically
|
|
50
|
+
* by `[formField]` / `[(ngModel)]`.
|
|
51
|
+
*/
|
|
52
|
+
value = model([], /* @ts-ignore */
|
|
53
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
54
|
+
/** Emitted on blur / commit so a bound field marks itself touched. */
|
|
55
|
+
touch = output();
|
|
56
|
+
/** Disable the whole control. @default false */
|
|
57
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
|
|
58
|
+
/** Show a filter box above each pane. @default false */
|
|
59
|
+
searchable = input(false, { ...(ngDevMode ? { debugName: "searchable" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
|
|
60
|
+
/** Heading above the left pane. Falls back to `transfer.source`. */
|
|
61
|
+
sourceTitle = input(null, /* @ts-ignore */
|
|
62
|
+
...(ngDevMode ? [{ debugName: "sourceTitle" }] : /* istanbul ignore next */ []));
|
|
63
|
+
/** Heading above the right pane. Falls back to `transfer.target`. */
|
|
64
|
+
targetTitle = input(null, /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "targetTitle" }] : /* istanbul ignore next */ []));
|
|
66
|
+
/** Placeholder in both filter boxes. Falls back to `transfer.search`. */
|
|
67
|
+
searchPlaceholder = input(null, /* @ts-ignore */
|
|
68
|
+
...(ngDevMode ? [{ debugName: "searchPlaceholder" }] : /* istanbul ignore next */ []));
|
|
69
|
+
/** Shown in a pane with no rows. Falls back to `transfer.empty`. */
|
|
70
|
+
emptyText = input(null, /* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []));
|
|
72
|
+
/** Accessible name of the move-right button. Falls back to `transfer.toTarget`. */
|
|
73
|
+
toTargetLabel = input(null, /* @ts-ignore */
|
|
74
|
+
...(ngDevMode ? [{ debugName: "toTargetLabel" }] : /* istanbul ignore next */ []));
|
|
75
|
+
/** Accessible name of the move-left button. Falls back to `transfer.toSource`. */
|
|
76
|
+
toSourceLabel = input(null, /* @ts-ignore */
|
|
77
|
+
...(ngDevMode ? [{ debugName: "toSourceLabel" }] : /* istanbul ignore next */ []));
|
|
78
|
+
resolvedSourceTitle = useI18nText(this.sourceTitle, 'transfer.source', 'Available');
|
|
79
|
+
resolvedTargetTitle = useI18nText(this.targetTitle, 'transfer.target', 'Selected');
|
|
80
|
+
resolvedSearch = useI18nText(this.searchPlaceholder, 'transfer.search', 'Search');
|
|
81
|
+
resolvedEmpty = useI18nText(this.emptyText, 'transfer.empty', 'Nothing here');
|
|
82
|
+
resolvedToTarget = useI18nText(this.toTargetLabel, 'transfer.toTarget', 'Move to selected');
|
|
83
|
+
resolvedToSource = useI18nText(this.toSourceLabel, 'transfer.toSource', 'Move to available');
|
|
84
|
+
/** `{{checked}} / {{total}}` under each heading. @internal */
|
|
85
|
+
countLabel = useI18nFormatter('transfer.count', '{{checked}} / {{total}}');
|
|
86
|
+
/** Pane order — the template iterates it so both panes share one block. */
|
|
87
|
+
panes = ['source', 'target'];
|
|
88
|
+
sourceQuery = signal('', /* @ts-ignore */
|
|
89
|
+
...(ngDevMode ? [{ debugName: "sourceQuery" }] : /* istanbul ignore next */ []));
|
|
90
|
+
targetQuery = signal('', /* @ts-ignore */
|
|
91
|
+
...(ngDevMode ? [{ debugName: "targetQuery" }] : /* istanbul ignore next */ []));
|
|
92
|
+
/** Staged rows, per pane. Cleared as soon as a move commits them. */
|
|
93
|
+
sourceChecked = signal([], /* @ts-ignore */
|
|
94
|
+
...(ngDevMode ? [{ debugName: "sourceChecked" }] : /* istanbul ignore next */ []));
|
|
95
|
+
targetChecked = signal([], /* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [{ debugName: "targetChecked" }] : /* istanbul ignore next */ []));
|
|
97
|
+
valueSet = computed(() => new Set(this.value()), /* @ts-ignore */
|
|
98
|
+
...(ngDevMode ? [{ debugName: "valueSet" }] : /* istanbul ignore next */ []));
|
|
99
|
+
source = computed(() => this.pane(this.items().filter(item => !this.valueSet().has(item.value)), this.sourceQuery(), this.sourceChecked()), /* @ts-ignore */
|
|
100
|
+
...(ngDevMode ? [{ debugName: "source" }] : /* istanbul ignore next */ []));
|
|
101
|
+
target = computed(() => this.pane(
|
|
102
|
+
// Right-pane order follows `value`, not `items`: the order a user built is
|
|
103
|
+
// the one they expect to read back.
|
|
104
|
+
this.value()
|
|
105
|
+
.map(v => this.items().find(item => item.value === v))
|
|
106
|
+
.filter((item) => item !== undefined), this.targetQuery(), this.targetChecked()), /* @ts-ignore */
|
|
107
|
+
...(ngDevMode ? [{ debugName: "target" }] : /* istanbul ignore next */ []));
|
|
108
|
+
canMoveRight = computed(() => !this.disabled() && this.source().checkedCount > 0, /* @ts-ignore */
|
|
109
|
+
...(ngDevMode ? [{ debugName: "canMoveRight" }] : /* istanbul ignore next */ []));
|
|
110
|
+
canMoveLeft = computed(() => !this.disabled() && this.target().checkedCount > 0, /* @ts-ignore */
|
|
111
|
+
...(ngDevMode ? [{ debugName: "canMoveLeft" }] : /* istanbul ignore next */ []));
|
|
112
|
+
classes = computed(() => {
|
|
113
|
+
const parts = ['wr-transfer'];
|
|
114
|
+
if (this.disabled())
|
|
115
|
+
parts.push('wr-transfer--disabled');
|
|
116
|
+
if (this.searchable())
|
|
117
|
+
parts.push('wr-transfer--searchable');
|
|
118
|
+
return parts.join(' ');
|
|
119
|
+
}, /* @ts-ignore */
|
|
120
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
121
|
+
isChecked(pane, item) {
|
|
122
|
+
return (pane === 'source' ? this.sourceChecked() : this.targetChecked()).includes(item.value);
|
|
123
|
+
}
|
|
124
|
+
toggle(pane, item, checked) {
|
|
125
|
+
if (item.disabled)
|
|
126
|
+
return;
|
|
127
|
+
const box = pane === 'source' ? this.sourceChecked : this.targetChecked;
|
|
128
|
+
const current = box();
|
|
129
|
+
box.set(checked ? [...current, item.value] : current.filter(v => v !== item.value));
|
|
130
|
+
}
|
|
131
|
+
/** Header checkbox — stages or clears every enabled row the filter shows. */
|
|
132
|
+
toggleAll(pane, checked) {
|
|
133
|
+
const state = pane === 'source' ? this.source() : this.target();
|
|
134
|
+
const box = pane === 'source' ? this.sourceChecked : this.targetChecked;
|
|
135
|
+
box.set(checked ? state.rows.filter(item => !item.disabled).map(item => item.value) : []);
|
|
136
|
+
}
|
|
137
|
+
onSearch(pane, event) {
|
|
138
|
+
const query = event.target?.value ?? '';
|
|
139
|
+
(pane === 'source' ? this.sourceQuery : this.targetQuery).set(query);
|
|
140
|
+
}
|
|
141
|
+
moveRight() {
|
|
142
|
+
const moving = this.sourceChecked();
|
|
143
|
+
if (moving.length === 0)
|
|
144
|
+
return;
|
|
145
|
+
this.value.set([...this.value(), ...moving]);
|
|
146
|
+
this.sourceChecked.set([]);
|
|
147
|
+
this.touch.emit();
|
|
148
|
+
}
|
|
149
|
+
moveLeft() {
|
|
150
|
+
const moving = new Set(this.targetChecked());
|
|
151
|
+
if (moving.size === 0)
|
|
152
|
+
return;
|
|
153
|
+
this.value.set(this.value().filter(v => !moving.has(v)));
|
|
154
|
+
this.targetChecked.set([]);
|
|
155
|
+
this.touch.emit();
|
|
156
|
+
}
|
|
157
|
+
/** Filter, then derive the header state from what survived. */
|
|
158
|
+
pane(rows, query, checked) {
|
|
159
|
+
const q = query.trim().toLowerCase();
|
|
160
|
+
const visible = q ? rows.filter(item => item.label.toLowerCase().includes(q)) : rows;
|
|
161
|
+
const enabled = visible.filter(item => !item.disabled);
|
|
162
|
+
const staged = new Set(checked);
|
|
163
|
+
const checkedCount = enabled.filter(item => staged.has(item.value)).length;
|
|
164
|
+
return {
|
|
165
|
+
rows: visible,
|
|
166
|
+
checkedCount,
|
|
167
|
+
allChecked: enabled.length > 0 && checkedCount === enabled.length,
|
|
168
|
+
someChecked: checkedCount > 0 && checkedCount < enabled.length,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrTransfer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
172
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: WrTransfer, isStandalone: true, selector: "wr-transfer", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", isSignal: true, isRequired: false, transformFunction: null }, sourceTitle: { classPropertyName: "sourceTitle", publicName: "sourceTitle", isSignal: true, isRequired: false, transformFunction: null }, targetTitle: { classPropertyName: "targetTitle", publicName: "targetTitle", isSignal: true, isRequired: false, transformFunction: null }, searchPlaceholder: { classPropertyName: "searchPlaceholder", publicName: "searchPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, emptyText: { classPropertyName: "emptyText", publicName: "emptyText", isSignal: true, isRequired: false, transformFunction: null }, toTargetLabel: { classPropertyName: "toTargetLabel", publicName: "toTargetLabel", isSignal: true, isRequired: false, transformFunction: null }, toSourceLabel: { classPropertyName: "toSourceLabel", publicName: "toSourceLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", touch: "touch" }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: "<!--\n Two panes and the buttons between them. Each pane is a PLAIN `<ul>` of\n checkboxes, deliberately: dressing it as a `role=\"listbox\"` of `role=\"option\"`\n rows reads better in the abstract but is invalid \u2014 an option may not contain an\n interactive control, and the axe gate says so. The checkbox is the thing the\n user operates, so it is the thing the semantics should describe; the pane\n heading names the group.\n-->\n@for (pane of panes; track pane) {\n @let state = pane === 'source' ? source() : target();\n @let title = pane === 'source' ? resolvedSourceTitle() : resolvedTargetTitle();\n\n <div class=\"wr-transfer__pane\" [class.wr-transfer__pane--target]=\"pane === 'target'\">\n <div class=\"wr-transfer__head\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"state.allChecked\"\n [indeterminate]=\"state.someChecked\"\n [disabled]=\"disabled() || state.rows.length === 0\"\n [ariaLabel]=\"title\"\n (checkedChange)=\"toggleAll(pane, $event)\"\n />\n <span class=\"wr-transfer__title\">{{ title }}</span>\n <span class=\"wr-transfer__count\">{{\n countLabel({ checked: state.checkedCount, total: state.rows.length })\n }}</span>\n </div>\n\n @if (searchable()) {\n <div class=\"wr-transfer__search\">\n <input\n wrInput\n wrSize=\"sm\"\n type=\"search\"\n [placeholder]=\"resolvedSearch()\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"`${title} \u2014 ${resolvedSearch()}`\"\n (input)=\"onSearch(pane, $event)\"\n />\n </div>\n }\n\n <ul class=\"wr-transfer__list\" [attr.aria-label]=\"title\">\n @for (item of state.rows; track item.value) {\n <li class=\"wr-transfer__item\" [class.wr-transfer__item--disabled]=\"item.disabled\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"isChecked(pane, item)\"\n [disabled]=\"disabled() || !!item.disabled\"\n (checkedChange)=\"toggle(pane, item, $event)\"\n (touch)=\"touch.emit()\"\n >\n {{ item.label }}\n </wr-checkbox>\n </li>\n } @empty {\n <li class=\"wr-transfer__empty\">{{ resolvedEmpty() }}</li>\n }\n </ul>\n </div>\n\n <!-- The buttons live between the panes, so they are emitted after the first. -->\n @if (pane === 'source') {\n <div class=\"wr-transfer__actions\">\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move\"\n [disabled]=\"!canMoveRight()\"\n [attr.aria-label]=\"resolvedToTarget()\"\n (click)=\"moveRight()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move\"\n [disabled]=\"!canMoveLeft()\"\n [attr.aria-label]=\"resolvedToSource()\"\n (click)=\"moveLeft()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n </div>\n }\n}\n", dependencies: [{ kind: "component", type: WrButton, selector: "wr-btn, button[wr-btn], a[wr-btn]", inputs: ["color", "size", "shape", "icon", "iconPosition", "disabled", "outlined", "block", "loading", "isDisabledWhenLoading"] }, { kind: "component", type: WrCheckbox, selector: "wr-checkbox", inputs: ["id", "checkboxValue", "ariaLabel", "checked", "disabled", "size", "icon", "indeterminate"], outputs: ["checkedChange", "touch"] }, { kind: "directive", type: WrInput, selector: "input[wrInput], textarea[wrInput]", inputs: ["wrSize", "rounded"] }], encapsulation: i0.ViewEncapsulation.None });
|
|
173
|
+
}
|
|
174
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrTransfer, decorators: [{
|
|
175
|
+
type: Component,
|
|
176
|
+
args: [{ selector: 'wr-transfer', encapsulation: ViewEncapsulation.None, host: { '[class]': 'classes()' }, imports: [WrButton, WrCheckbox, WrInput], template: "<!--\n Two panes and the buttons between them. Each pane is a PLAIN `<ul>` of\n checkboxes, deliberately: dressing it as a `role=\"listbox\"` of `role=\"option\"`\n rows reads better in the abstract but is invalid \u2014 an option may not contain an\n interactive control, and the axe gate says so. The checkbox is the thing the\n user operates, so it is the thing the semantics should describe; the pane\n heading names the group.\n-->\n@for (pane of panes; track pane) {\n @let state = pane === 'source' ? source() : target();\n @let title = pane === 'source' ? resolvedSourceTitle() : resolvedTargetTitle();\n\n <div class=\"wr-transfer__pane\" [class.wr-transfer__pane--target]=\"pane === 'target'\">\n <div class=\"wr-transfer__head\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"state.allChecked\"\n [indeterminate]=\"state.someChecked\"\n [disabled]=\"disabled() || state.rows.length === 0\"\n [ariaLabel]=\"title\"\n (checkedChange)=\"toggleAll(pane, $event)\"\n />\n <span class=\"wr-transfer__title\">{{ title }}</span>\n <span class=\"wr-transfer__count\">{{\n countLabel({ checked: state.checkedCount, total: state.rows.length })\n }}</span>\n </div>\n\n @if (searchable()) {\n <div class=\"wr-transfer__search\">\n <input\n wrInput\n wrSize=\"sm\"\n type=\"search\"\n [placeholder]=\"resolvedSearch()\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"`${title} \u2014 ${resolvedSearch()}`\"\n (input)=\"onSearch(pane, $event)\"\n />\n </div>\n }\n\n <ul class=\"wr-transfer__list\" [attr.aria-label]=\"title\">\n @for (item of state.rows; track item.value) {\n <li class=\"wr-transfer__item\" [class.wr-transfer__item--disabled]=\"item.disabled\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"isChecked(pane, item)\"\n [disabled]=\"disabled() || !!item.disabled\"\n (checkedChange)=\"toggle(pane, item, $event)\"\n (touch)=\"touch.emit()\"\n >\n {{ item.label }}\n </wr-checkbox>\n </li>\n } @empty {\n <li class=\"wr-transfer__empty\">{{ resolvedEmpty() }}</li>\n }\n </ul>\n </div>\n\n <!-- The buttons live between the panes, so they are emitted after the first. -->\n @if (pane === 'source') {\n <div class=\"wr-transfer__actions\">\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move\"\n [disabled]=\"!canMoveRight()\"\n [attr.aria-label]=\"resolvedToTarget()\"\n (click)=\"moveRight()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move\"\n [disabled]=\"!canMoveLeft()\"\n [attr.aria-label]=\"resolvedToSource()\"\n (click)=\"moveLeft()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n </div>\n }\n}\n" }]
|
|
177
|
+
}], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], touch: [{ type: i0.Output, args: ["touch"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], searchable: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchable", required: false }] }], sourceTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "sourceTitle", required: false }] }], targetTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "targetTitle", required: false }] }], searchPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchPlaceholder", required: false }] }], emptyText: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyText", required: false }] }], toTargetLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "toTargetLabel", required: false }] }], toSourceLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "toSourceLabel", required: false }] }] } });
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Generated bundle index. Do not edit.
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
export { WrTransfer };
|
|
184
|
+
//# sourceMappingURL=ngwr-transfer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngwr-transfer.mjs","sources":["../../../projects/lib/transfer/transfer.ts","../../../projects/lib/transfer/transfer.html","../../../projects/lib/transfer/ngwr-transfer.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input, model, output, signal } from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { WrButton } from 'ngwr/button';\nimport { WrCheckbox } from 'ngwr/checkbox';\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\nimport { WrInput } from 'ngwr/input';\n\nimport type { WrTransferItem } from './interfaces';\n\n/** A pane's rows plus the header state derived from them. */\ninterface PaneState {\n readonly rows: readonly WrTransferItem[];\n readonly checkedCount: number;\n readonly allChecked: boolean;\n readonly someChecked: boolean;\n}\n\n/**\n * Dual-listbox picker: two panes and the buttons that move rows between them.\n *\n * The full item set is `[items]` and the RIGHT pane is the value — `[(value)]`\n * holds the chosen `WrTransferItem['value']`s, everything else stays left. The\n * checked state inside each pane is transient staging, deliberately not part of\n * the value: what a form cares about is which rows ended up on the right.\n *\n * A signal-forms native control (`FormValueControl<readonly unknown[]>`), so\n * `[formField]` binds straight to `value`; `[(ngModel)]` and reactive forms keep\n * working through Angular's bridge, and `[(value)]` is the standalone shape.\n *\n * @example\n * ```html\n * <!-- Standalone -->\n * <wr-transfer [items]=\"permissions\" [(value)]=\"granted\" />\n *\n * <!-- Searchable, with pane titles -->\n * <wr-transfer\n * searchable\n * sourceTitle=\"Available\"\n * targetTitle=\"Granted\"\n * [items]=\"permissions\"\n * [formField]=\"form.granted\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/transfer\n */\n@Component({\n selector: 'wr-transfer',\n templateUrl: './transfer.html',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n imports: [WrButton, WrCheckbox, WrInput],\n})\nexport class WrTransfer implements FormValueControl<readonly unknown[]> {\n /** Every row, in either pane. Membership of the right pane is `value`. */\n readonly items = input<readonly WrTransferItem[]>([]);\n\n /**\n * Values currently in the RIGHT pane. Two-way bindable; bound automatically\n * by `[formField]` / `[(ngModel)]`.\n */\n readonly value = model<readonly unknown[]>([]);\n\n /** Emitted on blur / commit so a bound field marks itself touched. */\n readonly touch = output<void>();\n\n /** Disable the whole control. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Show a filter box above each pane. @default false */\n readonly searchable = input(false, { transform: coerceBooleanProperty });\n\n /** Heading above the left pane. Falls back to `transfer.source`. */\n readonly sourceTitle = input<string | null>(null);\n\n /** Heading above the right pane. Falls back to `transfer.target`. */\n readonly targetTitle = input<string | null>(null);\n\n /** Placeholder in both filter boxes. Falls back to `transfer.search`. */\n readonly searchPlaceholder = input<string | null>(null);\n\n /** Shown in a pane with no rows. Falls back to `transfer.empty`. */\n readonly emptyText = input<string | null>(null);\n\n /** Accessible name of the move-right button. Falls back to `transfer.toTarget`. */\n readonly toTargetLabel = input<string | null>(null);\n\n /** Accessible name of the move-left button. Falls back to `transfer.toSource`. */\n readonly toSourceLabel = input<string | null>(null);\n\n protected readonly resolvedSourceTitle = useI18nText(this.sourceTitle, 'transfer.source', 'Available');\n protected readonly resolvedTargetTitle = useI18nText(this.targetTitle, 'transfer.target', 'Selected');\n protected readonly resolvedSearch = useI18nText(this.searchPlaceholder, 'transfer.search', 'Search');\n protected readonly resolvedEmpty = useI18nText(this.emptyText, 'transfer.empty', 'Nothing here');\n protected readonly resolvedToTarget = useI18nText(this.toTargetLabel, 'transfer.toTarget', 'Move to selected');\n protected readonly resolvedToSource = useI18nText(this.toSourceLabel, 'transfer.toSource', 'Move to available');\n\n /** `{{checked}} / {{total}}` under each heading. @internal */\n protected readonly countLabel = useI18nFormatter('transfer.count', '{{checked}} / {{total}}');\n\n /** Pane order — the template iterates it so both panes share one block. */\n protected readonly panes = ['source', 'target'] as const;\n\n private readonly sourceQuery = signal('');\n private readonly targetQuery = signal('');\n\n /** Staged rows, per pane. Cleared as soon as a move commits them. */\n private readonly sourceChecked = signal<readonly unknown[]>([]);\n private readonly targetChecked = signal<readonly unknown[]>([]);\n\n private readonly valueSet = computed(() => new Set(this.value()));\n\n protected readonly source = computed<PaneState>(() =>\n this.pane(\n this.items().filter(item => !this.valueSet().has(item.value)),\n this.sourceQuery(),\n this.sourceChecked()\n )\n );\n\n protected readonly target = computed<PaneState>(() =>\n this.pane(\n // Right-pane order follows `value`, not `items`: the order a user built is\n // the one they expect to read back.\n this.value()\n .map(v => this.items().find(item => item.value === v))\n .filter((item): item is WrTransferItem => item !== undefined),\n this.targetQuery(),\n this.targetChecked()\n )\n );\n\n protected readonly canMoveRight = computed(() => !this.disabled() && this.source().checkedCount > 0);\n protected readonly canMoveLeft = computed(() => !this.disabled() && this.target().checkedCount > 0);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-transfer'];\n if (this.disabled()) parts.push('wr-transfer--disabled');\n if (this.searchable()) parts.push('wr-transfer--searchable');\n return parts.join(' ');\n });\n\n protected isChecked(pane: 'source' | 'target', item: WrTransferItem): boolean {\n return (pane === 'source' ? this.sourceChecked() : this.targetChecked()).includes(item.value);\n }\n\n protected toggle(pane: 'source' | 'target', item: WrTransferItem, checked: boolean): void {\n if (item.disabled) return;\n const box = pane === 'source' ? this.sourceChecked : this.targetChecked;\n const current = box();\n box.set(checked ? [...current, item.value] : current.filter(v => v !== item.value));\n }\n\n /** Header checkbox — stages or clears every enabled row the filter shows. */\n protected toggleAll(pane: 'source' | 'target', checked: boolean): void {\n const state = pane === 'source' ? this.source() : this.target();\n const box = pane === 'source' ? this.sourceChecked : this.targetChecked;\n box.set(checked ? state.rows.filter(item => !item.disabled).map(item => item.value) : []);\n }\n\n protected onSearch(pane: 'source' | 'target', event: Event): void {\n const query = (event.target as HTMLInputElement | null)?.value ?? '';\n (pane === 'source' ? this.sourceQuery : this.targetQuery).set(query);\n }\n\n protected moveRight(): void {\n const moving = this.sourceChecked();\n if (moving.length === 0) return;\n this.value.set([...this.value(), ...moving]);\n this.sourceChecked.set([]);\n this.touch.emit();\n }\n\n protected moveLeft(): void {\n const moving = new Set(this.targetChecked());\n if (moving.size === 0) return;\n this.value.set(this.value().filter(v => !moving.has(v)));\n this.targetChecked.set([]);\n this.touch.emit();\n }\n\n /** Filter, then derive the header state from what survived. */\n private pane(rows: readonly WrTransferItem[], query: string, checked: readonly unknown[]): PaneState {\n const q = query.trim().toLowerCase();\n const visible = q ? rows.filter(item => item.label.toLowerCase().includes(q)) : rows;\n const enabled = visible.filter(item => !item.disabled);\n const staged = new Set(checked);\n const checkedCount = enabled.filter(item => staged.has(item.value)).length;\n return {\n rows: visible,\n checkedCount,\n allChecked: enabled.length > 0 && checkedCount === enabled.length,\n someChecked: checkedCount > 0 && checkedCount < enabled.length,\n };\n }\n}\n","<!--\n Two panes and the buttons between them. Each pane is a PLAIN `<ul>` of\n checkboxes, deliberately: dressing it as a `role=\"listbox\"` of `role=\"option\"`\n rows reads better in the abstract but is invalid — an option may not contain an\n interactive control, and the axe gate says so. The checkbox is the thing the\n user operates, so it is the thing the semantics should describe; the pane\n heading names the group.\n-->\n@for (pane of panes; track pane) {\n @let state = pane === 'source' ? source() : target();\n @let title = pane === 'source' ? resolvedSourceTitle() : resolvedTargetTitle();\n\n <div class=\"wr-transfer__pane\" [class.wr-transfer__pane--target]=\"pane === 'target'\">\n <div class=\"wr-transfer__head\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"state.allChecked\"\n [indeterminate]=\"state.someChecked\"\n [disabled]=\"disabled() || state.rows.length === 0\"\n [ariaLabel]=\"title\"\n (checkedChange)=\"toggleAll(pane, $event)\"\n />\n <span class=\"wr-transfer__title\">{{ title }}</span>\n <span class=\"wr-transfer__count\">{{\n countLabel({ checked: state.checkedCount, total: state.rows.length })\n }}</span>\n </div>\n\n @if (searchable()) {\n <div class=\"wr-transfer__search\">\n <input\n wrInput\n wrSize=\"sm\"\n type=\"search\"\n [placeholder]=\"resolvedSearch()\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"`${title} — ${resolvedSearch()}`\"\n (input)=\"onSearch(pane, $event)\"\n />\n </div>\n }\n\n <ul class=\"wr-transfer__list\" [attr.aria-label]=\"title\">\n @for (item of state.rows; track item.value) {\n <li class=\"wr-transfer__item\" [class.wr-transfer__item--disabled]=\"item.disabled\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"isChecked(pane, item)\"\n [disabled]=\"disabled() || !!item.disabled\"\n (checkedChange)=\"toggle(pane, item, $event)\"\n (touch)=\"touch.emit()\"\n >\n {{ item.label }}\n </wr-checkbox>\n </li>\n } @empty {\n <li class=\"wr-transfer__empty\">{{ resolvedEmpty() }}</li>\n }\n </ul>\n </div>\n\n <!-- The buttons live between the panes, so they are emitted after the first. -->\n @if (pane === 'source') {\n <div class=\"wr-transfer__actions\">\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move\"\n [disabled]=\"!canMoveRight()\"\n [attr.aria-label]=\"resolvedToTarget()\"\n (click)=\"moveRight()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move\"\n [disabled]=\"!canMoveLeft()\"\n [attr.aria-label]=\"resolvedToSource()\"\n (click)=\"moveLeft()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n </div>\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;AAKG;AAqBH;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;MAQU,UAAU,CAAA;;IAEZ,KAAK,GAAG,KAAK,CAA4B,EAAE;8EAAC;AAErD;;;AAGG;IACM,KAAK,GAAG,KAAK,CAAqB,EAAE;8EAAC;;IAGrC,KAAK,GAAG,MAAM,EAAQ;;IAGtB,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;;IAG7D,UAAU,GAAG,KAAK,CAAC,KAAK,kFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;;IAG/D,WAAW,GAAG,KAAK,CAAgB,IAAI;oFAAC;;IAGxC,WAAW,GAAG,KAAK,CAAgB,IAAI;oFAAC;;IAGxC,iBAAiB,GAAG,KAAK,CAAgB,IAAI;0FAAC;;IAG9C,SAAS,GAAG,KAAK,CAAgB,IAAI;kFAAC;;IAGtC,aAAa,GAAG,KAAK,CAAgB,IAAI;sFAAC;;IAG1C,aAAa,GAAG,KAAK,CAAgB,IAAI;sFAAC;IAEhC,mBAAmB,GAAG,WAAW,CA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