ngwr 14.6.0 → 14.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/alert/styles/_index.scss +14 -3
- package/avatar/styles/_index.scss +44 -0
- package/cascader/styles/_rules.scss +0 -4
- package/collapse/styles/_index.scss +0 -1
- package/fesm2022/ngwr-avatar.mjs +19 -2
- package/fesm2022/ngwr-avatar.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +2 -2
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-image-cropper.mjs +149 -62
- package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +2 -2
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +73 -22
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/input/styles/_index.scss +8 -2
- package/lightbox/styles/_rules.scss +7 -1
- package/package.json +1 -1
- package/select/styles/_index.scss +16 -4
- package/table/styles/_index.scss +55 -0
- package/toast/styles/_index.scss +9 -3
- package/tree/styles/_index.scss +0 -3
- package/types/ngwr-avatar.d.ts +15 -1
- package/types/ngwr-image-cropper.d.ts +48 -0
- package/types/ngwr-select.d.ts +63 -6
- package/types/ngwr-version.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-cascader.mjs","sources":["../../../projects/lib/cascader/cascader.ts","../../../projects/lib/cascader/cascader.html","../../../projects/lib/cascader/ngwr-cascader.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 { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n Injector,\n TemplateRef,\n ViewContainerRef,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { useI18nText } from 'ngwr/i18n';\nimport { WR_OVERLAY, WrOutsideClick, wrFollowDirection } from 'ngwr/overlay';\n\nimport type { WrCascaderOption } from './interfaces';\n\nlet panelUid = 0;\n\n/**\n * Multi-level select — drills down through hierarchical categories\n * (e.g. country → state → city). Each level renders as a column; clicks\n * advance to the next column. Selecting a leaf (no children) commits\n * the full path.\n *\n * A signal-forms native control: it implements `FormValueControl<unknown>`,\n * so `[formField]` binds straight to its `value` model — no\n * `ControlValueAccessor` in between. `[(value)]` works standalone. The value\n * is the path through the tree (an array from root to leaf).\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-cascader [options]=\"locations\" [formField]=\"form.path\" placeholder=\"Pick a location\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-cascader [options]=\"locations\" [(value)]=\"path\" placeholder=\"Pick a location\" />\n * ```\n *\n * ```ts\n * locations: WrCascaderOption[] = [\n * {\n * value: 'us', label: 'United States', children: [\n * { value: 'ny', label: 'New York', children: [\n * { value: 'nyc', label: 'NYC' },\n * { value: 'buf', label: 'Buffalo' },\n * ] },\n * ],\n * },\n * ];\n * ```\n *\n * @see https://ngwr.dev/reference/components/cascader\n */\nexport type WrCascaderSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-cascader',\n templateUrl: './cascader.html',\n styleUrl: './cascader.scss',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n})\nexport class WrCascader<T = string> implements FormValueControl<unknown> {\n /** Accessible name. Falls back to `select.clearSelection`, then `'Clear selection'`. */\n readonly clearLabel = input<string | null>(null);\n\n protected readonly resolvedClearLabel = useI18nText(this.clearLabel, 'select.clearSelection', 'Clear selection');\n\n /** Root-level options. Each may have `children` for deeper levels. */\n readonly options = input.required<readonly WrCascaderOption<T>[]>();\n\n /** Placeholder shown when no path is selected. @default '' */\n readonly placeholder = input<string>('');\n\n /**\n * Accessible name of the trigger. Falls back to the placeholder, then to\n * `select.label` — a `role=\"combobox\"` with nothing selected and no\n * placeholder otherwise has no name at all.\n */\n readonly ariaLabel = input<string | null>(null);\n\n private readonly labelText = useI18nText(this.ariaLabel, 'select.label', 'Select');\n protected readonly resolvedAriaLabel = computed(() => {\n // Not `??`: an empty placeholder must fall through to the catalog string.\n const explicit = this.ariaLabel();\n if (explicit) return explicit;\n const placeholder = this.placeholder();\n return placeholder ? placeholder : this.labelText();\n });\n\n /**\n * Disable the cascader. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse changes while the trigger stays focusable and the path still submits.\n * Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * The panel is where every edit happens, so a read-only cascader simply does\n * not open — there is nothing to browse that is not already on the trigger —\n * and the clear button goes away with it. Mirrored as `aria-readonly`, which\n * role `combobox` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrCascaderSize>('md');\n\n /** Show a clear-all (×) button on the trigger when a path is selected. @default true */\n readonly clearable = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Allow selecting non-leaf (parent) nodes. When `false`, only leaves\n * (nodes without children) commit a selection. @default false\n */\n readonly changeOnSelect = input(false, { transform: coerceBooleanProperty });\n\n /** Separator between labels in the trigger display. @default '/' */\n readonly separator = input<string>('/');\n\n /**\n * Committed selection path (full array from root to leaf). Bound by\n * `[formField]`, or two-way via `[(value)]`.\n */\n readonly value = model<unknown>([]);\n\n /** Emitted on blur / commit so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n /** Committed selection path (full T[] from root to leaf). @internal */\n protected readonly path = signal<readonly T[]>([]);\n\n /** Currently-expanded column path — drives which columns the panel shows. @internal */\n protected readonly activePath = signal<readonly T[]>([]);\n\n protected readonly open = signal(false);\n\n /** Panel id used by the trigger's `aria-controls`. */\n protected readonly panelId = `wr-cascader-panel-${++panelUid}`;\n\n /**\n * Columns visible in the panel. Each column shows the children of the\n * preceding activePath entry. Column 0 = root options. The last\n * column is whatever the deepest active node's children resolve to —\n * we only render a column when there are children to show.\n */\n protected readonly columns = computed<readonly (readonly WrCascaderOption<T>[])[]>(() => {\n const cols: (readonly WrCascaderOption<T>[])[] = [this.options()];\n const trail = this.activePath();\n let list: readonly WrCascaderOption<T>[] = this.options();\n for (const v of trail) {\n const node = list.find(o => o.value === v);\n if (!node?.children?.length) break;\n cols.push(node.children);\n list = node.children;\n }\n return cols;\n });\n\n /** Label trail joined by `separator()` — what the trigger shows. */\n protected readonly displayLabel = computed(() => {\n const p = this.path();\n if (p.length === 0) return null;\n const labels: string[] = [];\n let list: readonly WrCascaderOption<T>[] = this.options();\n for (const v of p) {\n const node = list.find(o => o.value === v);\n if (!node) return null;\n labels.push(node.label);\n list = node.children ?? [];\n }\n const sep = ` ${this.separator()} `;\n return labels.join(sep);\n });\n\n protected readonly hasSelection = computed(() => this.path().length > 0);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-cascader'];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-cascader--${size}`);\n if (this.open()) parts.push('wr-cascader--open');\n if (this.disabled()) parts.push('wr-cascader--disabled');\n else if (this.readonly()) parts.push('wr-cascader--readonly');\n return parts.join(' ');\n });\n\n protected readonly panelTpl = viewChild.required('panelTpl', { read: TemplateRef });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly overlay = inject(WR_OVERLAY);\n private readonly outsideClick = inject(WrOutsideClick);\n private readonly vcr = inject(ViewContainerRef);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n /**\n * Ambient reading direction, for the open panel alone — nothing in this\n * component reads it directly. Optional so a bare `TestBed` needs no\n * provider; `Directionality` is root-provided anyway, and a missing one\n * simply reads as `ltr`.\n */\n private readonly dir = inject(Directionality, { optional: true });\n private overlayRef: OverlayRef | null = null;\n\n constructor() {\n // Same contract as wr-select / wr-dropdown / wr-lightbox: an overlay lives in\n // the CDK container, not in this component's view, so destroying the\n // component while the panel is open would strand the pane and its scroll\n // strategy.\n this.destroyRef.onDestroy(() => this.closeOverlay());\n\n effect(() => {\n if (this.open()) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n });\n\n // Close the panel if the control becomes disabled or read-only while open.\n effect(() => {\n if (this.disabled() || this.readonly()) this.open.set(false);\n });\n\n // Mirror an external `value` write into the internal path/activePath\n // (the old `writeValue`). Skipped when the write merely echoes the\n // committed path, so a live drill-down can never be clobbered.\n effect(() => {\n // Coerce null/undefined/non-array to an empty path — a classic-forms\n // binding can write null, which the old `writeValue(value: unknown)`\n // treated as \"no selection\" too.\n const value = this.value();\n untracked(() => {\n const next: readonly T[] = Array.isArray(value) ? (value as readonly T[]) : [];\n if (this.pathsEqual(this.path(), next)) return;\n this.path.set(next);\n this.activePath.set(next);\n });\n });\n }\n\n // Template handlers\n\n protected onTriggerClick(): void {\n if (this.disabled() || this.readonly()) return;\n if (!this.open()) this.activePath.set(this.path());\n this.open.update(v => !v);\n }\n\n /**\n * ArrowDown / ArrowUp open the panel, Alt+ArrowDown included — the combobox way in,\n * and the shape `wr-dropdown`'s trigger uses. Enter and Space need no branch: the\n * trigger is a real `<button>`, so the browser turns them into the click above.\n *\n * Only while closed. Once the panel is up the caret is inside it, and its options\n * own their own keys.\n */\n protected onTriggerKeydown(event: KeyboardEvent): void {\n if (this.disabled() || this.readonly() || this.open()) return;\n\n // Backspace is the × from the keyboard, and it has to be: the × is a\n // `tabindex=\"-1\"` span INSIDE this button, and a keydown goes to the focused\n // element, so the `(keydown.enter)` / `(keydown.space)` it used to carry could\n // never fire. Clearing was reachable by pointer alone — a WCAG 2.1.1 failure,\n // not a missing convenience. The span stays unfocusable, because a focusable\n // child of a button is `nested-interactive`. Same key, same gating as\n // `wr-select`: `clearable()` IS the clear control, so a consumer who turned\n // the × off did not ask for a keyboard twin of it.\n if (event.key === 'Backspace') {\n if (!this.clearable() || !this.hasSelection()) return;\n event.preventDefault();\n this.clearSelection(event);\n return;\n }\n\n if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;\n event.preventDefault();\n this.activePath.set(this.path());\n this.open.set(true);\n }\n\n protected onOptionClick(colIndex: number, opt: WrCascaderOption<T>, event: Event): void {\n event.stopPropagation();\n if (opt.disabled || this.disabled() || this.readonly()) return;\n\n const head = this.activePath().slice(0, colIndex);\n const newPath = [...head, opt.value];\n\n const hasChildren = !!opt.children?.length;\n\n // Always update active column for visual feedback / next column.\n this.activePath.set(newPath);\n\n // Commit when we've reached a leaf, or when changeOnSelect is on.\n if (!hasChildren || this.changeOnSelect()) {\n this.path.set(newPath);\n this.value.set(newPath);\n this.touch.emit();\n // Close once we hit a true leaf — parent commits keep the panel open.\n if (!hasChildren) this.open.set(false);\n }\n }\n\n protected clearSelection(event: Event): void {\n event.stopPropagation();\n if (this.disabled() || this.readonly()) return;\n this.path.set([]);\n this.activePath.set([]);\n this.value.set([]);\n this.touch.emit();\n }\n\n protected isActiveAt(colIndex: number, value: T): boolean {\n return this.activePath()[colIndex] === value;\n }\n\n /**\n * Whether this option is the committed choice — `null` when it is not a\n * choice at all.\n *\n * Two questions the panel has to keep apart, and `--active` answers only the\n * first: `activePath()` is where the user has NAVIGATED to, `path()` is what\n * they have COMMITTED. They agree once a leaf is picked and diverge for the\n * whole walk down.\n *\n * `null` — the attribute absent — on a branch while `changeOnSelect` is off,\n * because such a branch genuinely cannot be chosen; ARIA reads a missing\n * `aria-selected` as \"not selectable\", which is exactly true here. That makes\n * this binding the first expression the `changeOnSelect` contract has ever had\n * in ARIA, in both directions.\n */\n protected isSelectedAt(colIndex: number, opt: WrCascaderOption<T>): boolean | null {\n const committable = !opt.children?.length || this.changeOnSelect();\n if (!committable) return null;\n const path = this.path();\n return colIndex === path.length - 1 && path[colIndex] === opt.value;\n }\n\n /** Stable id for one option — what a column's `aria-labelledby` points at. */\n protected optionId(colIndex: number, optIndex: number): string {\n return `${this.panelId}-opt-${colIndex}-${optIndex}`;\n }\n\n /** Stable id for one column — what an expanded branch's `aria-controls` points at. */\n protected columnId(colIndex: number): string {\n return `${this.panelId}-col-${colIndex}`;\n }\n\n /**\n * The option whose children a column holds, by id — its accessible name.\n *\n * The columns are DOM SIBLINGS, so nothing in the markup says the second one\n * belongs to \"Europe\". Column 0 has no parent and stays unnamed; the tree\n * itself already carries the control's name.\n */\n protected parentOptionId(colIndex: number): string | null {\n if (colIndex === 0) return null;\n const parent = this.columns()[colIndex - 1] ?? [];\n const index = parent.findIndex(o => this.isActiveAt(colIndex - 1, o.value));\n return index < 0 ? null : this.optionId(colIndex - 1, index);\n }\n\n private pathsEqual(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n\n // Overlay\n\n private openOverlay(): void {\n if (this.overlayRef) return;\n\n const positionStrategy = this.overlay\n .position()\n .flexibleConnectedTo(this.host)\n .withPositions([\n { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },\n ])\n .withPush(true);\n\n this.overlayRef = this.overlay.create({\n positionStrategy,\n scrollStrategy: this.scrollStrategies.reposition(),\n panelClass: 'wr-cascader-overlay',\n });\n\n // The columns cascade inline-wards, and the CDK captured the direction as a\n // string when this ref was created — so a flip while the panel is open left\n // the whole cascade running the other way from the page around it.\n wrFollowDirection(this.overlayRef, this.dir, this.injector);\n\n const portal = new TemplatePortal(this.panelTpl(), this.vcr);\n this.overlayRef.attach(portal);\n\n // Move the caret into the panel it just opened. Nothing did, and the pane is\n // appended to `<body>`, so an opened cascader left focus on the trigger and its\n // options were reachable only by tabbing past the whole rest of the page —\n // `wr-tree` and `wr-context-menu` were the same defect. `closeOverlay` below\n // already assumes this is where the caret lives.\n //\n // `afterNextRender`, NOT `queueMicrotask`: under zoneless CD change detection runs\n // in a macrotask, so a microtask queued here fires before the columns are in the\n // DOM — the trap that once left `wr-calendar`'s ring and its real focus on\n // different days.\n afterNextRender(() => this.focusPanelOption(), { injector: this.injector });\n\n this.outsideClick\n .outsidePointerEvents(this.overlayRef)\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (this.host.nativeElement.contains(event.target as Node)) return;\n this.open.set(false);\n });\n\n this.overlayRef\n .keydownEvents()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.open.set(false);\n }\n });\n }\n\n /**\n * The option the panel opens on: the selected one in the first column when there is\n * a selection, otherwise the first enabled root. A disabled option is skipped — it\n * still carries `tabindex=\"-1\"`, so `focus()` would land on it and answer for a\n * choice nobody can make.\n */\n private focusPanelOption(): void {\n const pane = this.overlayRef?.overlayElement;\n if (!pane) return;\n const option =\n pane.querySelector<HTMLElement>('.wr-cascader__opt--active:not(.wr-cascader__opt--disabled)') ??\n pane.querySelector<HTMLElement>('.wr-cascader__opt:not(.wr-cascader__opt--disabled)');\n option?.focus();\n }\n\n private closeOverlay(): void {\n if (!this.overlayRef) return;\n // Every enabled option carries `tabindex=\"0\"` and commits on Enter, so on\n // the keyboard the caret is INSIDE the pane by design — and the ordinary\n // way to finish choosing (`onOptionClick` on a leaf) closes it. Disposing\n // without handing focus back dropped it on `<body>` on the SUCCESS path,\n // not merely on dismissal: a keyboard user who had just picked a value then\n // had to Tab from the top of the document to get back to the control.\n // Untouched when focus had already moved elsewhere — that click is usually\n // what closed us, and stealing the caret back would fight the user for it.\n const pane = this.overlayRef.overlayElement;\n const focusWasInside = pane.contains(this.host.nativeElement.ownerDocument.activeElement);\n this.overlayRef.dispose();\n this.overlayRef = null;\n if (focusWasInside) this.host.nativeElement.querySelector<HTMLElement>('.wr-cascader__trigger')?.focus();\n }\n}\n\nexport type { WrCascaderOption } from './interfaces';\n","<button\n type=\"button\"\n class=\"wr-cascader__trigger\"\n role=\"combobox\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [disabled]=\"disabled()\"\n [attr.aria-haspopup]=\"'tree'\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onTriggerClick()\"\n (keydown)=\"onTriggerKeydown($event)\"\n (blur)=\"touch.emit()\"\n>\n @if (displayLabel(); as label) {\n <span class=\"wr-cascader__value\">{{ label }}</span>\n } @else {\n <span class=\"wr-cascader__placeholder\">{{ placeholder() }}</span>\n }\n\n @if (clearable() && hasSelection() && !disabled() && !readonly()) {\n <span\n class=\"wr-cascader__clear\"\n role=\"button\"\n [attr.aria-label]=\"resolvedClearLabel()\"\n tabindex=\"-1\"\n (click)=\"clearSelection($event)\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </span>\n }\n\n <svg\n class=\"wr-icon__svg wr-cascader__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n</button>\n\n<ng-template #panelTpl>\n <div\n class=\"wr-cascader-panel\"\n [class.wr-cascader-panel--sm]=\"size() === 'sm'\"\n [class.wr-cascader-panel--lg]=\"size() === 'lg'\"\n role=\"tree\"\n [attr.id]=\"panelId\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n >\n <!--\n tree / group / treeitem, and NOT menu. A combobox's popup may be a listbox,\n a tree, a grid or a dialog and nothing else, so `aria-haspopup=\"menu\"` on\n the trigger was an author error — and a `menu` may own menuitems and\n groups, never other menus, so the columns were a second one. Neither is\n visible to axe: `menu` is a valid token for the global `aria-haspopup`, and\n `aria-required-children` passes a menu-inside-menu (measured against this\n exact fragment). A tree is what this control has always been — the value is\n a PATH, and only `treeitem` supports aria-expanded, aria-level,\n aria-setsize, aria-posinset and aria-selected at once.\n\n The columns stay `group` rather than collapsing to `role=\"presentation\"`,\n which is also axe-clean: the DOM is column-MAJOR, so a flat tree would\n leave level plus document order as the only structure, and \"Germany\"\n (level 2) would read as a child of \"Antarctica\" (level 1, the item\n immediately before it in source order).\n -->\n @for (col of columns(); track $index; let colIndex = $index) {\n <ul\n class=\"wr-cascader__col\"\n role=\"group\"\n [attr.id]=\"columnId(colIndex)\"\n [attr.aria-labelledby]=\"parentOptionId(colIndex)\"\n >\n @for (opt of col; track opt.value; let optIndex = $index) {\n <!--\n `aria-expanded` is exactly `isActiveAt`: `columns()` renders the next\n column for the active option and only when it has children, so the\n state can never claim a column that is not on screen — and\n `aria-controls` rides that same invariant, which is what makes\n \"expanded\" refer to something when the expanded content is a SIBLING\n rather than a descendant. It is emitted only while expanded: a\n reference to an absent id is a violation with `aria-expanded=\"true\"`\n and clean while collapsed.\n\n `aria-level` is load-bearing rather than decorative. The columns are\n siblings, so the DOM ancestry represents no level at all and every\n option would read as level 1. `aria-setsize` / `aria-posinset` are\n not strictly required — each column IS a complete sibling set — and\n are written anyway, because a tree that owns sibling groups is the\n uncommon shape where browser/AT pairs are known to miscompute both.\n\n `aria-selected` is written on every option that can be COMMITTED,\n `false` included, matching `wr-tree`. The alternative a reviewer may\n prefer: only the selected node, leaning on treeitem's implicit false,\n which is quieter in a long column and loses the \"this row is\n selectable\" signal that presence carries.\n -->\n <li\n class=\"wr-cascader__opt\"\n role=\"treeitem\"\n [attr.id]=\"optionId(colIndex, optIndex)\"\n [class.wr-cascader__opt--active]=\"isActiveAt(colIndex, opt.value)\"\n [class.wr-cascader__opt--disabled]=\"opt.disabled\"\n [attr.tabindex]=\"opt.disabled ? -1 : 0\"\n [attr.aria-disabled]=\"opt.disabled ? true : null\"\n [attr.aria-level]=\"colIndex + 1\"\n [attr.aria-setsize]=\"$count\"\n [attr.aria-posinset]=\"optIndex + 1\"\n [attr.aria-selected]=\"isSelectedAt(colIndex, opt)\"\n [attr.aria-expanded]=\"opt.children?.length ? isActiveAt(colIndex, opt.value) : null\"\n [attr.aria-controls]=\"\n opt.children?.length && isActiveAt(colIndex, opt.value) ? columnId(colIndex + 1) : null\n \"\n (click)=\"onOptionClick(colIndex, opt, $event)\"\n (keydown.enter)=\"onOptionClick(colIndex, opt, $event)\"\n (keydown.space)=\"onOptionClick(colIndex, opt, $event)\"\n >\n <span class=\"wr-cascader__opt-label\">{{ opt.label }}</span>\n @if (opt.children?.length) {\n <svg\n class=\"wr-icon__svg wr-cascader__opt-arrow\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n }\n </li>\n }\n </ul>\n }\n </div>\n</ng-template>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA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AAA,EAAA,IAAA,EAAA,CAAA,UAAU,EAAA,EAAA,GAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AE5NpF;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngwr-cascader.mjs","sources":["../../../projects/lib/cascader/cascader.ts","../../../projects/lib/cascader/cascader.html","../../../projects/lib/cascader/ngwr-cascader.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 { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n Injector,\n TemplateRef,\n ViewContainerRef,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { useI18nText } from 'ngwr/i18n';\nimport { WR_OVERLAY, WrOutsideClick, wrFollowDirection } from 'ngwr/overlay';\n\nimport type { WrCascaderOption } from './interfaces';\n\nlet panelUid = 0;\n\n/**\n * Multi-level select — drills down through hierarchical categories\n * (e.g. country → state → city). Each level renders as a column; clicks\n * advance to the next column. Selecting a leaf (no children) commits\n * the full path.\n *\n * A signal-forms native control: it implements `FormValueControl<unknown>`,\n * so `[formField]` binds straight to its `value` model — no\n * `ControlValueAccessor` in between. `[(value)]` works standalone. The value\n * is the path through the tree (an array from root to leaf).\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-cascader [options]=\"locations\" [formField]=\"form.path\" placeholder=\"Pick a location\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-cascader [options]=\"locations\" [(value)]=\"path\" placeholder=\"Pick a location\" />\n * ```\n *\n * ```ts\n * locations: WrCascaderOption[] = [\n * {\n * value: 'us', label: 'United States', children: [\n * { value: 'ny', label: 'New York', children: [\n * { value: 'nyc', label: 'NYC' },\n * { value: 'buf', label: 'Buffalo' },\n * ] },\n * ],\n * },\n * ];\n * ```\n *\n * @see https://ngwr.dev/reference/components/cascader\n */\nexport type WrCascaderSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-cascader',\n templateUrl: './cascader.html',\n styleUrl: './cascader.scss',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n})\nexport class WrCascader<T = string> implements FormValueControl<unknown> {\n /** Accessible name. Falls back to `select.clearSelection`, then `'Clear selection'`. */\n readonly clearLabel = input<string | null>(null);\n\n protected readonly resolvedClearLabel = useI18nText(this.clearLabel, 'select.clearSelection', 'Clear selection');\n\n /** Root-level options. Each may have `children` for deeper levels. */\n readonly options = input.required<readonly WrCascaderOption<T>[]>();\n\n /** Placeholder shown when no path is selected. @default '' */\n readonly placeholder = input<string>('');\n\n /**\n * Accessible name of the trigger. Falls back to the placeholder, then to\n * `select.label` — a `role=\"combobox\"` with nothing selected and no\n * placeholder otherwise has no name at all.\n */\n readonly ariaLabel = input<string | null>(null);\n\n private readonly labelText = useI18nText(this.ariaLabel, 'select.label', 'Select');\n protected readonly resolvedAriaLabel = computed(() => {\n // Not `??`: an empty placeholder must fall through to the catalog string.\n const explicit = this.ariaLabel();\n if (explicit) return explicit;\n const placeholder = this.placeholder();\n return placeholder ? placeholder : this.labelText();\n });\n\n /**\n * Disable the cascader. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse changes while the trigger stays focusable and the path still submits.\n * Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * The panel is where every edit happens, so a read-only cascader simply does\n * not open — there is nothing to browse that is not already on the trigger —\n * and the clear button goes away with it. Mirrored as `aria-readonly`, which\n * role `combobox` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrCascaderSize>('md');\n\n /** Show a clear-all (×) button on the trigger when a path is selected. @default true */\n readonly clearable = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Allow selecting non-leaf (parent) nodes. When `false`, only leaves\n * (nodes without children) commit a selection. @default false\n */\n readonly changeOnSelect = input(false, { transform: coerceBooleanProperty });\n\n /** Separator between labels in the trigger display. @default '/' */\n readonly separator = input<string>('/');\n\n /**\n * Committed selection path (full array from root to leaf). Bound by\n * `[formField]`, or two-way via `[(value)]`.\n */\n readonly value = model<unknown>([]);\n\n /** Emitted on blur / commit so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n /** Committed selection path (full T[] from root to leaf). @internal */\n protected readonly path = signal<readonly T[]>([]);\n\n /** Currently-expanded column path — drives which columns the panel shows. @internal */\n protected readonly activePath = signal<readonly T[]>([]);\n\n protected readonly open = signal(false);\n\n /** Panel id used by the trigger's `aria-controls`. */\n protected readonly panelId = `wr-cascader-panel-${++panelUid}`;\n\n /**\n * Columns visible in the panel. Each column shows the children of the\n * preceding activePath entry. Column 0 = root options. The last\n * column is whatever the deepest active node's children resolve to —\n * we only render a column when there are children to show.\n */\n protected readonly columns = computed<readonly (readonly WrCascaderOption<T>[])[]>(() => {\n const cols: (readonly WrCascaderOption<T>[])[] = [this.options()];\n const trail = this.activePath();\n let list: readonly WrCascaderOption<T>[] = this.options();\n for (const v of trail) {\n const node = list.find(o => o.value === v);\n if (!node?.children?.length) break;\n cols.push(node.children);\n list = node.children;\n }\n return cols;\n });\n\n /** Label trail joined by `separator()` — what the trigger shows. */\n protected readonly displayLabel = computed(() => {\n const p = this.path();\n if (p.length === 0) return null;\n const labels: string[] = [];\n let list: readonly WrCascaderOption<T>[] = this.options();\n for (const v of p) {\n const node = list.find(o => o.value === v);\n if (!node) return null;\n labels.push(node.label);\n list = node.children ?? [];\n }\n const sep = ` ${this.separator()} `;\n return labels.join(sep);\n });\n\n protected readonly hasSelection = computed(() => this.path().length > 0);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-cascader'];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-cascader--${size}`);\n if (this.open()) parts.push('wr-cascader--open');\n if (this.disabled()) parts.push('wr-cascader--disabled');\n else if (this.readonly()) parts.push('wr-cascader--readonly');\n return parts.join(' ');\n });\n\n protected readonly panelTpl = viewChild.required('panelTpl', { read: TemplateRef });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly overlay = inject(WR_OVERLAY);\n private readonly outsideClick = inject(WrOutsideClick);\n private readonly vcr = inject(ViewContainerRef);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n /**\n * Ambient reading direction, for the open panel alone — nothing in this\n * component reads it directly. Optional so a bare `TestBed` needs no\n * provider; `Directionality` is root-provided anyway, and a missing one\n * simply reads as `ltr`.\n */\n private readonly dir = inject(Directionality, { optional: true });\n private overlayRef: OverlayRef | null = null;\n\n constructor() {\n // Same contract as wr-select / wr-dropdown / wr-lightbox: an overlay lives in\n // the CDK container, not in this component's view, so destroying the\n // component while the panel is open would strand the pane and its scroll\n // strategy.\n this.destroyRef.onDestroy(() => this.closeOverlay());\n\n effect(() => {\n if (this.open()) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n });\n\n // Close the panel if the control becomes disabled or read-only while open.\n effect(() => {\n if (this.disabled() || this.readonly()) this.open.set(false);\n });\n\n // Mirror an external `value` write into the internal path/activePath\n // (the old `writeValue`). Skipped when the write merely echoes the\n // committed path, so a live drill-down can never be clobbered.\n effect(() => {\n // Coerce null/undefined/non-array to an empty path — a classic-forms\n // binding can write null, which the old `writeValue(value: unknown)`\n // treated as \"no selection\" too.\n const value = this.value();\n untracked(() => {\n const next: readonly T[] = Array.isArray(value) ? (value as readonly T[]) : [];\n if (this.pathsEqual(this.path(), next)) return;\n this.path.set(next);\n this.activePath.set(next);\n });\n });\n }\n\n // Template handlers\n\n protected onTriggerClick(): void {\n if (this.disabled() || this.readonly()) return;\n if (!this.open()) this.activePath.set(this.path());\n this.open.update(v => !v);\n }\n\n /**\n * ArrowDown / ArrowUp open the panel, Alt+ArrowDown included — the combobox way in,\n * and the shape `wr-dropdown`'s trigger uses. Enter and Space need no branch: the\n * trigger is a real `<button>`, so the browser turns them into the click above.\n *\n * Only while closed. Once the panel is up the caret is inside it, and its options\n * own their own keys.\n */\n protected onTriggerKeydown(event: KeyboardEvent): void {\n if (this.disabled() || this.readonly() || this.open()) return;\n\n // Backspace is the × from the keyboard, and it has to be: the × is a\n // `tabindex=\"-1\"` span INSIDE this button, and a keydown goes to the focused\n // element, so the `(keydown.enter)` / `(keydown.space)` it used to carry could\n // never fire. Clearing was reachable by pointer alone — a WCAG 2.1.1 failure,\n // not a missing convenience. The span stays unfocusable, because a focusable\n // child of a button is `nested-interactive`. Same key, same gating as\n // `wr-select`: `clearable()` IS the clear control, so a consumer who turned\n // the × off did not ask for a keyboard twin of it.\n if (event.key === 'Backspace') {\n if (!this.clearable() || !this.hasSelection()) return;\n event.preventDefault();\n this.clearSelection(event);\n return;\n }\n\n if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;\n event.preventDefault();\n this.activePath.set(this.path());\n this.open.set(true);\n }\n\n protected onOptionClick(colIndex: number, opt: WrCascaderOption<T>, event: Event): void {\n event.stopPropagation();\n if (opt.disabled || this.disabled() || this.readonly()) return;\n\n const head = this.activePath().slice(0, colIndex);\n const newPath = [...head, opt.value];\n\n const hasChildren = !!opt.children?.length;\n\n // Always update active column for visual feedback / next column.\n this.activePath.set(newPath);\n\n // Commit when we've reached a leaf, or when changeOnSelect is on.\n if (!hasChildren || this.changeOnSelect()) {\n this.path.set(newPath);\n this.value.set(newPath);\n this.touch.emit();\n // Close once we hit a true leaf — parent commits keep the panel open.\n if (!hasChildren) this.open.set(false);\n }\n }\n\n protected clearSelection(event: Event): void {\n event.stopPropagation();\n if (this.disabled() || this.readonly()) return;\n this.path.set([]);\n this.activePath.set([]);\n this.value.set([]);\n this.touch.emit();\n }\n\n protected isActiveAt(colIndex: number, value: T): boolean {\n return this.activePath()[colIndex] === value;\n }\n\n /**\n * Whether this option is the committed choice — `null` when it is not a\n * choice at all.\n *\n * Two questions the panel has to keep apart, and `--active` answers only the\n * first: `activePath()` is where the user has NAVIGATED to, `path()` is what\n * they have COMMITTED. They agree once a leaf is picked and diverge for the\n * whole walk down.\n *\n * `null` — the attribute absent — on a branch while `changeOnSelect` is off,\n * because such a branch genuinely cannot be chosen; ARIA reads a missing\n * `aria-selected` as \"not selectable\", which is exactly true here. That makes\n * this binding the first expression the `changeOnSelect` contract has ever had\n * in ARIA, in both directions.\n */\n protected isSelectedAt(colIndex: number, opt: WrCascaderOption<T>): boolean | null {\n const committable = !opt.children?.length || this.changeOnSelect();\n if (!committable) return null;\n const path = this.path();\n return colIndex === path.length - 1 && path[colIndex] === opt.value;\n }\n\n /** Stable id for one option — what a column's `aria-labelledby` points at. */\n protected optionId(colIndex: number, optIndex: number): string {\n return `${this.panelId}-opt-${colIndex}-${optIndex}`;\n }\n\n /** Stable id for one column — what an expanded branch's `aria-controls` points at. */\n protected columnId(colIndex: number): string {\n return `${this.panelId}-col-${colIndex}`;\n }\n\n /**\n * The option whose children a column holds, by id — its accessible name.\n *\n * The columns are DOM SIBLINGS, so nothing in the markup says the second one\n * belongs to \"Europe\". Column 0 has no parent and stays unnamed; the tree\n * itself already carries the control's name.\n */\n protected parentOptionId(colIndex: number): string | null {\n if (colIndex === 0) return null;\n const parent = this.columns()[colIndex - 1] ?? [];\n const index = parent.findIndex(o => this.isActiveAt(colIndex - 1, o.value));\n return index < 0 ? null : this.optionId(colIndex - 1, index);\n }\n\n private pathsEqual(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n\n // Overlay\n\n private openOverlay(): void {\n if (this.overlayRef) return;\n\n const positionStrategy = this.overlay\n .position()\n .flexibleConnectedTo(this.host)\n .withPositions([\n { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },\n ])\n .withPush(true);\n\n this.overlayRef = this.overlay.create({\n positionStrategy,\n scrollStrategy: this.scrollStrategies.reposition(),\n panelClass: 'wr-cascader-overlay',\n });\n\n // The columns cascade inline-wards, and the CDK captured the direction as a\n // string when this ref was created — so a flip while the panel is open left\n // the whole cascade running the other way from the page around it.\n wrFollowDirection(this.overlayRef, this.dir, this.injector);\n\n const portal = new TemplatePortal(this.panelTpl(), this.vcr);\n this.overlayRef.attach(portal);\n\n // Move the caret into the panel it just opened. Nothing did, and the pane is\n // appended to `<body>`, so an opened cascader left focus on the trigger and its\n // options were reachable only by tabbing past the whole rest of the page —\n // `wr-tree` and `wr-context-menu` were the same defect. `closeOverlay` below\n // already assumes this is where the caret lives.\n //\n // `afterNextRender`, NOT `queueMicrotask`: under zoneless CD change detection runs\n // in a macrotask, so a microtask queued here fires before the columns are in the\n // DOM — the trap that once left `wr-calendar`'s ring and its real focus on\n // different days.\n afterNextRender(() => this.focusPanelOption(), { injector: this.injector });\n\n this.outsideClick\n .outsidePointerEvents(this.overlayRef)\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (this.host.nativeElement.contains(event.target as Node)) return;\n this.open.set(false);\n });\n\n this.overlayRef\n .keydownEvents()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.open.set(false);\n }\n });\n }\n\n /**\n * The option the panel opens on: the selected one in the first column when there is\n * a selection, otherwise the first enabled root. A disabled option is skipped — it\n * still carries `tabindex=\"-1\"`, so `focus()` would land on it and answer for a\n * choice nobody can make.\n */\n private focusPanelOption(): void {\n const pane = this.overlayRef?.overlayElement;\n if (!pane) return;\n const option =\n pane.querySelector<HTMLElement>('.wr-cascader__opt--active:not(.wr-cascader__opt--disabled)') ??\n pane.querySelector<HTMLElement>('.wr-cascader__opt:not(.wr-cascader__opt--disabled)');\n option?.focus();\n }\n\n private closeOverlay(): void {\n if (!this.overlayRef) return;\n // Every enabled option carries `tabindex=\"0\"` and commits on Enter, so on\n // the keyboard the caret is INSIDE the pane by design — and the ordinary\n // way to finish choosing (`onOptionClick` on a leaf) closes it. Disposing\n // without handing focus back dropped it on `<body>` on the SUCCESS path,\n // not merely on dismissal: a keyboard user who had just picked a value then\n // had to Tab from the top of the document to get back to the control.\n // Untouched when focus had already moved elsewhere — that click is usually\n // what closed us, and stealing the caret back would fight the user for it.\n const pane = this.overlayRef.overlayElement;\n const focusWasInside = pane.contains(this.host.nativeElement.ownerDocument.activeElement);\n this.overlayRef.dispose();\n this.overlayRef = null;\n if (focusWasInside) this.host.nativeElement.querySelector<HTMLElement>('.wr-cascader__trigger')?.focus();\n }\n}\n\nexport type { WrCascaderOption } from './interfaces';\n","<button\n type=\"button\"\n class=\"wr-cascader__trigger\"\n role=\"combobox\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [disabled]=\"disabled()\"\n [attr.aria-haspopup]=\"'tree'\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onTriggerClick()\"\n (keydown)=\"onTriggerKeydown($event)\"\n (blur)=\"touch.emit()\"\n>\n @if (displayLabel(); as label) {\n <span class=\"wr-cascader__value\">{{ label }}</span>\n } @else {\n <span class=\"wr-cascader__placeholder\">{{ placeholder() }}</span>\n }\n\n @if (clearable() && hasSelection() && !disabled() && !readonly()) {\n <span\n class=\"wr-cascader__clear\"\n role=\"button\"\n [attr.aria-label]=\"resolvedClearLabel()\"\n tabindex=\"-1\"\n (click)=\"clearSelection($event)\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </span>\n }\n\n <svg\n class=\"wr-icon__svg wr-cascader__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n</button>\n\n<ng-template #panelTpl>\n <div\n class=\"wr-cascader-panel\"\n [class.wr-cascader-panel--sm]=\"size() === 'sm'\"\n [class.wr-cascader-panel--lg]=\"size() === 'lg'\"\n role=\"tree\"\n [attr.id]=\"panelId\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n >\n <!--\n tree / group / treeitem, and NOT menu. A combobox's popup may be a listbox,\n a tree, a grid or a dialog and nothing else, so `aria-haspopup=\"menu\"` on\n the trigger was an author error — and a `menu` may own menuitems and\n groups, never other menus, so the columns were a second one. Neither is\n visible to axe: `menu` is a valid token for the global `aria-haspopup`, and\n `aria-required-children` passes a menu-inside-menu (measured against this\n exact fragment). A tree is what this control has always been — the value is\n a PATH, and only `treeitem` supports aria-expanded, aria-level,\n aria-setsize, aria-posinset and aria-selected at once.\n\n The columns stay `group` rather than collapsing to `role=\"presentation\"`,\n which is also axe-clean: the DOM is column-MAJOR, so a flat tree would\n leave level plus document order as the only structure, and \"Germany\"\n (level 2) would read as a child of \"Antarctica\" (level 1, the item\n immediately before it in source order).\n -->\n @for (col of columns(); track $index; let colIndex = $index) {\n <ul\n class=\"wr-cascader__col\"\n role=\"group\"\n [attr.id]=\"columnId(colIndex)\"\n [attr.aria-labelledby]=\"parentOptionId(colIndex)\"\n >\n @for (opt of col; track opt.value; let optIndex = $index) {\n <!--\n `aria-expanded` is exactly `isActiveAt`: `columns()` renders the next\n column for the active option and only when it has children, so the\n state can never claim a column that is not on screen — and\n `aria-controls` rides that same invariant, which is what makes\n \"expanded\" refer to something when the expanded content is a SIBLING\n rather than a descendant. It is emitted only while expanded: a\n reference to an absent id is a violation with `aria-expanded=\"true\"`\n and clean while collapsed.\n\n `aria-level` is load-bearing rather than decorative. The columns are\n siblings, so the DOM ancestry represents no level at all and every\n option would read as level 1. `aria-setsize` / `aria-posinset` are\n not strictly required — each column IS a complete sibling set — and\n are written anyway, because a tree that owns sibling groups is the\n uncommon shape where browser/AT pairs are known to miscompute both.\n\n `aria-selected` is written on every option that can be COMMITTED,\n `false` included, matching `wr-tree`. The alternative a reviewer may\n prefer: only the selected node, leaning on treeitem's implicit false,\n which is quieter in a long column and loses the \"this row is\n selectable\" signal that presence carries.\n -->\n <li\n class=\"wr-cascader__opt\"\n role=\"treeitem\"\n [attr.id]=\"optionId(colIndex, optIndex)\"\n [class.wr-cascader__opt--active]=\"isActiveAt(colIndex, opt.value)\"\n [class.wr-cascader__opt--disabled]=\"opt.disabled\"\n [attr.tabindex]=\"opt.disabled ? -1 : 0\"\n [attr.aria-disabled]=\"opt.disabled ? true : null\"\n [attr.aria-level]=\"colIndex + 1\"\n [attr.aria-setsize]=\"$count\"\n [attr.aria-posinset]=\"optIndex + 1\"\n [attr.aria-selected]=\"isSelectedAt(colIndex, opt)\"\n [attr.aria-expanded]=\"opt.children?.length ? isActiveAt(colIndex, opt.value) : null\"\n [attr.aria-controls]=\"\n opt.children?.length && isActiveAt(colIndex, opt.value) ? columnId(colIndex + 1) : null\n \"\n (click)=\"onOptionClick(colIndex, opt, $event)\"\n (keydown.enter)=\"onOptionClick(colIndex, opt, $event)\"\n (keydown.space)=\"onOptionClick(colIndex, opt, $event)\"\n >\n <span class=\"wr-cascader__opt-label\">{{ opt.label }}</span>\n @if (opt.children?.length) {\n <svg\n class=\"wr-icon__svg wr-cascader__opt-arrow\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n }\n </li>\n }\n </ul>\n }\n </div>\n</ng-template>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;AAKG;AAkCH,IAAI,QAAQ,GAAG,CAAC;MA8CH,UAAU,CAAA;;IAEZ,UAAU,GAAG,KAAK,CAAgB,IAAI;mFAAC;IAE7B,kBAAkB,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,uBAAuB,EAAE,iBAAiB,CAAC;;IAGvG,OAAO,GAAG,KAAK,CAAC,QAAQ;gFAAkC;;IAG1D,WAAW,GAAG,KAAK,CAAS,EAAE;oFAAC;AAExC;;;;AAIG;IACM,SAAS,GAAG,KAAK,CAAgB,IAAI;kFAAC;IAE9B,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,EAAE,QAAQ,CAAC;AAC/D,IAAA,iBAAiB,GAAG,QAAQ,CAAC,MAAK;;AAEnD,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE;AACjC,QAAA,IAAI,QAAQ;AAAE,YAAA,OAAO,QAAQ;AAC7B,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE;AACtC,QAAA,OAAO,WAAW,GAAG,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE;IACrD,CAAC;0FAAC;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AAA,EAAA,KAAA,EAAA,WAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,KAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,OAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,aAAA,CAAA,EAAA,CAAA,EAAA,KAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,OAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,SAAA,EAAA,IAAA,EAAA,CAAA,UAAU,EAAA,EAAA,GAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AE5NpF;;AAEG;;;;"}
|
|
@@ -2,7 +2,7 @@ import { coerceNumberProperty } from '@angular/cdk/coercion';
|
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { signal, input, output, viewChild, inject, DestroyRef, computed, effect, ViewEncapsulation, Component } from '@angular/core';
|
|
4
4
|
import { useI18nText } from 'ngwr/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { clamp, randomId } from 'ngwr/utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
@@ -30,6 +30,67 @@ const NO_OVERRIDE = signal(null).asReadonly();
|
|
|
30
30
|
/** Keyboard step in display pixels, and what Shift promotes it to. */
|
|
31
31
|
const KEY_STEP = 1;
|
|
32
32
|
const KEY_STEP_COARSE = 10;
|
|
33
|
+
const NO_SIDES = { left: 0, top: 0, right: 0, bottom: 0 };
|
|
34
|
+
/**
|
|
35
|
+
* The rect a resize gesture produces: a pure function of the rect the gesture started
|
|
36
|
+
* from and the TOTAL pointer offset, so the same pointer position always gives the same
|
|
37
|
+
* rect however the pointer got there.
|
|
38
|
+
*
|
|
39
|
+
* The anchor never moves. It is the edge or corner opposite the handle — for `se` the
|
|
40
|
+
* top-left corner, for `e` the west edge's line. The old version clamped `x`, `y`, `w`
|
|
41
|
+
* and `h` one at a time after deriving the second axis, so once the derived axis ran
|
|
42
|
+
* into the image edge the rect slid AWAY from its anchor and, past the far bound, off
|
|
43
|
+
* the image entirely.
|
|
44
|
+
*
|
|
45
|
+
* With a ratio the size is the largest along that ratio which fits from the anchor —
|
|
46
|
+
* the smaller of the width-limited and height-limited sizes — and no smaller than both
|
|
47
|
+
* minimums allow. Where the image cannot fit the minimum from this anchor, the bound
|
|
48
|
+
* wins: a crop past the edge of the image is worse than one under the minimum.
|
|
49
|
+
*
|
|
50
|
+
* An edge handle with a ratio also sizes the axis it does not drive, and that axis has
|
|
51
|
+
* the image's WHOLE extent to grow into: the rect stays centred on its old midline where
|
|
52
|
+
* it can and slides along that axis only as far as it must to stay on the image. Capping
|
|
53
|
+
* the size at twice the distance from the midline to the nearer side instead would leave
|
|
54
|
+
* a square crop resting against the top edge unable to widen at all.
|
|
55
|
+
*/
|
|
56
|
+
function resizeFrom(r, handle, dx, dy, bounds, min, ratio) {
|
|
57
|
+
const east = handle.includes('e');
|
|
58
|
+
const west = handle.includes('w');
|
|
59
|
+
const south = handle.includes('s');
|
|
60
|
+
const north = handle.includes('n');
|
|
61
|
+
const right = r.x + r.w;
|
|
62
|
+
const bottom = r.y + r.h;
|
|
63
|
+
if (!ratio || ratio <= 0) {
|
|
64
|
+
let { x, y, w, h } = r;
|
|
65
|
+
if (east)
|
|
66
|
+
w = clamp(r.w + dx, min.w, bounds.w - r.x);
|
|
67
|
+
if (west) {
|
|
68
|
+
w = clamp(r.w - dx, min.w, right);
|
|
69
|
+
x = right - w;
|
|
70
|
+
}
|
|
71
|
+
if (south)
|
|
72
|
+
h = clamp(r.h + dy, min.h, bounds.h - r.y);
|
|
73
|
+
if (north) {
|
|
74
|
+
h = clamp(r.h - dy, min.h, bottom);
|
|
75
|
+
y = bottom - h;
|
|
76
|
+
}
|
|
77
|
+
return { x, y, w, h };
|
|
78
|
+
}
|
|
79
|
+
// Room from the anchor to the image edge on each axis the handle drives; the whole
|
|
80
|
+
// image on an axis it does not.
|
|
81
|
+
const roomW = east ? bounds.w - r.x : west ? right : bounds.w;
|
|
82
|
+
const roomH = south ? bounds.h - r.y : north ? bottom : bounds.h;
|
|
83
|
+
// Corners follow the horizontal delta, as they always have; `n` / `s` the vertical one.
|
|
84
|
+
const wanted = east ? r.w + dx : west ? r.w - dx : (south ? r.h + dy : r.h - dy) * ratio;
|
|
85
|
+
const w = clamp(wanted, Math.max(min.w, min.h * ratio), Math.min(roomW, roomH * ratio));
|
|
86
|
+
const h = w / ratio;
|
|
87
|
+
return {
|
|
88
|
+
x: east ? r.x : west ? right - w : clamp(r.x + r.w / 2 - w / 2, 0, bounds.w - w),
|
|
89
|
+
y: south ? r.y : north ? bottom - h : clamp(r.y + r.h / 2 - h / 2, 0, bounds.h - h),
|
|
90
|
+
w,
|
|
91
|
+
h,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
33
94
|
/**
|
|
34
95
|
* Image crop UI. Pass `[src]` (URL, `File`, or `Blob`); the user drags
|
|
35
96
|
* the crop window or any of its eight handles. Optionally lock the crop
|
|
@@ -128,6 +189,12 @@ class WrImageCropper {
|
|
|
128
189
|
active = null;
|
|
129
190
|
startPointer = { x: 0, y: 0 };
|
|
130
191
|
startRect = { x: 0, y: 0, w: 0, h: 0 };
|
|
192
|
+
/** The element the live drag set pointer capture on, so the end releases that one. */
|
|
193
|
+
captureTarget = null;
|
|
194
|
+
/** The pointer the live drag belongs to. Every other pointer's events are ignored. */
|
|
195
|
+
pointerId = null;
|
|
196
|
+
/** How far past each side of the crop the live resize was pressed — see `onPointerMove`. */
|
|
197
|
+
overhang = NO_SIDES;
|
|
131
198
|
destroyRef = inject(DestroyRef);
|
|
132
199
|
statusState = signal('empty', /* @ts-ignore */
|
|
133
200
|
...(ngDevMode ? [{ debugName: "statusState" }] : /* istanbul ignore next */ []));
|
|
@@ -330,27 +397,98 @@ class WrImageCropper {
|
|
|
330
397
|
event.preventDefault();
|
|
331
398
|
event.stopPropagation();
|
|
332
399
|
this.active = handle;
|
|
400
|
+
this.pointerId = event.pointerId;
|
|
333
401
|
this.startPointer = { x: event.clientX, y: event.clientY };
|
|
334
402
|
this.startRect = { ...this.cropDisplay() };
|
|
335
|
-
event.currentTarget
|
|
403
|
+
this.captureTarget = event.currentTarget;
|
|
404
|
+
this.captureTarget.setPointerCapture(event.pointerId);
|
|
405
|
+
this.overhang = handle === 'move' ? NO_SIDES : this.pastCrop(event);
|
|
336
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* A resize ENDS when the pointer leaves the image, exactly as `pointerup` would end it:
|
|
409
|
+
* the move that carried it out is applied — clamped to the image like any other — and
|
|
410
|
+
* then the drag is over. Nothing after that resumes it or changes the crop, pointer
|
|
411
|
+
* back over the image or not, until a new `pointerdown`. A move drag is not affected:
|
|
412
|
+
* its size is fixed, so it simply rests against the edge.
|
|
413
|
+
*
|
|
414
|
+
* The move that leaves is applied rather than dropped because pointer moves are
|
|
415
|
+
* SAMPLES. Dropped, a quick drag toward a corner would stop wherever its last sample
|
|
416
|
+
* inside happened to fall — a single move from a handle to past the image would change
|
|
417
|
+
* nothing at all — and even a slow one would stop a fraction of a pixel short of the
|
|
418
|
+
* edge. A drag that leaves across one edge still ends there: heading for a corner at a
|
|
419
|
+
* slant that crosses the bottom first, the crop's right edge stays where it was then.
|
|
420
|
+
*
|
|
421
|
+
* "The image" is the `<img>`'s own box — the bounds `applyMove` / `applyResize` clamp
|
|
422
|
+
* the crop to — with its edges counting as inside, since the crop may reach them. The
|
|
423
|
+
* box is re-measured on every move and compared with `clientX` / `clientY`: both are
|
|
424
|
+
* viewport coordinates, so a scroll mid-drag cannot put them out of step. The moves
|
|
425
|
+
* outside reach this handler at all only because the drag holds pointer capture.
|
|
426
|
+
*
|
|
427
|
+
* One allowance, fixed at `pointerdown`: the box is widened on each side by however far
|
|
428
|
+
* past that side of the CROP the press landed — at most as far as the pressed handle
|
|
429
|
+
* reaches past it. Half of an edge handle, and three quarters of a corner handle, lies
|
|
430
|
+
* outside the crop, so a press there already has the pointer ahead of the edge it drags.
|
|
431
|
+
* Measured without the allowance, that pointer would leave the image while the crop was
|
|
432
|
+
* still short of the image's edge by the same distance, with nothing able to close the
|
|
433
|
+
* gap; and a handle resting on the image's edge, pressed on its outer part, would begin
|
|
434
|
+
* its drag already outside. A press on a handle's inner part widens nothing.
|
|
435
|
+
*/
|
|
337
436
|
onPointerMove(event) {
|
|
338
|
-
if (!this.active)
|
|
437
|
+
if (!this.active || event.pointerId !== this.pointerId)
|
|
339
438
|
return;
|
|
340
439
|
const dx = event.clientX - this.startPointer.x;
|
|
341
440
|
const dy = event.clientY - this.startPointer.y;
|
|
342
|
-
if (this.active === 'move')
|
|
441
|
+
if (this.active === 'move') {
|
|
343
442
|
this.applyMove(dx, dy);
|
|
344
|
-
|
|
345
|
-
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
this.applyResize(this.active, dx, dy);
|
|
446
|
+
if (!this.withinImage(event))
|
|
447
|
+
this.onPointerUp(event);
|
|
346
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Ends the drag — for `pointerup`, `pointercancel`, a capture lost to something else,
|
|
451
|
+
* and a resize whose pointer left the image. Once per drag: the capture released here
|
|
452
|
+
* fires `lostpointercapture` afterwards, and by then there is nothing left to end.
|
|
453
|
+
*
|
|
454
|
+
* Only for the pointer that started it. A second finger is refused a drag of its own at
|
|
455
|
+
* `pointerdown`, but its moves and its lifting reach these handlers all the same, and
|
|
456
|
+
* would otherwise drive or end the first finger's drag.
|
|
457
|
+
*/
|
|
347
458
|
onPointerUp(event) {
|
|
348
|
-
if (!this.active)
|
|
459
|
+
if (!this.active || event.pointerId !== this.pointerId)
|
|
349
460
|
return;
|
|
350
|
-
|
|
461
|
+
const target = this.captureTarget;
|
|
351
462
|
this.active = null;
|
|
463
|
+
this.pointerId = null;
|
|
464
|
+
this.captureTarget = null;
|
|
465
|
+
this.overhang = NO_SIDES;
|
|
466
|
+
// Asked first: a capture that is already gone has nothing to release, and releasing
|
|
467
|
+
// one for a pointer that is no longer active throws.
|
|
468
|
+
if (target?.hasPointerCapture(event.pointerId))
|
|
469
|
+
target.releasePointerCapture(event.pointerId);
|
|
352
470
|
void this.emitCropped();
|
|
353
471
|
}
|
|
472
|
+
/** How far past each side of the crop window the pointer is, in CSS pixels. */
|
|
473
|
+
pastCrop(event) {
|
|
474
|
+
const box = this.imgEl().nativeElement.getBoundingClientRect();
|
|
475
|
+
const c = this.startRect;
|
|
476
|
+
return {
|
|
477
|
+
left: Math.max(0, box.left + c.x - event.clientX),
|
|
478
|
+
top: Math.max(0, box.top + c.y - event.clientY),
|
|
479
|
+
right: Math.max(0, event.clientX - (box.left + c.x + c.w)),
|
|
480
|
+
bottom: Math.max(0, event.clientY - (box.top + c.y + c.h)),
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
/** Whether the pointer is on the image, edges and the press's `overhang` included. */
|
|
484
|
+
withinImage(event) {
|
|
485
|
+
const box = this.imgEl().nativeElement.getBoundingClientRect();
|
|
486
|
+
const o = this.overhang;
|
|
487
|
+
return (event.clientX >= box.left - o.left &&
|
|
488
|
+
event.clientX <= box.right + o.right &&
|
|
489
|
+
event.clientY >= box.top - o.top &&
|
|
490
|
+
event.clientY <= box.bottom + o.bottom);
|
|
491
|
+
}
|
|
354
492
|
// Keyboard
|
|
355
493
|
/** Whether a key has moved the crop since the last `keyup`. */
|
|
356
494
|
keyboardDirty = false;
|
|
@@ -428,59 +566,8 @@ class WrImageCropper {
|
|
|
428
566
|
this.cropDisplay.set(next);
|
|
429
567
|
}
|
|
430
568
|
applyResize(handle, dx, dy) {
|
|
431
|
-
const display = this.display();
|
|
432
569
|
const min = { w: this.minWidth(), h: this.minHeight() };
|
|
433
|
-
|
|
434
|
-
const r = this.startRect;
|
|
435
|
-
let x = r.x;
|
|
436
|
-
let y = r.y;
|
|
437
|
-
let w = r.w;
|
|
438
|
-
let h = r.h;
|
|
439
|
-
if (handle.includes('e'))
|
|
440
|
-
w = clamp(r.w + dx, min.w, display.w - r.x);
|
|
441
|
-
if (handle.includes('w')) {
|
|
442
|
-
const nextW = clamp(r.w - dx, min.w, r.x + r.w);
|
|
443
|
-
x = r.x + (r.w - nextW);
|
|
444
|
-
w = nextW;
|
|
445
|
-
}
|
|
446
|
-
if (handle.includes('s'))
|
|
447
|
-
h = clamp(r.h + dy, min.h, display.h - r.y);
|
|
448
|
-
if (handle.includes('n')) {
|
|
449
|
-
const nextH = clamp(r.h - dy, min.h, r.y + r.h);
|
|
450
|
-
y = r.y + (r.h - nextH);
|
|
451
|
-
h = nextH;
|
|
452
|
-
}
|
|
453
|
-
if (ratio && ratio > 0) {
|
|
454
|
-
// Lock the orthogonal axis to maintain ratio. For corner handles,
|
|
455
|
-
// pick whichever delta drives the larger change so we don't bounce.
|
|
456
|
-
if (handle === 'e' || handle === 'w') {
|
|
457
|
-
const newH = w / ratio;
|
|
458
|
-
const dh = newH - r.h;
|
|
459
|
-
if (handle === 'e' || handle === 'w') {
|
|
460
|
-
y = r.y - dh / 2;
|
|
461
|
-
h = newH;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
else if (handle === 'n' || handle === 's') {
|
|
465
|
-
const newW = h * ratio;
|
|
466
|
-
const dw = newW - r.w;
|
|
467
|
-
x = r.x - dw / 2;
|
|
468
|
-
w = newW;
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
// Corner — drive by width, then derive height.
|
|
472
|
-
const newH = w / ratio;
|
|
473
|
-
if (handle.includes('n'))
|
|
474
|
-
y = r.y + r.h - newH;
|
|
475
|
-
h = newH;
|
|
476
|
-
}
|
|
477
|
-
// Re-clamp after ratio adjustment so we never spill out of the canvas.
|
|
478
|
-
x = clamp(x, 0, display.w - w);
|
|
479
|
-
y = clamp(y, 0, display.h - h);
|
|
480
|
-
w = clamp(w, min.w, display.w - x);
|
|
481
|
-
h = clamp(h, min.h, display.h - y);
|
|
482
|
-
}
|
|
483
|
-
this.cropDisplay.set({ x, y, w, h });
|
|
570
|
+
this.cropDisplay.set(resizeFrom(this.startRect, handle, dx, dy, this.display(), min, this.aspectRatio()));
|
|
484
571
|
}
|
|
485
572
|
// Public API
|
|
486
573
|
/** Render the current crop as a Blob. */
|
|
@@ -543,14 +630,14 @@ class WrImageCropper {
|
|
|
543
630
|
}
|
|
544
631
|
}
|
|
545
632
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: WrImageCropper, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
546
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.6", type: WrImageCropper, isStandalone: true, selector: "wr-image-cropper", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, aspectRatio: { classPropertyName: "aspectRatio", publicName: "aspectRatio", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, outputType: { classPropertyName: "outputType", publicName: "outputType", isSignal: true, isRequired: false, transformFunction: null }, outputQuality: { classPropertyName: "outputQuality", publicName: "outputQuality", isSignal: true, isRequired: false, transformFunction: null }, maxOutputSize: { classPropertyName: "maxOutputSize", publicName: "maxOutputSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { cropped: "cropped", loadError: "loadError" }, host: { properties: { "class.wr-image-cropper--failed": "status() === 'failed'" }, classAttribute: "wr-image-cropper" }, viewQueries: [{ propertyName: "imgEl", first: true, predicate: ["img"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img\n #img\n class=\"wr-image-cropper__image\"\n [src]=\"url\"\n alt=\"\"\n draggable=\"false\"\n (load)=\"onImageLoad()\"\n (error)=\"onImageError()\"\n />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!--\n Crop window \u2014 drag to move, with eight resize handles, and the ONE\n keyboard control the component has (see `onWindowKeydown`). The eight\n handles stay pointer-only and `aria-hidden`: eight extra tab stops per\n cropper would be hostile. The keys resize from the east and south edges\n only, so a west or north drag comes out as a resize plus a move rather\n than as one gesture.\n\n `role=\"group\"` rather than no role at all, because `aria-label` is\n prohibited on a roleless `<div>` and this needs a name; and rather than\n `role=\"application\"`, which would switch the reader out of its own\n browse mode for the whole subtree \u2014 far more than one rectangle is worth.\n -->\n <div\n class=\"wr-image-cropper__window\"\n role=\"group\"\n tabindex=\"0\"\n [attr.aria-label]=\"resolvedWindowLabel()\"\n [attr.aria-describedby]=\"helpId\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (keydown)=\"onWindowKeydown($event)\"\n (keyup)=\"onWindowKeyup()\"\n >\n @for (h of handles; track h) {\n <span\n aria-hidden=\"true\"\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n\n <p class=\"wr-image-cropper__sr-only\" [id]=\"helpId\">{{ resolvedKeyHelp() }}</p>\n\n <!--\n The crop rect in SOURCE pixels, announced after a keyboard change only \u2014\n a pointer drag already gives sighted feedback and would flood the region,\n and the initial crop is not news. Deliberately bare numbers: a sentence\n here would be a translated string the catalog does not carry, and the\n reader has just been told what the four numbers mean by `helpId`.\n -->\n <p class=\"wr-image-cropper__sr-only\" role=\"status\">{{ announcement() }}</p>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">{{ emptyText() }}</div>\n}\n", encapsulation: i0.ViewEncapsulation.None });
|
|
633
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.6", type: WrImageCropper, isStandalone: true, selector: "wr-image-cropper", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, aspectRatio: { classPropertyName: "aspectRatio", publicName: "aspectRatio", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, outputType: { classPropertyName: "outputType", publicName: "outputType", isSignal: true, isRequired: false, transformFunction: null }, outputQuality: { classPropertyName: "outputQuality", publicName: "outputQuality", isSignal: true, isRequired: false, transformFunction: null }, maxOutputSize: { classPropertyName: "maxOutputSize", publicName: "maxOutputSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { cropped: "cropped", loadError: "loadError" }, host: { properties: { "class.wr-image-cropper--failed": "status() === 'failed'" }, classAttribute: "wr-image-cropper" }, viewQueries: [{ propertyName: "imgEl", first: true, predicate: ["img"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img\n #img\n class=\"wr-image-cropper__image\"\n [src]=\"url\"\n alt=\"\"\n draggable=\"false\"\n (load)=\"onImageLoad()\"\n (error)=\"onImageError()\"\n />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!--\n Crop window \u2014 drag to move, with eight resize handles, and the ONE\n keyboard control the component has (see `onWindowKeydown`). The eight\n handles stay pointer-only and `aria-hidden`: eight extra tab stops per\n cropper would be hostile. The keys resize from the east and south edges\n only, so a west or north drag comes out as a resize plus a move rather\n than as one gesture.\n\n `role=\"group\"` rather than no role at all, because `aria-label` is\n prohibited on a roleless `<div>` and this needs a name; and rather than\n `role=\"application\"`, which would switch the reader out of its own\n browse mode for the whole subtree \u2014 far more than one rectangle is worth.\n -->\n <div\n class=\"wr-image-cropper__window\"\n role=\"group\"\n tabindex=\"0\"\n [attr.aria-label]=\"resolvedWindowLabel()\"\n [attr.aria-describedby]=\"helpId\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (lostpointercapture)=\"onPointerUp($event)\"\n (keydown)=\"onWindowKeydown($event)\"\n (keyup)=\"onWindowKeyup()\"\n >\n @for (h of handles; track h) {\n <span\n aria-hidden=\"true\"\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (lostpointercapture)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n\n <p class=\"wr-image-cropper__sr-only\" [id]=\"helpId\">{{ resolvedKeyHelp() }}</p>\n\n <!--\n The crop rect in SOURCE pixels, announced after a keyboard change only \u2014\n a pointer drag already gives sighted feedback and would flood the region,\n and the initial crop is not news. Deliberately bare numbers: a sentence\n here would be a translated string the catalog does not carry, and the\n reader has just been told what the four numbers mean by `helpId`.\n -->\n <p class=\"wr-image-cropper__sr-only\" role=\"status\">{{ announcement() }}</p>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">{{ emptyText() }}</div>\n}\n", encapsulation: i0.ViewEncapsulation.None });
|
|
547
634
|
}
|
|
548
635
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: WrImageCropper, decorators: [{
|
|
549
636
|
type: Component,
|
|
550
637
|
args: [{ selector: 'wr-image-cropper', encapsulation: ViewEncapsulation.None, host: {
|
|
551
638
|
class: 'wr-image-cropper',
|
|
552
639
|
'[class.wr-image-cropper--failed]': "status() === 'failed'",
|
|
553
|
-
}, template: "@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img\n #img\n class=\"wr-image-cropper__image\"\n [src]=\"url\"\n alt=\"\"\n draggable=\"false\"\n (load)=\"onImageLoad()\"\n (error)=\"onImageError()\"\n />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!--\n Crop window \u2014 drag to move, with eight resize handles, and the ONE\n keyboard control the component has (see `onWindowKeydown`). The eight\n handles stay pointer-only and `aria-hidden`: eight extra tab stops per\n cropper would be hostile. The keys resize from the east and south edges\n only, so a west or north drag comes out as a resize plus a move rather\n than as one gesture.\n\n `role=\"group\"` rather than no role at all, because `aria-label` is\n prohibited on a roleless `<div>` and this needs a name; and rather than\n `role=\"application\"`, which would switch the reader out of its own\n browse mode for the whole subtree \u2014 far more than one rectangle is worth.\n -->\n <div\n class=\"wr-image-cropper__window\"\n role=\"group\"\n tabindex=\"0\"\n [attr.aria-label]=\"resolvedWindowLabel()\"\n [attr.aria-describedby]=\"helpId\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (keydown)=\"onWindowKeydown($event)\"\n (keyup)=\"onWindowKeyup()\"\n >\n @for (h of handles; track h) {\n <span\n aria-hidden=\"true\"\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n\n <p class=\"wr-image-cropper__sr-only\" [id]=\"helpId\">{{ resolvedKeyHelp() }}</p>\n\n <!--\n The crop rect in SOURCE pixels, announced after a keyboard change only \u2014\n a pointer drag already gives sighted feedback and would flood the region,\n and the initial crop is not news. Deliberately bare numbers: a sentence\n here would be a translated string the catalog does not carry, and the\n reader has just been told what the four numbers mean by `helpId`.\n -->\n <p class=\"wr-image-cropper__sr-only\" role=\"status\">{{ announcement() }}</p>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">{{ emptyText() }}</div>\n}\n" }]
|
|
640
|
+
}, template: "@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img\n #img\n class=\"wr-image-cropper__image\"\n [src]=\"url\"\n alt=\"\"\n draggable=\"false\"\n (load)=\"onImageLoad()\"\n (error)=\"onImageError()\"\n />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!--\n Crop window \u2014 drag to move, with eight resize handles, and the ONE\n keyboard control the component has (see `onWindowKeydown`). The eight\n handles stay pointer-only and `aria-hidden`: eight extra tab stops per\n cropper would be hostile. The keys resize from the east and south edges\n only, so a west or north drag comes out as a resize plus a move rather\n than as one gesture.\n\n `role=\"group\"` rather than no role at all, because `aria-label` is\n prohibited on a roleless `<div>` and this needs a name; and rather than\n `role=\"application\"`, which would switch the reader out of its own\n browse mode for the whole subtree \u2014 far more than one rectangle is worth.\n -->\n <div\n class=\"wr-image-cropper__window\"\n role=\"group\"\n tabindex=\"0\"\n [attr.aria-label]=\"resolvedWindowLabel()\"\n [attr.aria-describedby]=\"helpId\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (lostpointercapture)=\"onPointerUp($event)\"\n (keydown)=\"onWindowKeydown($event)\"\n (keyup)=\"onWindowKeyup()\"\n >\n @for (h of handles; track h) {\n <span\n aria-hidden=\"true\"\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (lostpointercapture)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n\n <p class=\"wr-image-cropper__sr-only\" [id]=\"helpId\">{{ resolvedKeyHelp() }}</p>\n\n <!--\n The crop rect in SOURCE pixels, announced after a keyboard change only \u2014\n a pointer drag already gives sighted feedback and would flood the region,\n and the initial crop is not news. Deliberately bare numbers: a sentence\n here would be a translated string the catalog does not carry, and the\n reader has just been told what the four numbers mean by `helpId`.\n -->\n <p class=\"wr-image-cropper__sr-only\" role=\"status\">{{ announcement() }}</p>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">{{ emptyText() }}</div>\n}\n" }]
|
|
554
641
|
}], ctorParameters: () => [], propDecorators: { src: [{ type: i0.Input, args: [{ isSignal: true, alias: "src", required: false }] }], aspectRatio: [{ type: i0.Input, args: [{ isSignal: true, alias: "aspectRatio", required: false }] }], minWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "minWidth", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], outputType: [{ type: i0.Input, args: [{ isSignal: true, alias: "outputType", required: false }] }], outputQuality: [{ type: i0.Input, args: [{ isSignal: true, alias: "outputQuality", required: false }] }], maxOutputSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxOutputSize", required: false }] }], cropped: [{ type: i0.Output, args: ["cropped"] }], loadError: [{ type: i0.Output, args: ["loadError"] }], imgEl: [{ type: i0.ViewChild, args: ['img', { isSignal: true }] }] } });
|
|
555
642
|
|
|
556
643
|
/**
|