ngwr 14.4.0 → 14.5.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 +3 -3
- package/fesm2022/ngwr-breadcrumbs.mjs +2 -2
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +15 -3
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +18 -2
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +35 -3
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +30 -2
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +12 -1
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-drag-drop.mjs +2 -2
- package/fesm2022/ngwr-drag-drop.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +48 -2
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +22 -2
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-graph-testing.mjs +243 -0
- package/fesm2022/ngwr-graph-testing.mjs.map +1 -0
- package/fesm2022/ngwr-graph.mjs +1112 -0
- package/fesm2022/ngwr-graph.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-ar.mjs +5 -0
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +5 -0
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +5 -0
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +9 -0
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +5 -0
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +5 -0
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +5 -0
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +5 -0
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +5 -0
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +5 -0
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +5 -0
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +5 -0
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +5 -0
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +5 -0
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +5 -0
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +5 -0
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +5 -0
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +5 -0
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +5 -0
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +5 -0
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-TW.mjs +5 -0
- package/fesm2022/ngwr-i18n-zh-TW.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +5 -0
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +25 -4
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +2 -2
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-mention.mjs +18 -2
- package/fesm2022/ngwr-mention.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +119 -4
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm.mjs +19 -3
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover-testing.mjs +22 -5
- package/fesm2022/ngwr-popover-testing.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +215 -27
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +34 -1
- package/fesm2022/ngwr-segmented.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +15 -1
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-toast.mjs +19 -2
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +20 -6
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +9 -2
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-window.mjs +18 -1
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/graph/styles/_index.scss +113 -0
- package/i18n/ar.json +5 -0
- package/i18n/cs.json +5 -0
- package/i18n/de.json +5 -0
- package/i18n/en.json +5 -0
- package/i18n/es.json +5 -0
- package/i18n/fr.json +5 -0
- package/i18n/he.json +5 -0
- package/i18n/hi.json +5 -0
- package/i18n/id.json +5 -0
- package/i18n/it.json +5 -0
- package/i18n/ja.json +5 -0
- package/i18n/ko.json +5 -0
- package/i18n/nl.json +5 -0
- package/i18n/pl.json +5 -0
- package/i18n/pt.json +5 -0
- package/i18n/ru.json +5 -0
- package/i18n/sv.json +5 -0
- package/i18n/tr.json +5 -0
- package/i18n/uk.json +5 -0
- package/i18n/vi.json +5 -0
- package/i18n/zh-TW.json +5 -0
- package/i18n/zh.json +5 -0
- package/llms-full.txt +12 -2
- package/llms.txt +8 -6
- package/package.json +10 -1
- package/schematics/use/symbol-map.json +2 -0
- package/segmented/styles/_index.scss +8 -0
- package/skills/ngwr/SKILL.md +1 -1
- package/skills/ngwr/references/catalog.md +2 -0
- package/styles.scss +1 -0
- package/theme/styles/_focus.scss +7 -0
- package/types/ngwr-cascader.d.ts +7 -0
- package/types/ngwr-color-picker.d.ts +8 -0
- package/types/ngwr-context-menu.d.ts +10 -0
- package/types/ngwr-date-picker.d.ts +16 -0
- package/types/ngwr-dialog.d.ts +1 -0
- package/types/ngwr-drawer.d.ts +28 -0
- package/types/ngwr-dropdown.d.ts +9 -0
- package/types/ngwr-graph-testing.d.ts +190 -0
- package/types/ngwr-graph.d.ts +203 -0
- package/types/ngwr-lightbox.d.ts +15 -0
- package/types/ngwr-mention.d.ts +7 -0
- package/types/ngwr-overlay.d.ts +62 -4
- package/types/ngwr-popconfirm.d.ts +1 -0
- package/types/ngwr-popover-testing.d.ts +22 -5
- package/types/ngwr-popover.d.ts +28 -8
- package/types/ngwr-segmented.d.ts +16 -0
- package/types/ngwr-select.d.ts +7 -0
- package/types/ngwr-toast.d.ts +2 -0
- package/types/ngwr-tour.d.ts +6 -0
- package/types/ngwr-tree.d.ts +2 -1
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr-window.d.ts +1 -0
package/fesm2022/ngwr-dialog.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';
|
|
2
|
+
import { Directionality } from '@angular/cdk/bidi';
|
|
2
3
|
import { ScrollStrategyOptions } from '@angular/cdk/overlay';
|
|
3
4
|
import { ComponentPortal } from '@angular/cdk/portal';
|
|
4
5
|
import { isPlatformBrowser, Location } from '@angular/common';
|
|
5
6
|
import * as i0 from '@angular/core';
|
|
6
7
|
import { InjectionToken, inject, EnvironmentInjector, PLATFORM_ID, Injector, afterEveryRender, Service, ElementRef, Directive, input, computed } from '@angular/core';
|
|
7
8
|
import { WrI18n } from 'ngwr/i18n';
|
|
8
|
-
import { WR_OVERLAY, WR_RESPONSIVE_OVERLAYS, wrPresentAsSheet, wrAppendOverlayClose } from 'ngwr/overlay';
|
|
9
|
+
import { WR_OVERLAY, WR_RESPONSIVE_OVERLAYS, wrPresentAsSheet, wrFollowDirection, wrAppendOverlayClose } from 'ngwr/overlay';
|
|
9
10
|
import { ReplaySubject } from 'rxjs';
|
|
10
11
|
import * as i1 from '@angular/cdk/scrolling';
|
|
11
12
|
import { CdkScrollable } from '@angular/cdk/scrolling';
|
|
@@ -211,6 +212,7 @@ class WrDialog {
|
|
|
211
212
|
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
212
213
|
responsiveConfig = inject(WR_RESPONSIVE_OVERLAYS);
|
|
213
214
|
i18n = inject(WrI18n, { optional: true });
|
|
215
|
+
dir = inject(Directionality, { optional: true });
|
|
214
216
|
// Resolvable wherever the CDK's own `Overlay` is — it injects the same thing
|
|
215
217
|
// to implement `disposeOnNavigation`.
|
|
216
218
|
location = inject(Location);
|
|
@@ -239,6 +241,15 @@ class WrDialog {
|
|
|
239
241
|
width: asSheet ? '100%' : options.width,
|
|
240
242
|
maxWidth: asSheet ? '100%' : options.maxWidth,
|
|
241
243
|
});
|
|
244
|
+
// The CDK captures the direction as a string at create and never looks
|
|
245
|
+
// again, so an app that flips while a dialog is up leaves the panel behind.
|
|
246
|
+
// Nothing here derives from it — the box is centred and its x offset is
|
|
247
|
+
// empty, so `apply()`'s RTL branch moves nothing — but the `dir` attribute
|
|
248
|
+
// is what the dialog's own logical CSS and every ngwr control inside it
|
|
249
|
+
// resolve `start` and `end` against, so it has to follow. No teardown kept:
|
|
250
|
+
// the follower ends on the ref's own `detachments()`, which every dismissal
|
|
251
|
+
// path goes through, and each `open()` creates a fresh ref of its own.
|
|
252
|
+
wrFollowDirection(overlayRef, this.dir, this.parentInjector);
|
|
242
253
|
const dialogRef = new WrDialogRef(overlayRef);
|
|
243
254
|
if (this.isBrowser) {
|
|
244
255
|
const active = document.activeElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-dialog.mjs","sources":["../../../projects/lib/dialog/dialog-ref.ts","../../../projects/lib/dialog/tokens/dialog-data.token.ts","../../../projects/lib/dialog/tokens/dialog-ref.token.ts","../../../projects/lib/dialog/dialog.ts","../../../projects/lib/dialog/directives/dialog-title.ts","../../../projects/lib/dialog/directives/dialog-content.ts","../../../projects/lib/dialog/directives/dialog-footer.ts","../../../projects/lib/dialog/directives/dialog-close.ts","../../../projects/lib/dialog/ngwr-dialog.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 type { ConfigurableFocusTrap } from '@angular/cdk/a11y';\nimport type { OverlayRef } from '@angular/cdk/overlay';\nimport type { ComponentRef } from '@angular/core';\n\nimport { ReplaySubject } from 'rxjs';\n\n/**\n * Handle returned by `WrDialog.open()`.\n *\n * Wraps the underlying `OverlayRef` and tracks the close result. It is also\n * provided inside the dialog's own injector, so the projected content can\n * inject it and close itself — the counterpart to `[wrDialogClose]` when the\n * close is programmatic (after a save succeeds, say) rather than a click.\n *\n * @example\n * ```ts\n * // Caller side.\n * const ref = dialog.open<ConfirmComponent, boolean>(ConfirmComponent);\n * const result = await ref.awaitClose(); // boolean | undefined\n * ```\n *\n * @example\n * ```ts\n * // Content side — the dialog closes itself.\n * @Component({...})\n * export class ConfirmComponent {\n * private readonly ref = inject(WrDialogRef);\n *\n * save(): void {\n * this.store.save();\n * this.ref.close(true);\n * }\n * }\n * ```\n */\nexport class WrDialogRef<C, R = unknown> {\n /**\n * Emits the close result once and completes.\n *\n * A `ReplaySubject`, not a plain `Subject`, so the result survives a late\n * subscriber: content can close itself before `open()` has even returned, and\n * `awaitClose()` may be called long after the dismissal — both would otherwise\n * see only `complete` and resolve `undefined`.\n */\n readonly closed = new ReplaySubject<R | undefined>(1);\n\n /** @internal */\n componentRef: ComponentRef<C> | null = null;\n\n /** @internal */\n focusTrap: ConfigurableFocusTrap | null = null;\n\n /** @internal */\n previouslyFocused: HTMLElement | null = null;\n\n constructor(private readonly _overlayRef: OverlayRef) {}\n\n /** The instantiated dialog component. */\n get componentInstance(): C {\n if (!this.componentRef) {\n throw new Error('WrDialogRef: component not yet attached');\n }\n return this.componentRef.instance;\n }\n\n private isClosed = false;\n\n /** Close the dialog, optionally returning a result. */\n close(result?: R): void {\n if (this.isClosed) return;\n this.isClosed = true;\n this.closed.next(result);\n this.closed.complete();\n // Content that closes itself while constructing gets here with\n // `OverlayRef.attach()` still on the stack — `componentRef` is assigned\n // only once attach returns. Disposing mid-attach leaves the CDK writing to\n // a detached host, so let the current task finish first.\n if (!this.componentRef) {\n queueMicrotask(() => this.teardown());\n return;\n }\n this.teardown();\n }\n\n private teardown(): void {\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n this._overlayRef.dispose();\n // Drop the destroyed component so a retained ref doesn't pin its instance,\n // host element and view in memory.\n this.componentRef = null;\n // Restore focus after disposal so the trigger is reachable again.\n if (restore && typeof restore.focus === 'function') {\n restore.focus();\n }\n }\n\n /** Resolves with the close result when the dialog is dismissed. */\n awaitClose(): Promise<R | undefined> {\n return new Promise(resolve => {\n this.closed.subscribe({\n next: value => resolve(value),\n complete: () => resolve(undefined),\n });\n });\n }\n\n /** Underlying overlay ref — escape hatch for advanced cases. */\n get overlayRef(): OverlayRef {\n return this._overlayRef;\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 { InjectionToken } from '@angular/core';\n\n/**\n * Token that exposes the `data` payload passed to `WrDialog.open()`.\n *\n * @example\n * ```ts\n * @Component({...})\n * export class ConfirmComponent {\n * readonly data = inject<ConfirmData>(WR_DIALOG_DATA);\n * }\n * ```\n */\nexport const WR_DIALOG_DATA = new InjectionToken<unknown>('WR_DIALOG_DATA');\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 { WrDialogRef } from '../dialog-ref';\n\n/**\n * Token exposing the open dialog's `WrDialogRef` to components and\n * directives rendered inside it (e.g. `[wrDialogClose]`).\n *\n * **Prefer `inject(WrDialogRef)`** — the ref is provided under the class token\n * too, and the class path is the documented one. It already covers both cases\n * you might reach for a token for: `inject(WrDialogRef, { optional: true })`\n * works for content that also renders outside a dialog, and\n * `inject<WrDialogRef<ConfirmComponent, boolean>>(WrDialogRef)` types the\n * generics without a cast.\n *\n * This token is the same object under a second key. It exists for the library's\n * own directives (`[wrDialogClose]`) and for swapping the provider out — a test\n * stub, say — without touching the class.\n *\n * @example\n * ```ts\n * @Component({...})\n * export class ConfirmComponent {\n * private readonly ref = inject<WrDialogRef<ConfirmComponent, boolean>>(WrDialogRef);\n *\n * confirm(): void {\n * this.ref.close(true);\n * }\n * }\n * ```\n */\nexport const WR_DIALOG_REF = new InjectionToken<WrDialogRef<unknown, unknown>>('WR_DIALOG_REF');\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, type ComponentType } from '@angular/cdk/portal';\nimport { Location, isPlatformBrowser } from '@angular/common';\nimport { EnvironmentInjector, Service, Injector, PLATFORM_ID, afterEveryRender, inject } from '@angular/core';\n\nimport { WrI18n } from 'ngwr/i18n';\nimport { WR_OVERLAY, WR_RESPONSIVE_OVERLAYS, wrAppendOverlayClose, wrPresentAsSheet } from 'ngwr/overlay';\n\nimport { WrDialogRef } from './dialog-ref';\nimport type { WrDialogOptions } from './interfaces';\nimport { WR_DIALOG_DATA, WR_DIALOG_REF } from './tokens';\n\nconst DEFAULT_PANEL_CLASS = 'wr-dialog-panel';\nconst DEFAULT_BACKDROP_CLASS = 'wr-dialog-backdrop';\n\n/**\n * Opens dialog components in an isolated NGWR overlay.\n *\n * Uses `WR_OVERLAY` so it composes cleanly with `provideWrOverlay()`\n * — dialogs render into NGWR's own overlay container and never collide\n * with other CDK consumers (Material, NG-ZORRO, etc.).\n *\n * @example\n * ```ts\n * const dialog = inject(WrDialog);\n *\n * const ref = dialog.open(ConfirmComponent, {\n * data: { message: 'Delete this item?' },\n * width: '24rem',\n * });\n *\n * const ok = await ref.awaitClose();\n * if (ok) remove();\n * ```\n *\n * @see https://ngwr.dev/reference/components/dialog\n */\n@Service()\nexport class WrDialog {\n private readonly overlay = inject(WR_OVERLAY);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly parentInjector = inject(EnvironmentInjector);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly responsiveConfig = inject(WR_RESPONSIVE_OVERLAYS);\n private readonly i18n = inject(WrI18n, { optional: true });\n // Resolvable wherever the CDK's own `Overlay` is — it injects the same thing\n // to implement `disposeOnNavigation`.\n private readonly location = inject(Location);\n\n open<C, R = unknown, D = unknown>(component: ComponentType<C>, options: WrDialogOptions<D> = {}): WrDialogRef<C, R> {\n const panelClasses: string[] = [DEFAULT_PANEL_CLASS];\n const extra = options.panelClass;\n if (typeof extra === 'string') {\n panelClasses.push(extra);\n } else if (extra) {\n for (const cls of extra) panelClasses.push(cls);\n }\n\n // On small viewports (when opted in) present as a slide-up sheet pinned\n // to the bottom edge, full-width, instead of a centred modal.\n const asSheet = wrPresentAsSheet(options.responsive, this.responsiveConfig);\n if (asSheet) panelClasses.push('wr-overlay-sheet');\n\n const position = this.overlay.position().global().centerHorizontally();\n const overlayRef: OverlayRef = this.overlay.create({\n positionStrategy: asSheet ? position.bottom('0') : position.centerVertically(),\n scrollStrategy: this.scrollStrategies.block(),\n hasBackdrop: true,\n backdropClass: DEFAULT_BACKDROP_CLASS,\n panelClass: panelClasses,\n width: asSheet ? '100%' : options.width,\n maxWidth: asSheet ? '100%' : options.maxWidth,\n });\n\n const dialogRef = new WrDialogRef<C, R>(overlayRef);\n\n if (this.isBrowser) {\n const active = document.activeElement;\n dialogRef.previouslyFocused = active instanceof HTMLElement ? active : null;\n }\n\n const injector = Injector.create({\n parent: this.parentInjector,\n providers: [\n { provide: WR_DIALOG_DATA, useValue: options.data },\n { provide: WR_DIALOG_REF, useValue: dialogRef },\n // Provided as its own token as well, so dialog content can reach for\n // the familiar `inject(WrDialogRef)` and close itself.\n { provide: WrDialogRef, useValue: dialogRef },\n ],\n });\n\n const portal = new ComponentPortal(component, null, injector);\n dialogRef.componentRef = overlayRef.attach(portal);\n\n // Wired BEFORE the panel is decorated, and the order is the fix: everything\n // below attaches attributes, a ✕ and a focus trap to an overlay that is\n // already on screen, so anything that throws in there used to leave an\n // `aria-modal` panel with no dismissal path at all — no ✕, no backdrop\n // handler, no Escape — over the whole application, and no ref for the caller\n // to close it with. A dialog that fails to finish opening must still be one\n // the user can get rid of. Overlay subscriptions complete when the overlay is\n // disposed, so no explicit teardown is required.\n if (options.closeOnBackdropClick !== false) {\n overlayRef.backdropClick().subscribe(() => dialogRef.close());\n }\n if (options.closeOnEscape !== false) {\n overlayRef.keydownEvents().subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n dialogRef.close();\n }\n });\n }\n if (options.closeOnNavigation !== false) {\n this.watchNavigation(overlayRef, dialogRef);\n }\n\n if (this.isBrowser) {\n const host = overlayRef.overlayElement;\n host.setAttribute('role', 'dialog');\n host.setAttribute('aria-modal', 'true');\n // Built-in dismiss. Appended after the content portal so it paints above\n // it, and marked on the panel so the title reserves the corner gutter.\n if (options.closable !== false) {\n host.classList.add('wr-dialog-panel--closable');\n const label = options.closeLabel ?? this.closeLabel();\n wrAppendOverlayClose(host, 'wr-dialog__close', label, () => dialogRef.close());\n }\n // Wire aria-labelledby to wrDialogTitle's auto-id once content is in DOM.\n // Has to wait for a render, not a microtask: attaching the portal only\n // schedules change detection, so under zoneless CD a microtask runs while\n // the content is still an empty view and the title id doesn't exist yet.\n //\n // And after EVERY render, not just the next one: the title belongs to the\n // caller's component, so an `@if` or a late-arriving heading can replace\n // or remove the element the attribute names. A reference to a node that is\n // no longer there is not a name — the dialog announces as unnamed — so a\n // missing title clears the attribute rather than leaving it dangling.\n const labelSync = afterEveryRender(\n () => {\n const titleEl = host.querySelector<HTMLElement>('[wrDialogTitle], [wr-dialog-title]');\n if (titleEl?.id) host.setAttribute('aria-labelledby', titleEl.id);\n else host.removeAttribute('aria-labelledby');\n },\n { injector: this.parentInjector }\n );\n // The hook is bound to the root injector, so it outlives the dialog unless\n // it is torn down with it. `detachments()` fires on dispose, which is the\n // one path every dismissal goes through.\n overlayRef.detachments().subscribe(() => labelSync.destroy());\n // Trap focus inside the dialog and move initial focus in.\n const trap = this.focusTrapFactory.create(host);\n dialogRef.focusTrap = trap;\n void trap.focusInitialElementWhenReady();\n }\n\n return dialogRef;\n }\n\n /**\n * Tie the dialog's lifetime to the URL it was opened on.\n *\n * Nothing else does. The overlay belongs to a root service and is dismissed\n * only by the backdrop, Escape or an explicit `close()`, so pressing Back\n * swapped the routed view underneath and left the modal pane, its backdrop and\n * its focus trap sitting over a page the user never opened them on.\n *\n * `onUrlChange`, not `Location.subscribe()` — which is what CDK's own\n * `disposeOnNavigation` uses: `subscribe` fires on popstate alone, so an\n * in-app `router.navigate()` left the dialog standing. And `dialogRef.close()`\n * rather than disposing the overlay behind the ref's back, which would never\n * emit `closed`, never destroy the focus trap, and leave `awaitClose()`\n * pending forever.\n */\n private watchNavigation<C, R>(overlayRef: OverlayRef, dialogRef: WrDialogRef<C, R>): void {\n const stopWatching = this.location.onUrlChange(() => dialogRef.close());\n // Unhooked a microtask late, because `Location` notifies its listeners with\n // a `forEach` and unregistering splices the array it is iterating: removing\n // ours synchronously from inside the notification would shift the next entry\n // into the slot forEach has already passed, and a SECOND stacked dialog\n // would be skipped and left behind.\n overlayRef.detachments().subscribe(() => queueMicrotask(stopWatching));\n }\n\n /**\n * The dismiss button's accessible name.\n *\n * Two failure modes, and resolving PER OPEN is what covers both. `t()` hands\n * back the KEY on a miss, and `WrI18n` is root-provided with an empty catalog\n * by default, so an app that never configured i18n named its dismiss button\n * \"dialog.close\" — a name axe cannot fault, because a name is present, and a\n * screen reader reads out verbatim. Resolving once at injection time fixed\n * that but froze the answer: this is a root service, constructed before an\n * async catalog has loaded, so a localized app got the English fallback on\n * every dialog it ever opened.\n */\n private closeLabel(): string {\n const resolved = this.i18n?.t('dialog.close');\n return !resolved || resolved === 'dialog.close' ? 'Close dialog' : resolved;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, ElementRef, inject } from '@angular/core';\n\nlet uid = 0;\n\n/**\n * Styles a dialog title row. Use on a heading inside an opened dialog.\n * Auto-assigns an `id` so the dialog panel can reference it via\n * `aria-labelledby`.\n *\n * @example\n * ```html\n * <h2 wrDialogTitle>Confirm delete</h2>\n * ```\n */\n@Directive({\n selector: '[wrDialogTitle]',\n host: { class: 'wr-dialog__title', '[attr.id]': 'id' },\n})\nexport class WrDialogTitle {\n /** Generated id used for `aria-labelledby` wiring. */\n readonly id = `wr-dialog-title-${++uid}`;\n\n /** @internal */\n readonly elementRef = inject(ElementRef<HTMLElement>);\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 { CdkScrollable } from '@angular/cdk/scrolling';\nimport { Directive } from '@angular/core';\n\n/**\n * Styles the scrollable body section of a dialog.\n *\n * `CdkScrollable` is a host directive because this element is a real scroll\n * container (`overflow: auto`) and an anchored overlay opened from inside it has\n * to follow its trigger. CDK's `reposition()` strategy listens to\n * `ScrollDispatcher`, which is fed by registered scrollables plus ONE\n * non-capturing `document` listener — and element `scroll` does not bubble, so\n * without the registration a `<wr-select>` halfway down a long dialog form kept\n * its panel pinned to the viewport while the trigger scrolled away. Angular\n * Material carries the same host directive on `MatDialogContent` for the same\n * reason.\n *\n * @example\n * ```html\n * <div wrDialogContent>…body…</div>\n * ```\n */\n@Directive({\n selector: '[wrDialogContent]',\n host: { class: 'wr-dialog__content' },\n hostDirectives: [CdkScrollable],\n})\nexport class WrDialogContent {}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, computed, input } from '@angular/core';\n\n/**\n * Footer row, typically holding action buttons.\n *\n * @example\n * ```html\n * <div wrDialogFooter align=\"end\">\n * <wr-btn wrDialogClose>Cancel</wr-btn>\n * <wr-btn color=\"danger\" (click)=\"confirm()\">Delete</wr-btn>\n * </div>\n * ```\n */\n@Directive({\n selector: '[wrDialogFooter]',\n host: { '[class]': 'classes()' },\n})\nexport class WrDialogFooter {\n /**\n * Horizontal alignment of the children.\n *\n * @default 'end'\n */\n readonly align = input<'start' | 'center' | 'end'>('end');\n\n protected readonly classes = computed(() => `wr-dialog__footer wr-dialog__footer--${this.align()}`);\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, inject, input } from '@angular/core';\n\nimport type { WrDialogRef } from '../dialog-ref';\nimport { WR_DIALOG_REF } from '../tokens';\n\n/**\n * Closes the dialog when the host element is clicked.\n *\n * Optionally passes a `[wrDialogClose]` value as the close result.\n *\n * @example\n * ```html\n * <wr-btn wrDialogClose>Cancel</wr-btn>\n * <wr-btn color=\"primary\" [wrDialogClose]=\"true\">Confirm</wr-btn>\n * ```\n */\n@Directive({\n selector: '[wrDialogClose]',\n host: { '(click)': 'onClick()' },\n})\nexport class WrDialogClose<R = unknown> {\n /**\n * Value to pass to `close()`. When unset — or used as a bare attribute — the\n * dialog closes with `undefined`.\n */\n readonly result = input<R | undefined, R | undefined | ''>(undefined, {\n alias: 'wrDialogClose',\n // A bare `wrDialogClose` attribute arrives as the empty string; that means\n // \"no result\", not a result of `''`. Matches `wrDrawerClose`.\n transform: value => (value === '' ? undefined : value),\n });\n\n private readonly ref = inject<WrDialogRef<unknown, R>>(WR_DIALOG_REF, { optional: true });\n\n protected onClick(): void {\n this.ref?.close(this.result());\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;AAKG;AAQH;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;MACU,WAAW,CAAA;AAoBO,IAAA,WAAA;AAnB7B;;;;;;;AAOG;AACM,IAAA,MAAM,GAAG,IAAI,aAAa,CAAgB,CAAC,CAAC;;IAGrD,YAAY,GAA2B,IAAI;;IAG3C,SAAS,GAAiC,IAAI;;IAG9C,iBAAiB,GAAuB,IAAI;AAE5C,IAAA,WAAA,CAA6B,WAAuB,EAAA;QAAvB,IAAA,CAAA,WAAW,GAAX,WAAW;IAAe;;AAGvD,IAAA,IAAI,iBAAiB,GAAA;AACnB,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;AACtB,YAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;QAC5D;AACA,QAAA,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ;I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Ae;;;AAGtB,QAAA,SAAS,EAAE,KAAK,KAAK,KAAK,KAAK,EAAE,GAAG,SAAS,GAAG,KAAK,CAAC,GACtD;IAEe,GAAG,GAAG,MAAM,CAA0B,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAE/E,OAAO,GAAA;QACf,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IAChC;uGAhBW,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAb,aAAa,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,EAAA,MAAA,EAAA,EAAA,iBAAA,EAAA,QAAA,EAAA,UAAA,EAAA,eAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,WAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBAJzB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,iBAAiB;AAC3B,oBAAA,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE;AACjC,iBAAA;;;AC1BD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngwr-dialog.mjs","sources":["../../../projects/lib/dialog/dialog-ref.ts","../../../projects/lib/dialog/tokens/dialog-data.token.ts","../../../projects/lib/dialog/tokens/dialog-ref.token.ts","../../../projects/lib/dialog/dialog.ts","../../../projects/lib/dialog/directives/dialog-title.ts","../../../projects/lib/dialog/directives/dialog-content.ts","../../../projects/lib/dialog/directives/dialog-footer.ts","../../../projects/lib/dialog/directives/dialog-close.ts","../../../projects/lib/dialog/ngwr-dialog.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 type { ConfigurableFocusTrap } from '@angular/cdk/a11y';\nimport type { OverlayRef } from '@angular/cdk/overlay';\nimport type { ComponentRef } from '@angular/core';\n\nimport { ReplaySubject } from 'rxjs';\n\n/**\n * Handle returned by `WrDialog.open()`.\n *\n * Wraps the underlying `OverlayRef` and tracks the close result. It is also\n * provided inside the dialog's own injector, so the projected content can\n * inject it and close itself — the counterpart to `[wrDialogClose]` when the\n * close is programmatic (after a save succeeds, say) rather than a click.\n *\n * @example\n * ```ts\n * // Caller side.\n * const ref = dialog.open<ConfirmComponent, boolean>(ConfirmComponent);\n * const result = await ref.awaitClose(); // boolean | undefined\n * ```\n *\n * @example\n * ```ts\n * // Content side — the dialog closes itself.\n * @Component({...})\n * export class ConfirmComponent {\n * private readonly ref = inject(WrDialogRef);\n *\n * save(): void {\n * this.store.save();\n * this.ref.close(true);\n * }\n * }\n * ```\n */\nexport class WrDialogRef<C, R = unknown> {\n /**\n * Emits the close result once and completes.\n *\n * A `ReplaySubject`, not a plain `Subject`, so the result survives a late\n * subscriber: content can close itself before `open()` has even returned, and\n * `awaitClose()` may be called long after the dismissal — both would otherwise\n * see only `complete` and resolve `undefined`.\n */\n readonly closed = new ReplaySubject<R | undefined>(1);\n\n /** @internal */\n componentRef: ComponentRef<C> | null = null;\n\n /** @internal */\n focusTrap: ConfigurableFocusTrap | null = null;\n\n /** @internal */\n previouslyFocused: HTMLElement | null = null;\n\n constructor(private readonly _overlayRef: OverlayRef) {}\n\n /** The instantiated dialog component. */\n get componentInstance(): C {\n if (!this.componentRef) {\n throw new Error('WrDialogRef: component not yet attached');\n }\n return this.componentRef.instance;\n }\n\n private isClosed = false;\n\n /** Close the dialog, optionally returning a result. */\n close(result?: R): void {\n if (this.isClosed) return;\n this.isClosed = true;\n this.closed.next(result);\n this.closed.complete();\n // Content that closes itself while constructing gets here with\n // `OverlayRef.attach()` still on the stack — `componentRef` is assigned\n // only once attach returns. Disposing mid-attach leaves the CDK writing to\n // a detached host, so let the current task finish first.\n if (!this.componentRef) {\n queueMicrotask(() => this.teardown());\n return;\n }\n this.teardown();\n }\n\n private teardown(): void {\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n this._overlayRef.dispose();\n // Drop the destroyed component so a retained ref doesn't pin its instance,\n // host element and view in memory.\n this.componentRef = null;\n // Restore focus after disposal so the trigger is reachable again.\n if (restore && typeof restore.focus === 'function') {\n restore.focus();\n }\n }\n\n /** Resolves with the close result when the dialog is dismissed. */\n awaitClose(): Promise<R | undefined> {\n return new Promise(resolve => {\n this.closed.subscribe({\n next: value => resolve(value),\n complete: () => resolve(undefined),\n });\n });\n }\n\n /** Underlying overlay ref — escape hatch for advanced cases. */\n get overlayRef(): OverlayRef {\n return this._overlayRef;\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 { InjectionToken } from '@angular/core';\n\n/**\n * Token that exposes the `data` payload passed to `WrDialog.open()`.\n *\n * @example\n * ```ts\n * @Component({...})\n * export class ConfirmComponent {\n * readonly data = inject<ConfirmData>(WR_DIALOG_DATA);\n * }\n * ```\n */\nexport const WR_DIALOG_DATA = new InjectionToken<unknown>('WR_DIALOG_DATA');\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 { WrDialogRef } from '../dialog-ref';\n\n/**\n * Token exposing the open dialog's `WrDialogRef` to components and\n * directives rendered inside it (e.g. `[wrDialogClose]`).\n *\n * **Prefer `inject(WrDialogRef)`** — the ref is provided under the class token\n * too, and the class path is the documented one. It already covers both cases\n * you might reach for a token for: `inject(WrDialogRef, { optional: true })`\n * works for content that also renders outside a dialog, and\n * `inject<WrDialogRef<ConfirmComponent, boolean>>(WrDialogRef)` types the\n * generics without a cast.\n *\n * This token is the same object under a second key. It exists for the library's\n * own directives (`[wrDialogClose]`) and for swapping the provider out — a test\n * stub, say — without touching the class.\n *\n * @example\n * ```ts\n * @Component({...})\n * export class ConfirmComponent {\n * private readonly ref = inject<WrDialogRef<ConfirmComponent, boolean>>(WrDialogRef);\n *\n * confirm(): void {\n * this.ref.close(true);\n * }\n * }\n * ```\n */\nexport const WR_DIALOG_REF = new InjectionToken<WrDialogRef<unknown, unknown>>('WR_DIALOG_REF');\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 { Directionality } from '@angular/cdk/bidi';\nimport { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { ComponentPortal, type ComponentType } from '@angular/cdk/portal';\nimport { Location, isPlatformBrowser } from '@angular/common';\nimport { EnvironmentInjector, Service, Injector, PLATFORM_ID, afterEveryRender, inject } from '@angular/core';\n\nimport { WrI18n } from 'ngwr/i18n';\nimport {\n WR_OVERLAY,\n WR_RESPONSIVE_OVERLAYS,\n wrAppendOverlayClose,\n wrFollowDirection,\n wrPresentAsSheet,\n} from 'ngwr/overlay';\n\nimport { WrDialogRef } from './dialog-ref';\nimport type { WrDialogOptions } from './interfaces';\nimport { WR_DIALOG_DATA, WR_DIALOG_REF } from './tokens';\n\nconst DEFAULT_PANEL_CLASS = 'wr-dialog-panel';\nconst DEFAULT_BACKDROP_CLASS = 'wr-dialog-backdrop';\n\n/**\n * Opens dialog components in an isolated NGWR overlay.\n *\n * Uses `WR_OVERLAY` so it composes cleanly with `provideWrOverlay()`\n * — dialogs render into NGWR's own overlay container and never collide\n * with other CDK consumers (Material, NG-ZORRO, etc.).\n *\n * @example\n * ```ts\n * const dialog = inject(WrDialog);\n *\n * const ref = dialog.open(ConfirmComponent, {\n * data: { message: 'Delete this item?' },\n * width: '24rem',\n * });\n *\n * const ok = await ref.awaitClose();\n * if (ok) remove();\n * ```\n *\n * @see https://ngwr.dev/reference/components/dialog\n */\n@Service()\nexport class WrDialog {\n private readonly overlay = inject(WR_OVERLAY);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly parentInjector = inject(EnvironmentInjector);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly responsiveConfig = inject(WR_RESPONSIVE_OVERLAYS);\n private readonly i18n = inject(WrI18n, { optional: true });\n private readonly dir = inject(Directionality, { optional: true });\n // Resolvable wherever the CDK's own `Overlay` is — it injects the same thing\n // to implement `disposeOnNavigation`.\n private readonly location = inject(Location);\n\n open<C, R = unknown, D = unknown>(component: ComponentType<C>, options: WrDialogOptions<D> = {}): WrDialogRef<C, R> {\n const panelClasses: string[] = [DEFAULT_PANEL_CLASS];\n const extra = options.panelClass;\n if (typeof extra === 'string') {\n panelClasses.push(extra);\n } else if (extra) {\n for (const cls of extra) panelClasses.push(cls);\n }\n\n // On small viewports (when opted in) present as a slide-up sheet pinned\n // to the bottom edge, full-width, instead of a centred modal.\n const asSheet = wrPresentAsSheet(options.responsive, this.responsiveConfig);\n if (asSheet) panelClasses.push('wr-overlay-sheet');\n\n const position = this.overlay.position().global().centerHorizontally();\n const overlayRef: OverlayRef = this.overlay.create({\n positionStrategy: asSheet ? position.bottom('0') : position.centerVertically(),\n scrollStrategy: this.scrollStrategies.block(),\n hasBackdrop: true,\n backdropClass: DEFAULT_BACKDROP_CLASS,\n panelClass: panelClasses,\n width: asSheet ? '100%' : options.width,\n maxWidth: asSheet ? '100%' : options.maxWidth,\n });\n\n // The CDK captures the direction as a string at create and never looks\n // again, so an app that flips while a dialog is up leaves the panel behind.\n // Nothing here derives from it — the box is centred and its x offset is\n // empty, so `apply()`'s RTL branch moves nothing — but the `dir` attribute\n // is what the dialog's own logical CSS and every ngwr control inside it\n // resolve `start` and `end` against, so it has to follow. No teardown kept:\n // the follower ends on the ref's own `detachments()`, which every dismissal\n // path goes through, and each `open()` creates a fresh ref of its own.\n wrFollowDirection(overlayRef, this.dir, this.parentInjector);\n\n const dialogRef = new WrDialogRef<C, R>(overlayRef);\n\n if (this.isBrowser) {\n const active = document.activeElement;\n dialogRef.previouslyFocused = active instanceof HTMLElement ? active : null;\n }\n\n const injector = Injector.create({\n parent: this.parentInjector,\n providers: [\n { provide: WR_DIALOG_DATA, useValue: options.data },\n { provide: WR_DIALOG_REF, useValue: dialogRef },\n // Provided as its own token as well, so dialog content can reach for\n // the familiar `inject(WrDialogRef)` and close itself.\n { provide: WrDialogRef, useValue: dialogRef },\n ],\n });\n\n const portal = new ComponentPortal(component, null, injector);\n dialogRef.componentRef = overlayRef.attach(portal);\n\n // Wired BEFORE the panel is decorated, and the order is the fix: everything\n // below attaches attributes, a ✕ and a focus trap to an overlay that is\n // already on screen, so anything that throws in there used to leave an\n // `aria-modal` panel with no dismissal path at all — no ✕, no backdrop\n // handler, no Escape — over the whole application, and no ref for the caller\n // to close it with. A dialog that fails to finish opening must still be one\n // the user can get rid of. Overlay subscriptions complete when the overlay is\n // disposed, so no explicit teardown is required.\n if (options.closeOnBackdropClick !== false) {\n overlayRef.backdropClick().subscribe(() => dialogRef.close());\n }\n if (options.closeOnEscape !== false) {\n overlayRef.keydownEvents().subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n dialogRef.close();\n }\n });\n }\n if (options.closeOnNavigation !== false) {\n this.watchNavigation(overlayRef, dialogRef);\n }\n\n if (this.isBrowser) {\n const host = overlayRef.overlayElement;\n host.setAttribute('role', 'dialog');\n host.setAttribute('aria-modal', 'true');\n // Built-in dismiss. Appended after the content portal so it paints above\n // it, and marked on the panel so the title reserves the corner gutter.\n if (options.closable !== false) {\n host.classList.add('wr-dialog-panel--closable');\n const label = options.closeLabel ?? this.closeLabel();\n wrAppendOverlayClose(host, 'wr-dialog__close', label, () => dialogRef.close());\n }\n // Wire aria-labelledby to wrDialogTitle's auto-id once content is in DOM.\n // Has to wait for a render, not a microtask: attaching the portal only\n // schedules change detection, so under zoneless CD a microtask runs while\n // the content is still an empty view and the title id doesn't exist yet.\n //\n // And after EVERY render, not just the next one: the title belongs to the\n // caller's component, so an `@if` or a late-arriving heading can replace\n // or remove the element the attribute names. A reference to a node that is\n // no longer there is not a name — the dialog announces as unnamed — so a\n // missing title clears the attribute rather than leaving it dangling.\n const labelSync = afterEveryRender(\n () => {\n const titleEl = host.querySelector<HTMLElement>('[wrDialogTitle], [wr-dialog-title]');\n if (titleEl?.id) host.setAttribute('aria-labelledby', titleEl.id);\n else host.removeAttribute('aria-labelledby');\n },\n { injector: this.parentInjector }\n );\n // The hook is bound to the root injector, so it outlives the dialog unless\n // it is torn down with it. `detachments()` fires on dispose, which is the\n // one path every dismissal goes through.\n overlayRef.detachments().subscribe(() => labelSync.destroy());\n // Trap focus inside the dialog and move initial focus in.\n const trap = this.focusTrapFactory.create(host);\n dialogRef.focusTrap = trap;\n void trap.focusInitialElementWhenReady();\n }\n\n return dialogRef;\n }\n\n /**\n * Tie the dialog's lifetime to the URL it was opened on.\n *\n * Nothing else does. The overlay belongs to a root service and is dismissed\n * only by the backdrop, Escape or an explicit `close()`, so pressing Back\n * swapped the routed view underneath and left the modal pane, its backdrop and\n * its focus trap sitting over a page the user never opened them on.\n *\n * `onUrlChange`, not `Location.subscribe()` — which is what CDK's own\n * `disposeOnNavigation` uses: `subscribe` fires on popstate alone, so an\n * in-app `router.navigate()` left the dialog standing. And `dialogRef.close()`\n * rather than disposing the overlay behind the ref's back, which would never\n * emit `closed`, never destroy the focus trap, and leave `awaitClose()`\n * pending forever.\n */\n private watchNavigation<C, R>(overlayRef: OverlayRef, dialogRef: WrDialogRef<C, R>): void {\n const stopWatching = this.location.onUrlChange(() => dialogRef.close());\n // Unhooked a microtask late, because `Location` notifies its listeners with\n // a `forEach` and unregistering splices the array it is iterating: removing\n // ours synchronously from inside the notification would shift the next entry\n // into the slot forEach has already passed, and a SECOND stacked dialog\n // would be skipped and left behind.\n overlayRef.detachments().subscribe(() => queueMicrotask(stopWatching));\n }\n\n /**\n * The dismiss button's accessible name.\n *\n * Two failure modes, and resolving PER OPEN is what covers both. `t()` hands\n * back the KEY on a miss, and `WrI18n` is root-provided with an empty catalog\n * by default, so an app that never configured i18n named its dismiss button\n * \"dialog.close\" — a name axe cannot fault, because a name is present, and a\n * screen reader reads out verbatim. Resolving once at injection time fixed\n * that but froze the answer: this is a root service, constructed before an\n * async catalog has loaded, so a localized app got the English fallback on\n * every dialog it ever opened.\n */\n private closeLabel(): string {\n const resolved = this.i18n?.t('dialog.close');\n return !resolved || resolved === 'dialog.close' ? 'Close dialog' : resolved;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, ElementRef, inject } from '@angular/core';\n\nlet uid = 0;\n\n/**\n * Styles a dialog title row. Use on a heading inside an opened dialog.\n * Auto-assigns an `id` so the dialog panel can reference it via\n * `aria-labelledby`.\n *\n * @example\n * ```html\n * <h2 wrDialogTitle>Confirm delete</h2>\n * ```\n */\n@Directive({\n selector: '[wrDialogTitle]',\n host: { class: 'wr-dialog__title', '[attr.id]': 'id' },\n})\nexport class WrDialogTitle {\n /** Generated id used for `aria-labelledby` wiring. */\n readonly id = `wr-dialog-title-${++uid}`;\n\n /** @internal */\n readonly elementRef = inject(ElementRef<HTMLElement>);\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 { CdkScrollable } from '@angular/cdk/scrolling';\nimport { Directive } from '@angular/core';\n\n/**\n * Styles the scrollable body section of a dialog.\n *\n * `CdkScrollable` is a host directive because this element is a real scroll\n * container (`overflow: auto`) and an anchored overlay opened from inside it has\n * to follow its trigger. CDK's `reposition()` strategy listens to\n * `ScrollDispatcher`, which is fed by registered scrollables plus ONE\n * non-capturing `document` listener — and element `scroll` does not bubble, so\n * without the registration a `<wr-select>` halfway down a long dialog form kept\n * its panel pinned to the viewport while the trigger scrolled away. Angular\n * Material carries the same host directive on `MatDialogContent` for the same\n * reason.\n *\n * @example\n * ```html\n * <div wrDialogContent>…body…</div>\n * ```\n */\n@Directive({\n selector: '[wrDialogContent]',\n host: { class: 'wr-dialog__content' },\n hostDirectives: [CdkScrollable],\n})\nexport class WrDialogContent {}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, computed, input } from '@angular/core';\n\n/**\n * Footer row, typically holding action buttons.\n *\n * @example\n * ```html\n * <div wrDialogFooter align=\"end\">\n * <wr-btn wrDialogClose>Cancel</wr-btn>\n * <wr-btn color=\"danger\" (click)=\"confirm()\">Delete</wr-btn>\n * </div>\n * ```\n */\n@Directive({\n selector: '[wrDialogFooter]',\n host: { '[class]': 'classes()' },\n})\nexport class WrDialogFooter {\n /**\n * Horizontal alignment of the children.\n *\n * @default 'end'\n */\n readonly align = input<'start' | 'center' | 'end'>('end');\n\n protected readonly classes = computed(() => `wr-dialog__footer wr-dialog__footer--${this.align()}`);\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, inject, input } from '@angular/core';\n\nimport type { WrDialogRef } from '../dialog-ref';\nimport { WR_DIALOG_REF } from '../tokens';\n\n/**\n * Closes the dialog when the host element is clicked.\n *\n * Optionally passes a `[wrDialogClose]` value as the close result.\n *\n * @example\n * ```html\n * <wr-btn wrDialogClose>Cancel</wr-btn>\n * <wr-btn color=\"primary\" [wrDialogClose]=\"true\">Confirm</wr-btn>\n * ```\n */\n@Directive({\n selector: '[wrDialogClose]',\n host: { '(click)': 'onClick()' },\n})\nexport class WrDialogClose<R = unknown> {\n /**\n * Value to pass to `close()`. When unset — or used as a bare attribute — the\n * dialog closes with `undefined`.\n */\n readonly result = input<R | undefined, R | undefined | ''>(undefined, {\n alias: 'wrDialogClose',\n // A bare `wrDialogClose` attribute arrives as the empty string; that means\n // \"no result\", not a result of `''`. Matches `wrDrawerClose`.\n transform: value => (value === '' ? undefined : value),\n });\n\n private readonly ref = inject<WrDialogRef<unknown, R>>(WR_DIALOG_REF, { optional: true });\n\n protected onClick(): void {\n this.ref?.close(this.result());\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;;;AAKG;AAQH;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;MACU,WAAW,CAAA;AAoBO,IAAA,WAAA;AAnB7B;;;;;;;AAOG;AACM,IAAA,MAAM,GAAG,IAAI,aAAa,CAAgB,CAAC,CAAC;;IAGrD,YAAY,GAA2B,IAAI;;IAG3C,SAAS,GAAiC,IAAI;;IAG9C,iBAAiB,GAAuB,IAAI;AAE5C,IAAA,WAAA,CAA6B,WAAuB,EAAA;QAAvB,IAAA,CAAA,WAAW,GAAX,WAAW;IAAe;;AAGvD,IAAA,IAAI,iBAAiB,GAAA;AACnB,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;AACtB,YAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;QAC5D;AACA,QAAA,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ;IACnC;IAEQ,QAAQ,GAAG,KAAK;;AAGxB,IAAA,KAAK,CAAC,MAAU,EAAA;QACd,IAAI,IAAI,CAAC,QAAQ;YAAE;AACnB,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACpB,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;AACxB,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KAAK,KAAK,EAAE,GAAG,SAAS,GAAG,KAAK,CAAC,GACtD;IAEe,GAAG,GAAG,MAAM,CAA0B,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAE/E,OAAO,GAAA;QACf,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IAChC;uGAhBW,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAb,aAAa,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,EAAA,MAAA,EAAA,EAAA,iBAAA,EAAA,QAAA,EAAA,UAAA,EAAA,eAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,WAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBAJzB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,iBAAiB;AAC3B,oBAAA,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE;AACjC,iBAAA;;;AC1BD;;AAEG;;;;"}
|
|
@@ -254,11 +254,11 @@ class WrSortableList {
|
|
|
254
254
|
return { index: index + 1, total: this.items().length };
|
|
255
255
|
}
|
|
256
256
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: WrSortableList, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
257
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.6", type: WrSortableList, isStandalone: true, selector: "wr-sortable-list", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, lockAxis: { classPropertyName: "lockAxis", publicName: "lockAxis", isSignal: true, isRequired: false, transformFunction: null }, dragStartDelay: { classPropertyName: "dragStartDelay", publicName: "dragStartDelay", isSignal: true, isRequired: false, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { items: "itemsChange", reorder: "reorder" }, host: { classAttribute: "wr-sortable-list" }, queries: [{ propertyName: "rowTemplate", first: true, predicate: (TemplateRef), descendants: true, isSignal: true }], viewQueries: [{ propertyName: "rowEls", predicate: ["row"], descendants: true, isSignal: true }], ngImport: i0, template: "<!--\n `role=\"list\"` / `role=\"listitem\"` rather than the bare divs this used to be:\n every row is a tab stop now, and a focusable element with no role at all is\n announced as loose text. The list role is also what gives the reader the\n position of the row focus lands on.\n-->\n<div\n cdkDropList\n role=\"list\"\n class=\"wr-sortable-list__list\"\n [cdkDropListOrientation]=\"orientation()\"\n [cdkDropListDisabled]=\"disabled()\"\n (cdkDropListDropped)=\"onDrop($event)\"\n>\n @for (item of items(); track trackBy()($index, item)) {\n <div\n #row\n cdkDrag\n role=\"listitem\"\n class=\"wr-sortable-list__item\"\n [class.wr-sortable-list__item--grabbed]=\"grabbedIndex() === $index\"\n [attr.tabindex]=\"disabled() ? null : 0\"\n [attr.aria-describedby]=\"disabled() ? null : keyHelpId\"\n [cdkDragDisabled]=\"disabled()\"\n [cdkDragLockAxis]=\"lockAxis() ?? null\"\n [cdkDragStartDelay]=\"dragStartDelay()\"\n (keydown)=\"onRowKeydown($event, $index)\"\n (focusout)=\"onRowFocusout()\"\n >\n <ng-container *ngTemplateOutlet=\"rowTemplate(); context: { $implicit: item, index: $index }\" />\n </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 \u2014 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", styles: [".wr-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-table__sort-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-tabs__tab:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-sidebar__entry:focus-visible,.wr-sidebar__group-toggle:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sidebar__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-anchor__link:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-collapse__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-command-palette__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-mention-panel__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-segmented__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-back-top:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-carousel__nav:focus-visible,.wr-carousel__dot:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-speed-dial__trigger:focus-visible,.wr-speed-dial__action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-stepper__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-window__chrome-action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-date-picker__trigger:focus-visible,.wr-time-picker__step:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-dropdown-item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-alert__close:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sortable-list{display:block}.wr-sortable-list__list{display:flex;flex-direction:column;gap:var(--wr-sortable-list-gap, .5rem)}.wr-sortable-list__item{cursor:grab;-webkit-user-select:none;user-select:none;transition:box-shadow .18s ease}.wr-sortable-list__item.cdk-drag-disabled{cursor:default}.wr-sortable-list__item:active{cursor:grabbing}.wr-sortable-list__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sortable-list__item--grabbed{cursor:grabbing;box-shadow:0 6px 12px rgba(var(--wr-color-backdrop-rgb),.22)}.wr-sortable-list__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.wr-sortable-list[orientation=horizontal] .wr-sortable-list__list,.wr-sortable-list[data-orientation=horizontal] .wr-sortable-list__list{flex-direction:row}.wr-drag-handle{cursor:grab;display:inline-flex;align-items:center;justify-content:center;color:rgba(var(--wr-color-on-surface-rgb),.45);transition:color .15s ease}@media(pointer:coarse){.wr-drag-handle{position:relative}.wr-drag-handle:after{content:\"\";position:absolute;top:50%;left:50%;width:100%;height:100%;min-width:44px;min-height:44px;transform:translate(-50%,-50%)}}.wr-drag-handle:hover{color:var(--wr-color-on-surface)}.wr-drag-handle:active{cursor:grabbing}.cdk-drag-preview.wr-sortable-list__item{box-sizing:border-box;color:var(--wr-color-on-surface);font-family:var(--wr-font-family-base);transition:none;filter:drop-shadow(0 8px 12px rgba(var(--wr-color-backdrop-rgb),.24)) drop-shadow(0 2px 3px rgba(var(--wr-color-backdrop-rgb),.16))}.wr-sortable-list .cdk-drag-placeholder{opacity:.35;background:var(--wr-color-fill-strong);border-radius:var(--wr-border-radius-base);outline:1px dashed rgba(var(--wr-color-on-surface-rgb),.25);outline-offset:-1px}.cdk-drag-animating.wr-sortable-list__item{transition:transform .18s var(--wr-ease-spring)}.wr-sortable-list__list.cdk-drop-list-dragging .wr-sortable-list__item:not(.cdk-drag-placeholder){transition:transform .18s var(--wr-ease-spring)}\n"], dependencies: [{ kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], encapsulation: i0.ViewEncapsulation.None });
|
|
257
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.6", type: WrSortableList, isStandalone: true, selector: "wr-sortable-list", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, lockAxis: { classPropertyName: "lockAxis", publicName: "lockAxis", isSignal: true, isRequired: false, transformFunction: null }, dragStartDelay: { classPropertyName: "dragStartDelay", publicName: "dragStartDelay", isSignal: true, isRequired: false, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { items: "itemsChange", reorder: "reorder" }, host: { classAttribute: "wr-sortable-list" }, queries: [{ propertyName: "rowTemplate", first: true, predicate: (TemplateRef), descendants: true, isSignal: true }], viewQueries: [{ propertyName: "rowEls", predicate: ["row"], descendants: true, isSignal: true }], ngImport: i0, template: "<!--\n `role=\"list\"` / `role=\"listitem\"` rather than the bare divs this used to be:\n every row is a tab stop now, and a focusable element with no role at all is\n announced as loose text. The list role is also what gives the reader the\n position of the row focus lands on.\n-->\n<div\n cdkDropList\n role=\"list\"\n class=\"wr-sortable-list__list\"\n [cdkDropListOrientation]=\"orientation()\"\n [cdkDropListDisabled]=\"disabled()\"\n (cdkDropListDropped)=\"onDrop($event)\"\n>\n @for (item of items(); track trackBy()($index, item)) {\n <div\n #row\n cdkDrag\n role=\"listitem\"\n class=\"wr-sortable-list__item\"\n [class.wr-sortable-list__item--grabbed]=\"grabbedIndex() === $index\"\n [attr.tabindex]=\"disabled() ? null : 0\"\n [attr.aria-describedby]=\"disabled() ? null : keyHelpId\"\n [cdkDragDisabled]=\"disabled()\"\n [cdkDragLockAxis]=\"lockAxis() ?? null\"\n [cdkDragStartDelay]=\"dragStartDelay()\"\n (keydown)=\"onRowKeydown($event, $index)\"\n (focusout)=\"onRowFocusout()\"\n >\n <ng-container *ngTemplateOutlet=\"rowTemplate(); context: { $implicit: item, index: $index }\" />\n </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 \u2014 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", styles: [".wr-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-table__sort-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-tabs__tab:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-sidebar__entry:focus-visible,.wr-sidebar__group-toggle:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sidebar__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-anchor__link:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-collapse__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-command-palette__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-mention-panel__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-segmented__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-back-top:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-carousel__nav:focus-visible,.wr-carousel__dot:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-speed-dial__trigger:focus-visible,.wr-speed-dial__action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-stepper__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-window__chrome-action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-date-picker__trigger:focus-visible,.wr-time-picker__step:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-dropdown-item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-alert__close:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-graph__viewport:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sortable-list{display:block}.wr-sortable-list__list{display:flex;flex-direction:column;gap:var(--wr-sortable-list-gap, .5rem)}.wr-sortable-list__item{cursor:grab;-webkit-user-select:none;user-select:none;transition:box-shadow .18s ease}.wr-sortable-list__item.cdk-drag-disabled{cursor:default}.wr-sortable-list__item:active{cursor:grabbing}.wr-sortable-list__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sortable-list__item--grabbed{cursor:grabbing;box-shadow:0 6px 12px rgba(var(--wr-color-backdrop-rgb),.22)}.wr-sortable-list__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.wr-sortable-list[orientation=horizontal] .wr-sortable-list__list,.wr-sortable-list[data-orientation=horizontal] .wr-sortable-list__list{flex-direction:row}.wr-drag-handle{cursor:grab;display:inline-flex;align-items:center;justify-content:center;color:rgba(var(--wr-color-on-surface-rgb),.45);transition:color .15s ease}@media(pointer:coarse){.wr-drag-handle{position:relative}.wr-drag-handle:after{content:\"\";position:absolute;top:50%;left:50%;width:100%;height:100%;min-width:44px;min-height:44px;transform:translate(-50%,-50%)}}.wr-drag-handle:hover{color:var(--wr-color-on-surface)}.wr-drag-handle:active{cursor:grabbing}.cdk-drag-preview.wr-sortable-list__item{box-sizing:border-box;color:var(--wr-color-on-surface);font-family:var(--wr-font-family-base);transition:none;filter:drop-shadow(0 8px 12px rgba(var(--wr-color-backdrop-rgb),.24)) drop-shadow(0 2px 3px rgba(var(--wr-color-backdrop-rgb),.16))}.wr-sortable-list .cdk-drag-placeholder{opacity:.35;background:var(--wr-color-fill-strong);border-radius:var(--wr-border-radius-base);outline:1px dashed rgba(var(--wr-color-on-surface-rgb),.25);outline-offset:-1px}.cdk-drag-animating.wr-sortable-list__item{transition:transform .18s var(--wr-ease-spring)}.wr-sortable-list__list.cdk-drop-list-dragging .wr-sortable-list__item:not(.cdk-drag-placeholder){transition:transform .18s var(--wr-ease-spring)}\n"], dependencies: [{ kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], encapsulation: i0.ViewEncapsulation.None });
|
|
258
258
|
}
|
|
259
259
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: WrSortableList, decorators: [{
|
|
260
260
|
type: Component,
|
|
261
|
-
args: [{ selector: 'wr-sortable-list', encapsulation: ViewEncapsulation.None, imports: [CdkDropList, CdkDrag, NgTemplateOutlet], host: { class: 'wr-sortable-list' }, template: "<!--\n `role=\"list\"` / `role=\"listitem\"` rather than the bare divs this used to be:\n every row is a tab stop now, and a focusable element with no role at all is\n announced as loose text. The list role is also what gives the reader the\n position of the row focus lands on.\n-->\n<div\n cdkDropList\n role=\"list\"\n class=\"wr-sortable-list__list\"\n [cdkDropListOrientation]=\"orientation()\"\n [cdkDropListDisabled]=\"disabled()\"\n (cdkDropListDropped)=\"onDrop($event)\"\n>\n @for (item of items(); track trackBy()($index, item)) {\n <div\n #row\n cdkDrag\n role=\"listitem\"\n class=\"wr-sortable-list__item\"\n [class.wr-sortable-list__item--grabbed]=\"grabbedIndex() === $index\"\n [attr.tabindex]=\"disabled() ? null : 0\"\n [attr.aria-describedby]=\"disabled() ? null : keyHelpId\"\n [cdkDragDisabled]=\"disabled()\"\n [cdkDragLockAxis]=\"lockAxis() ?? null\"\n [cdkDragStartDelay]=\"dragStartDelay()\"\n (keydown)=\"onRowKeydown($event, $index)\"\n (focusout)=\"onRowFocusout()\"\n >\n <ng-container *ngTemplateOutlet=\"rowTemplate(); context: { $implicit: item, index: $index }\" />\n </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 \u2014 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", styles: [".wr-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-table__sort-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-tabs__tab:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-sidebar__entry:focus-visible,.wr-sidebar__group-toggle:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sidebar__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-anchor__link:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-collapse__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-command-palette__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-mention-panel__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-segmented__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-back-top:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-carousel__nav:focus-visible,.wr-carousel__dot:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-speed-dial__trigger:focus-visible,.wr-speed-dial__action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-stepper__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-window__chrome-action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-date-picker__trigger:focus-visible,.wr-time-picker__step:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-dropdown-item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-alert__close:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sortable-list{display:block}.wr-sortable-list__list{display:flex;flex-direction:column;gap:var(--wr-sortable-list-gap, .5rem)}.wr-sortable-list__item{cursor:grab;-webkit-user-select:none;user-select:none;transition:box-shadow .18s ease}.wr-sortable-list__item.cdk-drag-disabled{cursor:default}.wr-sortable-list__item:active{cursor:grabbing}.wr-sortable-list__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sortable-list__item--grabbed{cursor:grabbing;box-shadow:0 6px 12px rgba(var(--wr-color-backdrop-rgb),.22)}.wr-sortable-list__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.wr-sortable-list[orientation=horizontal] .wr-sortable-list__list,.wr-sortable-list[data-orientation=horizontal] .wr-sortable-list__list{flex-direction:row}.wr-drag-handle{cursor:grab;display:inline-flex;align-items:center;justify-content:center;color:rgba(var(--wr-color-on-surface-rgb),.45);transition:color .15s ease}@media(pointer:coarse){.wr-drag-handle{position:relative}.wr-drag-handle:after{content:\"\";position:absolute;top:50%;left:50%;width:100%;height:100%;min-width:44px;min-height:44px;transform:translate(-50%,-50%)}}.wr-drag-handle:hover{color:var(--wr-color-on-surface)}.wr-drag-handle:active{cursor:grabbing}.cdk-drag-preview.wr-sortable-list__item{box-sizing:border-box;color:var(--wr-color-on-surface);font-family:var(--wr-font-family-base);transition:none;filter:drop-shadow(0 8px 12px rgba(var(--wr-color-backdrop-rgb),.24)) drop-shadow(0 2px 3px rgba(var(--wr-color-backdrop-rgb),.16))}.wr-sortable-list .cdk-drag-placeholder{opacity:.35;background:var(--wr-color-fill-strong);border-radius:var(--wr-border-radius-base);outline:1px dashed rgba(var(--wr-color-on-surface-rgb),.25);outline-offset:-1px}.cdk-drag-animating.wr-sortable-list__item{transition:transform .18s var(--wr-ease-spring)}.wr-sortable-list__list.cdk-drop-list-dragging .wr-sortable-list__item:not(.cdk-drag-placeholder){transition:transform .18s var(--wr-ease-spring)}\n"] }]
|
|
261
|
+
args: [{ selector: 'wr-sortable-list', encapsulation: ViewEncapsulation.None, imports: [CdkDropList, CdkDrag, NgTemplateOutlet], host: { class: 'wr-sortable-list' }, template: "<!--\n `role=\"list\"` / `role=\"listitem\"` rather than the bare divs this used to be:\n every row is a tab stop now, and a focusable element with no role at all is\n announced as loose text. The list role is also what gives the reader the\n position of the row focus lands on.\n-->\n<div\n cdkDropList\n role=\"list\"\n class=\"wr-sortable-list__list\"\n [cdkDropListOrientation]=\"orientation()\"\n [cdkDropListDisabled]=\"disabled()\"\n (cdkDropListDropped)=\"onDrop($event)\"\n>\n @for (item of items(); track trackBy()($index, item)) {\n <div\n #row\n cdkDrag\n role=\"listitem\"\n class=\"wr-sortable-list__item\"\n [class.wr-sortable-list__item--grabbed]=\"grabbedIndex() === $index\"\n [attr.tabindex]=\"disabled() ? null : 0\"\n [attr.aria-describedby]=\"disabled() ? null : keyHelpId\"\n [cdkDragDisabled]=\"disabled()\"\n [cdkDragLockAxis]=\"lockAxis() ?? null\"\n [cdkDragStartDelay]=\"dragStartDelay()\"\n (keydown)=\"onRowKeydown($event, $index)\"\n (focusout)=\"onRowFocusout()\"\n >\n <ng-container *ngTemplateOutlet=\"rowTemplate(); context: { $implicit: item, index: $index }\" />\n </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 \u2014 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", styles: [".wr-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-table__sort-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-tabs__tab:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-sidebar__entry:focus-visible,.wr-sidebar__group-toggle:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sidebar__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-anchor__link:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-collapse__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-command-palette__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-mention-panel__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-segmented__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-back-top:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-carousel__nav:focus-visible,.wr-carousel__dot:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-speed-dial__trigger:focus-visible,.wr-speed-dial__action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-stepper__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-window__chrome-action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-date-picker__trigger:focus-visible,.wr-time-picker__step:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-dropdown-item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-alert__close:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-graph__viewport:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sortable-list{display:block}.wr-sortable-list__list{display:flex;flex-direction:column;gap:var(--wr-sortable-list-gap, .5rem)}.wr-sortable-list__item{cursor:grab;-webkit-user-select:none;user-select:none;transition:box-shadow .18s ease}.wr-sortable-list__item.cdk-drag-disabled{cursor:default}.wr-sortable-list__item:active{cursor:grabbing}.wr-sortable-list__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sortable-list__item--grabbed{cursor:grabbing;box-shadow:0 6px 12px rgba(var(--wr-color-backdrop-rgb),.22)}.wr-sortable-list__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.wr-sortable-list[orientation=horizontal] .wr-sortable-list__list,.wr-sortable-list[data-orientation=horizontal] .wr-sortable-list__list{flex-direction:row}.wr-drag-handle{cursor:grab;display:inline-flex;align-items:center;justify-content:center;color:rgba(var(--wr-color-on-surface-rgb),.45);transition:color .15s ease}@media(pointer:coarse){.wr-drag-handle{position:relative}.wr-drag-handle:after{content:\"\";position:absolute;top:50%;left:50%;width:100%;height:100%;min-width:44px;min-height:44px;transform:translate(-50%,-50%)}}.wr-drag-handle:hover{color:var(--wr-color-on-surface)}.wr-drag-handle:active{cursor:grabbing}.cdk-drag-preview.wr-sortable-list__item{box-sizing:border-box;color:var(--wr-color-on-surface);font-family:var(--wr-font-family-base);transition:none;filter:drop-shadow(0 8px 12px rgba(var(--wr-color-backdrop-rgb),.24)) drop-shadow(0 2px 3px rgba(var(--wr-color-backdrop-rgb),.16))}.wr-sortable-list .cdk-drag-placeholder{opacity:.35;background:var(--wr-color-fill-strong);border-radius:var(--wr-border-radius-base);outline:1px dashed rgba(var(--wr-color-on-surface-rgb),.25);outline-offset:-1px}.cdk-drag-animating.wr-sortable-list__item{transition:transform .18s var(--wr-ease-spring)}.wr-sortable-list__list.cdk-drop-list-dragging .wr-sortable-list__item:not(.cdk-drag-placeholder){transition:transform .18s var(--wr-ease-spring)}\n"] }]
|
|
262
262
|
}], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: true }] }, { type: i0.Output, args: ["itemsChange"] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], lockAxis: [{ type: i0.Input, args: [{ isSignal: true, alias: "lockAxis", required: false }] }], dragStartDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragStartDelay", required: false }] }], trackBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackBy", required: false }] }], reorder: [{ type: i0.Output, args: ["reorder"] }], rowTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }], rowEls: [{ type: i0.ViewChildren, args: ['row', { isSignal: true }] }] } });
|
|
263
263
|
|
|
264
264
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-drag-drop.mjs","sources":["../../../projects/lib/drag-drop/sortable-list.ts","../../../projects/lib/drag-drop/sortable-list.html","../../../projects/lib/drag-drop/drag-handle.ts","../../../projects/lib/drag-drop/ngwr-drag-drop.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 { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { CdkDrag, type CdkDragDrop, CdkDropList, moveItemInArray } from '@angular/cdk/drag-drop';\nimport { NgTemplateOutlet } from '@angular/common';\nimport type { ElementRef } from '@angular/core';\nimport {\n Component,\n Injector,\n TemplateRef,\n ViewEncapsulation,\n afterNextRender,\n contentChild,\n inject,\n input,\n model,\n output,\n signal,\n viewChildren,\n} from '@angular/core';\n\nimport { readI18nText, useI18nFormatter } from 'ngwr/i18n';\n\nimport type { WrSortableReorderEvent } from './interfaces';\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 * Drop a single template — it's rendered per item with `let-item\n * let-index=\"index\"`. Put `wrDragHandle` on an element inside that\n * template to restrict drag start to a handle; there is no input for\n * 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 * @example\n * ```html\n * <wr-sortable-list [(items)]=\"rows\" (reorder)=\"onReorder($event)\">\n * <ng-template let-row let-i=\"index\">\n * <div class=\"row\">\n * <span wrDragHandle>≡</span>\n * {{ i + 1 }}. {{ row.label }}\n * </div>\n * </ng-template>\n * </wr-sortable-list>\n * ```\n *\n * @see https://ngwr.dev/reference/components/drag-drop\n */\n@Component({\n selector: 'wr-sortable-list',\n templateUrl: './sortable-list.html',\n styleUrl: './sortable-list.scss',\n encapsulation: ViewEncapsulation.None,\n imports: [CdkDropList, CdkDrag, NgTemplateOutlet],\n host: { class: 'wr-sortable-list' },\n})\nexport class WrSortableList<T = unknown> {\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 /** `trackBy` for the inner `@for`. Defaults to identity. */\n readonly trackBy = input<(index: number, item: T) => unknown>((_, item) => item);\n\n /** Fired after a successful reorder with the new array + indices. */\n readonly reorder = output<WrSortableReorderEvent<T>>();\n\n protected readonly rowTemplate = contentChild.required(TemplateRef<{ $implicit: T; index: number }>);\n\n private readonly injector = inject(Injector);\n\n /**\n * Ambient reading direction, for the horizontal keyboard path only.\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 private readonly rowEls = viewChildren<ElementRef<HTMLElement>>('row');\n\n /** Index of the row the keyboard is holding, or `null` when nothing is held. */\n protected readonly grabbedIndex = signal<number | null>(null);\n\n /** Live-region text. Written by the keyboard path only. */\n protected readonly announcement = signal('');\n\n /** Links every row to the key model via `aria-describedby`. */\n protected readonly keyHelpId = `wr-sortable-list-help-${++sortableListUid}`;\n\n protected readonly resolvedKeyHelp = readI18nText(\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\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 = readI18nText('sortableList.cancelled', 'Move cancelled.');\n\n /** Where the held row started. Escape puts it back there. */\n private grabOrigin = -1;\n\n /** True while a keyboard move is handing focus back — see `onRowFocusout`. */\n private restoringFocus = false;\n\n protected onDrop(event: CdkDragDrop<T[]>): void {\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 protected 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 = horizontal && this.dir?.value === 'rtl';\n const forward = horizontal ? (rtl ? 'ArrowLeft' : 'ArrowRight') : 'ArrowDown';\n const back = horizontal ? (rtl ? 'ArrowRight' : 'ArrowLeft') : 'ArrowUp';\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 }\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 protected onRowFocusout(): void {\n if (this.restoringFocus || this.grabbedIndex() === null) return;\n this.drop();\n }\n\n private grab(index: number): void {\n this.grabOrigin = 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 private drop(): void {\n const to = this.grabbedIndex();\n const from = this.grabOrigin;\n this.grabbedIndex.set(null);\n this.grabOrigin = -1;\n if (to === null) return;\n\n this.announcement.set(this.droppedText(this.position(to)));\n if (from === 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: from, currentIndex: to, item: this.items()[to] });\n }\n\n private cancelGrab(): void {\n const from = this.grabbedIndex();\n if (from === null) return;\n if (from !== this.grabOrigin) this.relocate(from, this.grabOrigin);\n this.grabbedIndex.set(null);\n this.grabOrigin = -1;\n this.announcement.set(this.cancelledText());\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\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 this.rowEls()[to]?.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 { WrSortableReorderEvent } from './interfaces';\n","<!--\n `role=\"list\"` / `role=\"listitem\"` rather than the bare divs this used to be:\n every row is a tab stop now, and a focusable element with no role at all is\n announced as loose text. The list role is also what gives the reader the\n position of the row focus lands on.\n-->\n<div\n cdkDropList\n role=\"list\"\n class=\"wr-sortable-list__list\"\n [cdkDropListOrientation]=\"orientation()\"\n [cdkDropListDisabled]=\"disabled()\"\n (cdkDropListDropped)=\"onDrop($event)\"\n>\n @for (item of items(); track trackBy()($index, item)) {\n <div\n #row\n cdkDrag\n role=\"listitem\"\n class=\"wr-sortable-list__item\"\n [class.wr-sortable-list__item--grabbed]=\"grabbedIndex() === $index\"\n [attr.tabindex]=\"disabled() ? null : 0\"\n [attr.aria-describedby]=\"disabled() ? null : keyHelpId\"\n [cdkDragDisabled]=\"disabled()\"\n [cdkDragLockAxis]=\"lockAxis() ?? null\"\n [cdkDragStartDelay]=\"dragStartDelay()\"\n (keydown)=\"onRowKeydown($event, $index)\"\n (focusout)=\"onRowFocusout()\"\n >\n <ng-container *ngTemplateOutlet=\"rowTemplate(); context: { $implicit: item, index: $index }\" />\n </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 { CdkDragHandle } from '@angular/cdk/drag-drop';\nimport { Directive } from '@angular/core';\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 * <ng-template let-row>\n * <div class=\"row\">\n * <span wrDragHandle class=\"grip\">≡</span>\n * <span>{{ row.label }}</span>\n * </div>\n * </ng-template>\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;AAKG;AA0BH;AACA,IAAI,eAAe,GAAG,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCG;MASU,cAAc,CAAA;;IAEhB,KAAK,GAAG,KAAK,CAAC,QAAQ;8EAAO;;IAG7B,WAAW,GAAG,KAAK,CAA4B,UAAU;oFAAC;;IAG1D,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;;IAG7D,QAAQ,GAAG,KAAK,CAAwB,SAAS;iFAAC;AAE3D;;;;;;;AAOG;IACM,cAAc,GAAG,KAAK,CAA4C,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE;uFAAC;;IAG3F,OAAO,GAAG,KAAK,CAAsC,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI;gFAAC;;IAGvE,OAAO,GAAG,MAAM,EAA6B;AAEnC,IAAA,WAAW,GAAG,YAAY,CAAC,QAAQ,EAAC,WAA4C;oFAAC;AAEnF,IAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAE5C;;;;;;;;;;;;;AAaG;IACc,GAAG,GAAG,MAAM,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAEhD,MAAM,GAAG,YAAY,CAA0B,KAAK;+EAAC;;IAGnD,YAAY,GAAG,MAAM,CAAgB,IAAI;qFAAC;;IAG1C,YAAY,GAAG,MAAM,CAAC,EAAE;qFAAC;;AAGzB,IAAA,SAAS,GAAG,CAAA,sBAAA,EAAyB,EAAE,eAAe,EAAE;AAExD,IAAA,eAAe,GAAG,YAAY,CAC/C,sBAAsB,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BAAA;;;AC/BD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngwr-drag-drop.mjs","sources":["../../../projects/lib/drag-drop/sortable-list.ts","../../../projects/lib/drag-drop/sortable-list.html","../../../projects/lib/drag-drop/drag-handle.ts","../../../projects/lib/drag-drop/ngwr-drag-drop.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 { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { CdkDrag, type CdkDragDrop, CdkDropList, moveItemInArray } from '@angular/cdk/drag-drop';\nimport { NgTemplateOutlet } from '@angular/common';\nimport type { ElementRef } from '@angular/core';\nimport {\n Component,\n Injector,\n TemplateRef,\n ViewEncapsulation,\n afterNextRender,\n contentChild,\n inject,\n input,\n model,\n output,\n signal,\n viewChildren,\n} from '@angular/core';\n\nimport { readI18nText, useI18nFormatter } from 'ngwr/i18n';\n\nimport type { WrSortableReorderEvent } from './interfaces';\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 * Drop a single template — it's rendered per item with `let-item\n * let-index=\"index\"`. Put `wrDragHandle` on an element inside that\n * template to restrict drag start to a handle; there is no input for\n * 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 * @example\n * ```html\n * <wr-sortable-list [(items)]=\"rows\" (reorder)=\"onReorder($event)\">\n * <ng-template let-row let-i=\"index\">\n * <div class=\"row\">\n * <span wrDragHandle>≡</span>\n * {{ i + 1 }}. {{ row.label }}\n * </div>\n * </ng-template>\n * </wr-sortable-list>\n * ```\n *\n * @see https://ngwr.dev/reference/components/drag-drop\n */\n@Component({\n selector: 'wr-sortable-list',\n templateUrl: './sortable-list.html',\n styleUrl: './sortable-list.scss',\n encapsulation: ViewEncapsulation.None,\n imports: [CdkDropList, CdkDrag, NgTemplateOutlet],\n host: { class: 'wr-sortable-list' },\n})\nexport class WrSortableList<T = unknown> {\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 /** `trackBy` for the inner `@for`. Defaults to identity. */\n readonly trackBy = input<(index: number, item: T) => unknown>((_, item) => item);\n\n /** Fired after a successful reorder with the new array + indices. */\n readonly reorder = output<WrSortableReorderEvent<T>>();\n\n protected readonly rowTemplate = contentChild.required(TemplateRef<{ $implicit: T; index: number }>);\n\n private readonly injector = inject(Injector);\n\n /**\n * Ambient reading direction, for the horizontal keyboard path only.\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 private readonly rowEls = viewChildren<ElementRef<HTMLElement>>('row');\n\n /** Index of the row the keyboard is holding, or `null` when nothing is held. */\n protected readonly grabbedIndex = signal<number | null>(null);\n\n /** Live-region text. Written by the keyboard path only. */\n protected readonly announcement = signal('');\n\n /** Links every row to the key model via `aria-describedby`. */\n protected readonly keyHelpId = `wr-sortable-list-help-${++sortableListUid}`;\n\n protected readonly resolvedKeyHelp = readI18nText(\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\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 = readI18nText('sortableList.cancelled', 'Move cancelled.');\n\n /** Where the held row started. Escape puts it back there. */\n private grabOrigin = -1;\n\n /** True while a keyboard move is handing focus back — see `onRowFocusout`. */\n private restoringFocus = false;\n\n protected onDrop(event: CdkDragDrop<T[]>): void {\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 protected 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 = horizontal && this.dir?.value === 'rtl';\n const forward = horizontal ? (rtl ? 'ArrowLeft' : 'ArrowRight') : 'ArrowDown';\n const back = horizontal ? (rtl ? 'ArrowRight' : 'ArrowLeft') : 'ArrowUp';\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 }\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 protected onRowFocusout(): void {\n if (this.restoringFocus || this.grabbedIndex() === null) return;\n this.drop();\n }\n\n private grab(index: number): void {\n this.grabOrigin = 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 private drop(): void {\n const to = this.grabbedIndex();\n const from = this.grabOrigin;\n this.grabbedIndex.set(null);\n this.grabOrigin = -1;\n if (to === null) return;\n\n this.announcement.set(this.droppedText(this.position(to)));\n if (from === 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: from, currentIndex: to, item: this.items()[to] });\n }\n\n private cancelGrab(): void {\n const from = this.grabbedIndex();\n if (from === null) return;\n if (from !== this.grabOrigin) this.relocate(from, this.grabOrigin);\n this.grabbedIndex.set(null);\n this.grabOrigin = -1;\n this.announcement.set(this.cancelledText());\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\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 this.rowEls()[to]?.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 { WrSortableReorderEvent } from './interfaces';\n","<!--\n `role=\"list\"` / `role=\"listitem\"` rather than the bare divs this used to be:\n every row is a tab stop now, and a focusable element with no role at all is\n announced as loose text. The list role is also what gives the reader the\n position of the row focus lands on.\n-->\n<div\n cdkDropList\n role=\"list\"\n class=\"wr-sortable-list__list\"\n [cdkDropListOrientation]=\"orientation()\"\n [cdkDropListDisabled]=\"disabled()\"\n (cdkDropListDropped)=\"onDrop($event)\"\n>\n @for (item of items(); track trackBy()($index, item)) {\n <div\n #row\n cdkDrag\n role=\"listitem\"\n class=\"wr-sortable-list__item\"\n [class.wr-sortable-list__item--grabbed]=\"grabbedIndex() === $index\"\n [attr.tabindex]=\"disabled() ? null : 0\"\n [attr.aria-describedby]=\"disabled() ? null : keyHelpId\"\n [cdkDragDisabled]=\"disabled()\"\n [cdkDragLockAxis]=\"lockAxis() ?? null\"\n [cdkDragStartDelay]=\"dragStartDelay()\"\n (keydown)=\"onRowKeydown($event, $index)\"\n (focusout)=\"onRowFocusout()\"\n >\n <ng-container *ngTemplateOutlet=\"rowTemplate(); context: { $implicit: item, index: $index }\" />\n </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 { CdkDragHandle } from '@angular/cdk/drag-drop';\nimport { Directive } from '@angular/core';\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 * <ng-template let-row>\n * <div class=\"row\">\n * <span wrDragHandle class=\"grip\">≡</span>\n * <span>{{ row.label }}</span>\n * </div>\n * </ng-template>\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;AAKG;AA0BH;AACA,IAAI,eAAe,GAAG,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCG;MASU,cAAc,CAAA;;IAEhB,KAAK,GAAG,KAAK,CAAC,QAAQ;8EAAO;;IAG7B,WAAW,GAAG,KAAK,CAA4B,UAAU;oFAAC;;IAG1D,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;;IAG7D,QAAQ,GAAG,KAAK,CAAwB,SAAS;iFAAC;AAE3D;;;;;;;AAOG;IACM,cAAc,GAAG,KAAK,CAA4C,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE;uFAAC;;IAG3F,OAAO,GAAG,KAAK,CAAsC,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI;gFAAC;;IAGvE,OAAO,GAAG,MAAM,EAA6B;AAEnC,IAAA,WAAW,GAAG,YAAY,CAAC,QAAQ,EAAC,WAA4C;oFAAC;AAEnF,IAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAE5C;;;;;;;;;;;;;AAaG;IACc,GAAG,GAAG,MAAM,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAEhD,MAAM,GAAG,YAAY,CAA0B,KAAK;+EAAC;;IAGnD,YAAY,GAAG,MAAM,CAAgB,IAAI;qFAAC;;IAG1C,YAAY,GAAG,MAAM,CAAC,EAAE;qFAAC;;AAGzB,IAAA,SAAS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AAE,CAAC,aAAa,CAAC;AAC/B,oBAAA,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE;AAClC,iBAAA;;;AC/BD;;AAEG;;;;"}
|
package/fesm2022/ngwr-drawer.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';
|
|
2
|
+
import { Directionality } from '@angular/cdk/bidi';
|
|
2
3
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
3
4
|
import { TemplatePortal, ComponentPortal } from '@angular/cdk/portal';
|
|
4
5
|
import { isPlatformBrowser, Location } from '@angular/common';
|
|
5
6
|
import * as i0 from '@angular/core';
|
|
6
|
-
import { Directive, model, input, viewChild, TemplateRef, contentChild, inject, ViewContainerRef, DestroyRef, PLATFORM_ID, effect, afterEveryRender, ViewEncapsulation, Component, InjectionToken,
|
|
7
|
+
import { Directive, model, input, viewChild, TemplateRef, contentChild, inject, ViewContainerRef, DestroyRef, Injector, PLATFORM_ID, EnvironmentInjector, effect, afterEveryRender, ViewEncapsulation, Component, InjectionToken, Service, computed } from '@angular/core';
|
|
7
8
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
8
9
|
import { useI18nText, WrI18n } from 'ngwr/i18n';
|
|
9
|
-
import { WR_OVERLAY, wrAppendOverlayClose } from 'ngwr/overlay';
|
|
10
|
+
import { WR_OVERLAY, wrFollowDirection, wrAppendOverlayClose } from 'ngwr/overlay';
|
|
10
11
|
import { ScrollStrategyOptions } from '@angular/cdk/overlay';
|
|
11
12
|
import { ReplaySubject } from 'rxjs';
|
|
12
13
|
|
|
@@ -238,8 +239,28 @@ class WrDrawer {
|
|
|
238
239
|
overlay = inject(WR_OVERLAY);
|
|
239
240
|
vcr = inject(ViewContainerRef);
|
|
240
241
|
destroyRef = inject(DestroyRef);
|
|
242
|
+
injector = inject(Injector);
|
|
241
243
|
focusTrapFactory = inject(ConfigurableFocusTrapFactory);
|
|
242
244
|
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
245
|
+
/**
|
|
246
|
+
* The reading direction the open drawer has to keep up with, resolved off the
|
|
247
|
+
* ENVIRONMENT injector rather than this component's.
|
|
248
|
+
*
|
|
249
|
+
* That is where the CDK read it: `createOverlayRef` takes `Directionality`
|
|
250
|
+
* from the `Overlay`'s own injector, which `provideWrOverlay()` parents to
|
|
251
|
+
* the application's, so a node-level CDK `[dir]` is never in the chain. A
|
|
252
|
+
* panel is not IN that island either — it is appended to the overlay
|
|
253
|
+
* container on `<body>` — so following the node injector would not follow the
|
|
254
|
+
* ref at all: it would rewrite a correctly-stamped panel to the island's
|
|
255
|
+
* direction one pass after it opened, and `WrDrawerManager`, a root service
|
|
256
|
+
* with no island to read, could never do the same. Two halves of one
|
|
257
|
+
* component, same panel classes, same stylesheet, two answers.
|
|
258
|
+
*
|
|
259
|
+
* `null` never happens in an app — `Directionality` is root-provided — but a
|
|
260
|
+
* bare `TestBed` should still get a drawer that opens, with nothing ambient
|
|
261
|
+
* to follow.
|
|
262
|
+
*/
|
|
263
|
+
dir = inject(EnvironmentInjector).get(Directionality, null);
|
|
243
264
|
overlayRef = null;
|
|
244
265
|
focusTrap = null;
|
|
245
266
|
previouslyFocused = null;
|
|
@@ -301,6 +322,16 @@ class WrDrawer {
|
|
|
301
322
|
height: isHorizontal ? undefined : this.height(),
|
|
302
323
|
maxHeight: isHorizontal ? undefined : (cap ?? undefined),
|
|
303
324
|
});
|
|
325
|
+
// `position` is PHYSICAL — a `left` drawer is on the physical left in either
|
|
326
|
+
// direction — and it takes BOTH halves of the follower to keep it that way.
|
|
327
|
+
// The CDK places the panel with `justify-content` on a host it also writes
|
|
328
|
+
// `dir` to, and that host is a flex row, so the attribute alone reverses the
|
|
329
|
+
// main axis and slides a `left` drawer across to the right; `apply()`'s own
|
|
330
|
+
// RTL branch swaps `flex-start` for `flex-end` to cancel exactly that. So
|
|
331
|
+
// the `setDirection()` + `updatePosition()` pair leaves the panel where it
|
|
332
|
+
// is and only re-resolves what the panel's own logical CSS reads — which is
|
|
333
|
+
// the whole point, since the direction inside the drawer really did change.
|
|
334
|
+
wrFollowDirection(this.overlayRef, this.dir, this.injector);
|
|
304
335
|
const portal = new TemplatePortal(this.panelTpl(), this.vcr);
|
|
305
336
|
this.overlayRef.attach(portal);
|
|
306
337
|
if (this.isBrowser) {
|
|
@@ -563,6 +594,14 @@ class WrDrawerManager {
|
|
|
563
594
|
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
564
595
|
i18n = inject(WrI18n);
|
|
565
596
|
location = inject(Location);
|
|
597
|
+
/**
|
|
598
|
+
* The application's reading direction — the instance the CDK itself read when
|
|
599
|
+
* it stamped the overlay. A root service has no node injector above it, so a
|
|
600
|
+
* plain `inject()` here already resolves the environment one; `<wr-drawer>`,
|
|
601
|
+
* which does, spells that out and says why. The two halves of one component
|
|
602
|
+
* must not answer differently about the same panel.
|
|
603
|
+
*/
|
|
604
|
+
dir = inject(Directionality, { optional: true });
|
|
566
605
|
open(component, options = {}) {
|
|
567
606
|
const position = options.position ?? DEFAULT_POSITION;
|
|
568
607
|
const isHorizontal = position === 'left' || position === 'right';
|
|
@@ -606,6 +645,13 @@ class WrDrawerManager {
|
|
|
606
645
|
height: isHorizontal ? undefined : (options.height ?? DEFAULT_HEIGHT),
|
|
607
646
|
maxHeight: isHorizontal ? undefined : (cap ?? undefined),
|
|
608
647
|
});
|
|
648
|
+
// Same pair, same reason as `<wr-drawer>`: `position` is physical, the CDK
|
|
649
|
+
// writes `dir` on the flex host that `justify-content` places the panel in,
|
|
650
|
+
// so the attribute alone would slide a `left` drawer to the right and
|
|
651
|
+
// re-applying the strategy is what cancels it. The follower ends on the
|
|
652
|
+
// ref's own `detachments()`, which every dismissal goes through, and each
|
|
653
|
+
// `open()` creates a fresh ref of its own.
|
|
654
|
+
wrFollowDirection(overlayRef, this.dir, this.parentInjector);
|
|
609
655
|
const drawerRef = new WrDrawerRef(overlayRef);
|
|
610
656
|
if (this.isBrowser) {
|
|
611
657
|
const active = document.activeElement;
|