ngwr 16.7.1 → 16.9.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/charts/donut-chart/styles/_index.scss +9 -3
- package/charts/meter-group/styles/_index.scss +8 -1
- package/charts/sparkline/styles/_index.scss +6 -3
- package/command-palette/styles/_index.scss +10 -0
- package/descriptions/styles/_index.scss +91 -0
- package/fesm2022/ngwr-anchor.mjs +48 -10
- package/fesm2022/ngwr-anchor.mjs.map +1 -1
- package/fesm2022/ngwr-carousel.mjs +3 -2
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +3 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-charts-core.mjs +17 -0
- package/fesm2022/ngwr-charts-core.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart-testing.mjs +27 -0
- package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart.mjs +54 -6
- package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group-testing.mjs +27 -0
- package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group.mjs +54 -6
- package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-charts-sparkline-testing.mjs +27 -0
- package/fesm2022/ngwr-charts-sparkline-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-sparkline.mjs +45 -4
- package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox.mjs +38 -3
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +4 -3
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-command-palette.mjs +39 -19
- package/fesm2022/ngwr-command-palette.mjs.map +1 -1
- package/fesm2022/ngwr-compare.mjs +4 -0
- package/fesm2022/ngwr-compare.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +7 -2
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-cookie.mjs +6 -3
- package/fesm2022/ngwr-cookie.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp-testing.mjs +3 -0
- package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp.mjs +81 -4
- package/fesm2022/ngwr-date-stamp.mjs.map +1 -1
- package/fesm2022/ngwr-date.mjs +16 -2
- package/fesm2022/ngwr-date.mjs.map +1 -1
- package/fesm2022/ngwr-density.mjs +4 -3
- package/fesm2022/ngwr-density.mjs.map +1 -1
- package/fesm2022/ngwr-descriptions.mjs +77 -20
- package/fesm2022/ngwr-descriptions.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +10 -7
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +12 -0
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +14 -8
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +1 -0
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +4 -5
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-hotkey.mjs +10 -5
- package/fesm2022/ngwr-hotkey.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +18 -5
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +18 -5
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +18 -5
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +18 -5
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +18 -5
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +18 -5
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +18 -5
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +18 -5
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +18 -5
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +18 -5
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +18 -5
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-kk.mjs +18 -5
- package/fesm2022/ngwr-i18n-kk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +18 -5
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +18 -5
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +18 -5
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +18 -5
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +18 -5
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +18 -5
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +18 -5
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +18 -5
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +18 -5
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +18 -5
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +18 -5
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +7 -6
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-image-cropper-testing.mjs +33 -0
- package/fesm2022/ngwr-image-cropper-testing.mjs.map +1 -1
- package/fesm2022/ngwr-image-cropper.mjs +536 -30
- package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +33 -10
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +24 -10
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +2 -2
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-knob.mjs +5 -0
- package/fesm2022/ngwr-knob.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +5 -3
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-mention.mjs +2 -0
- package/fesm2022/ngwr-mention.mjs.map +1 -1
- package/fesm2022/ngwr-meta.mjs +43 -8
- package/fesm2022/ngwr-meta.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +51 -2
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +1 -1
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +160 -8
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm.mjs +2 -2
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-qr.mjs +65 -7
- package/fesm2022/ngwr-qr.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +2 -2
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-scroll.mjs +1 -2
- package/fesm2022/ngwr-scroll.mjs.map +1 -1
- package/fesm2022/ngwr-slider.mjs +22 -17
- package/fesm2022/ngwr-slider.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +30 -1
- package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
- package/fesm2022/ngwr-statistic.mjs +1 -1
- package/fesm2022/ngwr-stepper-testing.mjs +7 -1
- package/fesm2022/ngwr-stepper-testing.mjs.map +1 -1
- package/fesm2022/ngwr-stepper.mjs +55 -4
- package/fesm2022/ngwr-stepper.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +33 -3
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-timeline.mjs +4 -0
- package/fesm2022/ngwr-timeline.mjs.map +1 -1
- package/fesm2022/ngwr-toolbar.mjs +171 -16
- package/fesm2022/ngwr-toolbar.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +8 -3
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-transfer.mjs +3 -2
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +1 -1
- package/fesm2022/ngwr-utils.mjs +46 -8
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-virtual-scroll.mjs +2 -2
- package/fesm2022/ngwr-virtual-scroll.mjs.map +1 -1
- package/i18n/ar.json +18 -5
- package/i18n/cs.json +18 -5
- package/i18n/de.json +18 -5
- package/i18n/en.json +18 -5
- package/i18n/es.json +18 -5
- package/i18n/fr.json +18 -5
- package/i18n/he.json +18 -5
- package/i18n/hi.json +18 -5
- package/i18n/id.json +18 -5
- package/i18n/it.json +18 -5
- package/i18n/ja.json +18 -5
- package/i18n/kk.json +18 -5
- package/i18n/ko.json +18 -5
- package/i18n/nl.json +18 -5
- package/i18n/pl.json +18 -5
- package/i18n/pt.json +18 -5
- package/i18n/ru.json +18 -5
- package/i18n/sv.json +18 -5
- package/i18n/tr.json +18 -5
- package/i18n/uk.json +18 -5
- package/i18n/vi.json +18 -5
- package/i18n/zh-TW.json +18 -5
- package/i18n/zh.json +18 -5
- package/image-cropper/styles/_index.scss +30 -1
- package/llms-full.txt +9 -9
- package/package.json +1 -1
- package/schematics/use/rule.js +1 -0
- package/schematics/use/symbol-map.json +2 -0
- package/skills/ngwr/SKILL.md +2 -2
- package/stepper/styles/_index.scss +33 -0
- package/tour/styles/_index.scss +11 -7
- package/types/ngwr-anchor.d.ts +14 -1
- package/types/ngwr-charts-donut-chart-testing.d.ts +32 -3
- package/types/ngwr-charts-donut-chart.d.ts +45 -6
- package/types/ngwr-charts-meter-group-testing.d.ts +29 -1
- package/types/ngwr-charts-meter-group.d.ts +43 -4
- package/types/ngwr-charts-sparkline-testing.d.ts +32 -2
- package/types/ngwr-charts-sparkline.d.ts +42 -3
- package/types/ngwr-checkbox.d.ts +14 -0
- package/types/ngwr-color-picker-testing.d.ts +1 -1
- package/types/ngwr-command-palette.d.ts +2 -1
- package/types/ngwr-date-stamp-testing.d.ts +2 -0
- package/types/ngwr-date-stamp.d.ts +41 -2
- package/types/ngwr-date.d.ts +3 -1
- package/types/ngwr-descriptions.d.ts +33 -5
- package/types/ngwr-dialog.d.ts +11 -6
- package/types/ngwr-directives.d.ts +1 -0
- package/types/ngwr-drawer.d.ts +12 -4
- package/types/ngwr-file-upload.d.ts +1 -1
- package/types/ngwr-form.d.ts +4 -0
- package/types/ngwr-hotkey.d.ts +2 -0
- package/types/ngwr-image-cropper-testing.d.ts +33 -1
- package/types/ngwr-image-cropper.d.ts +214 -6
- package/types/ngwr-input-number.d.ts +14 -2
- package/types/ngwr-input-otp.d.ts +2 -0
- package/types/ngwr-lightbox.d.ts +1 -0
- package/types/ngwr-meta.d.ts +13 -1
- package/types/ngwr-overlay.d.ts +20 -1
- package/types/ngwr-pipes.d.ts +125 -1
- package/types/ngwr-qr.d.ts +17 -0
- package/types/ngwr-slider.d.ts +3 -1
- package/types/ngwr-speed-dial.d.ts +10 -0
- package/types/ngwr-stepper-testing.d.ts +10 -0
- package/types/ngwr-stepper.d.ts +47 -1
- package/types/ngwr-switch.d.ts +13 -0
- package/types/ngwr-toolbar.d.ts +27 -0
- package/types/ngwr-transfer.d.ts +2 -0
- package/types/ngwr-utils.d.ts +61 -2
- package/types/ngwr-version.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-input.mjs","names":[],"sources":["../../../projects/lib/input/directives/wr-input.ts","../../../projects/lib/input/directives/wr-input-prefix.ts","../../../projects/lib/input/directives/wr-input-suffix.ts","../../../projects/lib/input/input-group.ts","../../../projects/lib/input/input-group.html","../../../projects/lib/input/password-toggle.ts","../../../projects/lib/input/password-toggle.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Directive, ElementRef, computed, inject, input } from '@angular/core';\n\nimport { WR_FORM_FIELD, useFormFieldAria } from 'ngwr/form';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrInputSize } from '../types';\n\n/**\n * Applies NGWR input styling to a native `<input>` element.\n *\n * Because this is an attribute directive on the real `<input>` (not a wrapper\n * component), any other directive that targets `input` — `[(ngModel)]`,\n * `[formControl]`, validators, third-party libraries like `ngx-mask` — composes\n * naturally on the same element.\n *\n * @example\n * ```html\n * <input wrInput [(ngModel)]=\"name\" placeholder=\"Your name\" />\n *\n * <!-- Works with ngx-mask, validators, etc. -->\n * <input wrInput [(ngModel)]=\"phone\" mask=\"(000) 000-0000\" />\n * ```\n *\n * For prefix / suffix / password-toggle layouts, wrap the input in\n * `<wr-input-group>`.\n *\n * @see https://ngwr.dev/reference/components/input\n */\n@Directive({\n selector: 'input[wrInput], textarea[wrInput]',\n host: {\n class: 'wr-input',\n '[class]': 'classes()',\n '[attr.id]': 'resolvedId()',\n '[attr.aria-invalid]': 'ariaInvalid()',\n '[attr.aria-describedby]': 'describedBy()',\n '[attr.aria-required]': 'ariaRequired()',\n },\n})\nexport class WrInput {\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly field = inject(WR_FORM_FIELD, { optional: true });\n\n /**\n * Read once, at construction: a static `id=\"\"` in the template is already on\n * the element by the time a directive is instantiated, and it must win over\n * the field's generated one.\n */\n private readonly ownId = this.host.nativeElement.getAttribute('id');\n\n /**\n * Adopts the surrounding `<wr-form-field>`'s `controlId`, so the label it\n * already rendered actually points at this element. Without this the `for`\n * referenced an id that existed nowhere and the input had no label at all.\n */\n protected readonly resolvedId = computed(() => this.ownId ?? this.field?.controlId() ?? null);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n // Tell the field which id actually stuck. Without this its `<label for>` keeps\n // pointing at the generated id while this element answers to the author's own —\n // a label referencing nothing, which is the same as having none.\n if (this.ownId) this.field?.adoptControlId(this.ownId);\n }\n\n /**\n * Announced state, taken from the surrounding `<wr-form-field>`.\n *\n * The field renders the message but cannot reach the projected control, so\n * the control reads back: without this the error is visible on screen and\n * invisible to a screen reader, which never learns the field is invalid or\n * what the message says.\n */\n // Through the shared helper, not a local pair: the hint is described by\n // `hintId`, which only `useFormFieldAria()` composes, and `aria-invalid` keys\n // on the error COUNT rather than on \"something is described\". Hand-rolled here,\n // these three announced the error and never the hint — and `<input wrInput>` is\n // the control the report was filed against.\n private readonly fieldAria = useFormFieldAria();\n protected readonly describedBy = this.fieldAria.describedBy;\n protected readonly ariaInvalid = this.fieldAria.ariaInvalid;\n\n /** The element's own `aria-required`, read once: a hand-written one wins over the field's. */\n private readonly ownAriaRequired = this.host.nativeElement.getAttribute('aria-required');\n\n /**\n * Native `required` (including the one Signal Forms binds) already announces it,\n * so the field's `required` only fills in when neither is there.\n */\n protected ariaRequired(): string | null {\n if (this.ownAriaRequired !== null) return this.ownAriaRequired;\n if ((this.host.nativeElement as HTMLInputElement).required) return null;\n return this.fieldAria.ariaRequired();\n }\n\n /**\n * Control size. @default 'md'\n *\n * Called `wrSize` until v14, to dodge the native `<input size>` attribute —\n * which measures the field in characters and which `.wr-input`'s `width: 100%`\n * has always overridden, so the clash it guarded against was never observable.\n * It made this the one size input in the catalog spelled differently from the\n * other twenty-three. The cost of the change is that a consumer who wanted the\n * NATIVE `size` on an ngwr input can no longer have it — but `width: 100%`\n * meant they never did.\n */\n readonly size = input<WrInputSize>('md');\n\n /** Pill-shaped corners. @default false */\n readonly rounded = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-input--${size}`);\n if (this.rounded()) parts.push('wr-input--rounded');\n return parts.join(' ');\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 } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Marks an element as the **left** decoration inside `<wr-input-group>`.\n * Adds the `.wr-input-group__affix` class so the group's layout flexes it\n * to the input's left edge.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <span wrInputPrefix>$</span>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * </wr-input-group>\n * ```\n */\n@Directive({\n selector: '[wrInputPrefix]',\n host: { class: 'wr-input-group__affix wr-input-group__affix--prefix' },\n})\nexport class WrInputPrefix {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\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 } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Marks an element as the **right** decoration inside `<wr-input-group>`.\n * Adds the `.wr-input-group__affix` class so the group's layout flexes it\n * to the input's right edge.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * <span wrInputSuffix>USD</span>\n * </wr-input-group>\n * ```\n */\n@Directive({\n selector: '[wrInputSuffix]',\n host: { class: 'wr-input-group__affix wr-input-group__affix--suffix' },\n})\nexport class WrInputSuffix {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n ElementRef,\n Renderer2,\n ViewEncapsulation,\n afterEveryRender,\n computed,\n contentChild,\n effect,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { WrSpinner } from 'ngwr/spinner';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrInput } from './directives';\n\n/**\n * Container for `<input wrInput>` + `[wrInputPrefix]` / `[wrInputSuffix]` /\n * `<wr-password-toggle>` siblings. Renders the border and focus ring; the\n * inner native input drops its own border so it visually melts into the\n * group.\n *\n * Focus styling is driven entirely by `:focus-within`, so any focusable child\n * counts.\n *\n * `clearable` and `loading` draw a clear (×) button and a spinner after the\n * field, before any `[wrInputSuffix]` or `<wr-password-toggle>`. Both act on the\n * first `wrInput` the group wraps.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <span wrInputPrefix>$</span>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * <span wrInputSuffix>USD</span>\n * </wr-input-group>\n *\n * <!-- a search box: a clear button, and a spinner while the lookup runs -->\n * <wr-input-group clearable [loading]=\"pending()\">\n * <input wrInput [(ngModel)]=\"query\" placeholder=\"Search\" />\n * </wr-input-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/input\n */\n@Component({\n selector: 'wr-input-group',\n templateUrl: './input-group.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-input-group', '[class]': 'classes()', '(input)': 'syncClear()' },\n imports: [WrSpinner],\n})\nexport class WrInputGroup {\n private readonly renderer = inject(Renderer2);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n\n // A native field's value is not a signal, and a model write (`ngModel`,\n // `[formField]`, a bound `[value]`) reaches it with no event. So the field\n // is read after every render, and on its own `input` events in between.\n afterEveryRender({ read: () => this.syncClear() });\n\n effect(() => {\n const field = this.field()?.nativeElement;\n if (!field) return;\n if (this.loading()) this.renderer.setAttribute(field, 'aria-busy', 'true');\n else this.renderer.removeAttribute(field, 'aria-busy');\n });\n }\n\n /** Pill-shaped corners. @default false */\n readonly rounded = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Show a clear (×) button while the field holds text and is neither disabled\n * nor read-only. Clearing empties the field through an `input` event, so\n * whatever is bound to it (`ngModel`, `[formField]`, an `(input)` listener)\n * hears it as an edit, and puts focus back in the field. It is a pointer\n * control: from the keyboard, emptying the field clears it. @default false\n */\n readonly clearable = input(false, { transform: coerceBooleanProperty });\n\n /** Clear (×) button aria-label. Falls back to `common.clear`. */\n readonly clearLabel = input<string | null>(null);\n\n /**\n * Show a spinner after the field and mark the field `aria-busy`. The field\n * stays editable. @default false\n */\n readonly loading = input(false, { transform: coerceBooleanProperty });\n\n /** Emitted after the clear (×) button emptied the field. */\n readonly cleared = output<void>();\n\n protected readonly resolvedClear = useI18nText(this.clearLabel, 'common.clear', 'Clear');\n\n private readonly field = contentChild<WrInput, ElementRef<HTMLInputElement | HTMLTextAreaElement>>(WrInput, {\n read: ElementRef,\n });\n\n /** Whether the field has text a user could clear right now. */\n private readonly fieldClearable = signal(false);\n\n protected readonly clearShown = computed(() => this.clearable() && this.fieldClearable());\n\n protected syncClear(): void {\n if (!this.clearable()) return;\n const field = this.field()?.nativeElement;\n this.fieldClearable.set(!!field && field.value !== '' && !field.disabled && !field.readOnly);\n }\n\n protected clear(): void {\n const field = this.field()?.nativeElement;\n if (!field || field.disabled || field.readOnly) return;\n field.value = '';\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.focus();\n this.cleared.emit();\n }\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.rounded()) parts.push('wr-input-group--rounded');\n return parts.join(' ');\n });\n}\n","<ng-content />\n<!-- Pointer-only, as the select's is: emptying the field is the keyboard way to clear. -->\n@if (clearShown()) {\n <span class=\"wr-input-group__clear\" role=\"button\" [attr.aria-label]=\"resolvedClear()\" tabindex=\"-1\" (click)=\"clear()\">\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} @else if (clearable()) {\n <!-- Holds the ×'s room while the field is empty, so clearing does not narrow the group. -->\n <span class=\"wr-input-group__clear-space\" aria-hidden=\"true\"></span>\n}\n<!-- Hidden from the accessibility tree: the field says it is busy with `aria-busy`. -->\n@if (loading()) {\n <wr-spinner class=\"wr-input-group__spinner\" size=\"sm\" aria-hidden=\"true\" />\n}\n<ng-content select=\"[wrInputSuffix], wr-password-toggle\" />\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 { Component, ViewEncapsulation, computed, input, signal } from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Self-contained eye-toggle button. Flips the linked `<input>`'s `type`\n * attribute between `password` and `text`. Drop it inside an\n * `<wr-input-group>` next to a password input.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <input wrInput type=\"password\" [(ngModel)]=\"pw\" #pwInput />\n * <wr-password-toggle [for]=\"pwInput\" />\n * </wr-input-group>\n * ```\n */\n@Component({\n selector: 'wr-password-toggle',\n templateUrl: './password-toggle.html',\n encapsulation: ViewEncapsulation.None,\n})\nexport class WrPasswordToggle {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n }\n\n /** Reference to the linked password input. */\n readonly for = input.required<HTMLInputElement>();\n\n protected readonly revealed = signal(false);\n\n /** Accessible name while the password is hidden. Falls back to `input.showPassword`. */\n readonly showPasswordLabel = input<string | null>(null);\n\n /** Accessible name while the password is revealed. Falls back to `input.hidePassword`. */\n readonly hidePasswordLabel = input<string | null>(null);\n\n private readonly resolvedShowPasswordLabel = useI18nText(\n this.showPasswordLabel,\n 'input.showPassword',\n 'Show password'\n );\n private readonly resolvedHidePasswordLabel = useI18nText(\n this.hidePasswordLabel,\n 'input.hidePassword',\n 'Hide password'\n );\n\n protected readonly ariaLabel = computed(() =>\n this.revealed() ? this.resolvedHidePasswordLabel() : this.resolvedShowPasswordLabel()\n );\n\n protected toggle(): void {\n const input = this.for();\n const next = input.type === 'password' ? 'text' : 'password';\n input.type = next;\n this.revealed.set(next === 'text');\n }\n}\n","<button\n type=\"button\"\n class=\"wr-input-group__toggle\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-pressed]=\"revealed()\"\n (click)=\"toggle()\"\n>\n @if (revealed()) {\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=\"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49\" />\n <path d=\"M14.084 14.158a3 3 0 0 1-4.242-4.242\" />\n <path d=\"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143\" />\n <path d=\"m2 2 20 20\" />\n </svg>\n } @else {\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=\"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n }\n</button>\n"],"mappings":";;;;;;;;;;;;;AA+CA,IAAa,UAAb,MAAa,QAAO;CACD,OAAO,OAAgC,UAAU;CACjD,QAAQ,OAAO,eAAe,EAAE,UAAU,KAAI,CAAE;CAOhD,QAAQ,KAAK,KAAK,cAAc,aAAa,IAAI;CAO/C,aAAa,eAAe,KAAK,SAAS,KAAK,OAAO,UAAS,KAAM,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAE7F,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,OAAO;EAIxE,IAAI,KAAK,OAAO,KAAK,OAAO,eAAe,KAAK,KAAK;CACvD;CAeiB,YAAY,iBAAgB;CAC1B,cAAc,KAAK,UAAU;CAC7B,cAAc,KAAK,UAAU;CAG/B,kBAAkB,KAAK,KAAK,cAAc,aAAa,eAAe;CAM7E,eAAY;EACpB,IAAI,KAAK,oBAAoB,MAAM,OAAO,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A,YAAA;IAAA,mBAAA;GAAA;GAAA,mBAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,UAAA;EAAA,UC9B7B;EAyCA,eAAA,GAAA,kBAAA;CAAA,CAAA;;ADXa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgB,YAAA,CAAA;EAL5B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAoB,eAEf,kBAAkB;GAAI,UAAA;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-input.mjs","names":[],"sources":["../../../projects/lib/input/directives/wr-input.ts","../../../projects/lib/input/directives/wr-input-prefix.ts","../../../projects/lib/input/directives/wr-input-suffix.ts","../../../projects/lib/input/input-group.ts","../../../projects/lib/input/input-group.html","../../../projects/lib/input/password-toggle.ts","../../../projects/lib/input/password-toggle.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Directive, ElementRef, computed, inject, input } from '@angular/core';\n\nimport { WR_FORM_FIELD, useFormFieldAria } from 'ngwr/form';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrInputSize } from '../types';\n\n/**\n * Applies NGWR input styling to a native `<input>` element.\n *\n * Because this is an attribute directive on the real `<input>` (not a wrapper\n * component), any other directive that targets `input` — `[(ngModel)]`,\n * `[formControl]`, validators, third-party libraries like `ngx-mask` — composes\n * naturally on the same element.\n *\n * @example\n * ```html\n * <input wrInput [(ngModel)]=\"name\" placeholder=\"Your name\" />\n *\n * <!-- Works with ngx-mask, validators, etc. -->\n * <input wrInput [(ngModel)]=\"phone\" mask=\"(000) 000-0000\" />\n * ```\n *\n * For prefix / suffix / password-toggle layouts, wrap the input in\n * `<wr-input-group>`.\n *\n * @see https://ngwr.dev/reference/components/input\n */\n@Directive({\n selector: 'input[wrInput], textarea[wrInput]',\n host: {\n class: 'wr-input',\n '[class]': 'classes()',\n '[attr.id]': 'resolvedId()',\n '[attr.aria-invalid]': 'ariaInvalid()',\n '[attr.aria-describedby]': 'describedBy()',\n '[attr.aria-required]': 'ariaRequired()',\n },\n})\nexport class WrInput {\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly field = inject(WR_FORM_FIELD, { optional: true });\n\n /**\n * Read once, at construction: a static `id=\"\"` in the template is already on\n * the element by the time a directive is instantiated, and it must win over\n * the field's generated one.\n */\n private readonly ownId = this.host.nativeElement.getAttribute('id');\n\n /**\n * Adopts the surrounding `<wr-form-field>`'s `controlId`, so the label it\n * already rendered actually points at this element. Without this the `for`\n * referenced an id that existed nowhere and the input had no label at all.\n */\n protected readonly resolvedId = computed(() => this.ownId ?? this.field?.controlId() ?? null);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n // Tell the field which id actually stuck. Without this its `<label for>` keeps\n // pointing at the generated id while this element answers to the author's own —\n // a label referencing nothing, which is the same as having none.\n if (this.ownId) this.field?.adoptControlId(this.ownId);\n }\n\n /**\n * Announced state, taken from the surrounding `<wr-form-field>`.\n *\n * The field renders the message but cannot reach the projected control, so\n * the control reads back: without this the error is visible on screen and\n * invisible to a screen reader, which never learns the field is invalid or\n * what the message says.\n */\n // Through the shared helper, not a local pair: the hint is described by\n // `hintId`, which only `useFormFieldAria()` composes, and `aria-invalid` keys\n // on the error COUNT rather than on \"something is described\". Hand-rolled here,\n // these three announced the error and never the hint — and `<input wrInput>` is\n // the control the report was filed against.\n private readonly fieldAria = useFormFieldAria();\n protected readonly describedBy = this.fieldAria.describedBy;\n protected readonly ariaInvalid = this.fieldAria.ariaInvalid;\n\n /** The element's own `aria-required`, read once: a hand-written one wins over the field's. */\n private readonly ownAriaRequired = this.host.nativeElement.getAttribute('aria-required');\n\n /**\n * Native `required` (including the one Signal Forms binds) already announces it,\n * so the field's `required` only fills in when neither is there.\n */\n protected ariaRequired(): string | null {\n if (this.ownAriaRequired !== null) return this.ownAriaRequired;\n if ((this.host.nativeElement as HTMLInputElement).required) return null;\n return this.fieldAria.ariaRequired();\n }\n\n /**\n * Control size. @default 'md'\n *\n * Called `wrSize` until v14, to dodge the native `<input size>` attribute —\n * which measures the field in characters and which `.wr-input`'s `width: 100%`\n * has always overridden, so the clash it guarded against was never observable.\n * It made this the one size input in the catalog spelled differently from the\n * other twenty-three. The cost of the change is that a consumer who wanted the\n * NATIVE `size` on an ngwr input can no longer have it — but `width: 100%`\n * meant they never did.\n */\n readonly size = input<WrInputSize>('md');\n\n /** Pill-shaped corners. @default false */\n readonly rounded = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-input--${size}`);\n if (this.rounded()) parts.push('wr-input--rounded');\n return parts.join(' ');\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 } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Marks an element as the **left** decoration inside `<wr-input-group>`.\n * Adds the `.wr-input-group__affix` class so the group's layout flexes it\n * to the input's left edge.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <span wrInputPrefix>$</span>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * </wr-input-group>\n * ```\n */\n@Directive({\n selector: '[wrInputPrefix]',\n host: { class: 'wr-input-group__affix wr-input-group__affix--prefix' },\n})\nexport class WrInputPrefix {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\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 } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Marks an element as the **right** decoration inside `<wr-input-group>`.\n * Adds the `.wr-input-group__affix` class so the group's layout flexes it\n * to the input's right edge.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * <span wrInputSuffix>USD</span>\n * </wr-input-group>\n * ```\n */\n@Directive({\n selector: '[wrInputSuffix]',\n host: { class: 'wr-input-group__affix wr-input-group__affix--suffix' },\n})\nexport class WrInputSuffix {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n ElementRef,\n Renderer2,\n ViewEncapsulation,\n afterEveryRender,\n computed,\n contentChild,\n effect,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { WrSpinner } from 'ngwr/spinner';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrInput } from './directives';\n\n/**\n * Container for `<input wrInput>` + `[wrInputPrefix]` / `[wrInputSuffix]` /\n * `<wr-password-toggle>` siblings. Renders the border and focus ring; the\n * inner native input drops its own border so it visually melts into the\n * group.\n *\n * Focus styling is driven entirely by `:focus-within`, so any focusable child\n * counts.\n *\n * `clearable` and `loading` draw a clear (×) button and a spinner after the\n * field, before any `[wrInputSuffix]` or `<wr-password-toggle>`. Both act on the\n * first `wrInput` the group wraps.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <span wrInputPrefix>$</span>\n * <input wrInput [(ngModel)]=\"amount\" type=\"number\" />\n * <span wrInputSuffix>USD</span>\n * </wr-input-group>\n *\n * <!-- a search box: a clear button, and a spinner while the lookup runs -->\n * <wr-input-group clearable [loading]=\"pending()\">\n * <input wrInput [(ngModel)]=\"query\" placeholder=\"Search\" />\n * </wr-input-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/input\n */\n@Component({\n selector: 'wr-input-group',\n templateUrl: './input-group.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-input-group', '[class]': 'classes()', '(input)': 'syncClear()' },\n imports: [WrSpinner],\n})\nexport class WrInputGroup {\n private readonly renderer = inject(Renderer2);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n\n // A native field's value is not a signal, and a model write (`ngModel`,\n // `[formField]`, a bound `[value]`) reaches it with no event. So the field\n // is read after every render, and on its own `input` events in between.\n afterEveryRender({ read: () => this.syncClear() });\n\n effect(() => {\n const field = this.field()?.nativeElement;\n if (!field) return;\n if (this.loading()) this.renderer.setAttribute(field, 'aria-busy', 'true');\n else this.renderer.removeAttribute(field, 'aria-busy');\n });\n }\n\n /** Pill-shaped corners. @default false */\n readonly rounded = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Show a clear (×) button while the field holds text and is neither disabled\n * nor read-only. Clearing empties the field through an `input` event, so\n * whatever is bound to it (`ngModel`, `[formField]`, an `(input)` listener)\n * hears it as an edit, and puts focus back in the field. It is a pointer\n * control: from the keyboard, emptying the field clears it. @default false\n */\n readonly clearable = input(false, { transform: coerceBooleanProperty });\n\n /** Clear (×) button aria-label. Falls back to `common.clear`. */\n readonly clearLabel = input<string | null>(null);\n\n /**\n * Show a spinner after the field and mark the field `aria-busy`. The field\n * stays editable. @default false\n */\n readonly loading = input(false, { transform: coerceBooleanProperty });\n\n /** Emitted after the clear (×) button emptied the field. */\n readonly cleared = output<void>();\n\n protected readonly resolvedClear = useI18nText(this.clearLabel, 'common.clear', 'Clear');\n\n private readonly field = contentChild<WrInput, ElementRef<HTMLInputElement | HTMLTextAreaElement>>(WrInput, {\n read: ElementRef,\n });\n\n /** Whether the field has text a user could clear right now. */\n private readonly fieldClearable = signal(false);\n\n protected readonly clearShown = computed(() => this.clearable() && this.fieldClearable());\n\n protected syncClear(): void {\n if (!this.clearable()) return;\n const field = this.field()?.nativeElement;\n this.fieldClearable.set(!!field && field.value !== '' && !field.disabled && !field.readOnly);\n }\n\n protected clear(): void {\n const field = this.field()?.nativeElement;\n if (!field || field.disabled || field.readOnly) return;\n field.value = '';\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.focus();\n this.cleared.emit();\n }\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.rounded()) parts.push('wr-input-group--rounded');\n return parts.join(' ');\n });\n}\n","<ng-content />\n<!-- Pointer-only, as the select's is: emptying the field is the keyboard way to clear. -->\n@if (clearShown()) {\n <span class=\"wr-input-group__clear\" role=\"button\" [attr.aria-label]=\"resolvedClear()\" tabindex=\"-1\" (click)=\"clear()\">\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} @else if (clearable()) {\n <!-- Holds the ×'s room while the field is empty, so clearing does not narrow the group. -->\n <span class=\"wr-input-group__clear-space\" aria-hidden=\"true\"></span>\n}\n<!-- Hidden from the accessibility tree: the field says it is busy with `aria-busy`. -->\n@if (loading()) {\n <wr-spinner class=\"wr-input-group__spinner\" size=\"sm\" aria-hidden=\"true\" />\n}\n<ng-content select=\"[wrInputSuffix], wr-password-toggle\" />\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 { Component, ViewEncapsulation, computed, input, signal } from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Self-contained eye-toggle button. Flips the linked `<input>`'s `type`\n * attribute between `password` and `text`. Drop it inside an\n * `<wr-input-group>` next to a password input.\n *\n * @example\n * ```html\n * <wr-input-group>\n * <input wrInput type=\"password\" [(ngModel)]=\"pw\" #pwInput />\n * <wr-password-toggle [for]=\"pwInput\" />\n * </wr-input-group>\n * ```\n */\n@Component({\n selector: 'wr-password-toggle',\n templateUrl: './password-toggle.html',\n encapsulation: ViewEncapsulation.None,\n})\nexport class WrPasswordToggle {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('input');\n }\n\n /** Reference to the linked password input. */\n readonly for = input.required<HTMLInputElement>();\n\n protected readonly revealed = signal(false);\n\n /** Accessible name while the password is hidden. Falls back to `input.showPassword`. */\n readonly showPasswordLabel = input<string | null>(null);\n\n /** Accessible name while the password is revealed. Falls back to `input.hidePassword`. */\n readonly hidePasswordLabel = input<string | null>(null);\n\n private readonly resolvedShowPasswordLabel = useI18nText(\n this.showPasswordLabel,\n 'input.showPassword',\n 'Show password'\n );\n private readonly resolvedHidePasswordLabel = useI18nText(\n this.hidePasswordLabel,\n 'input.hidePassword',\n 'Hide password'\n );\n\n protected readonly ariaLabel = computed(() =>\n this.revealed() ? this.resolvedHidePasswordLabel() : this.resolvedShowPasswordLabel()\n );\n\n protected toggle(): void {\n const input = this.for();\n const next = input.type === 'password' ? 'text' : 'password';\n input.type = next;\n this.revealed.set(next === 'text');\n }\n}\n","<button type=\"button\" class=\"wr-input-group__toggle\" [attr.aria-label]=\"ariaLabel()\" (click)=\"toggle()\">\n @if (revealed()) {\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=\"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49\" />\n <path d=\"M14.084 14.158a3 3 0 0 1-4.242-4.242\" />\n <path d=\"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143\" />\n <path d=\"m2 2 20 20\" />\n </svg>\n } @else {\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=\"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n }\n</button>\n"],"mappings":";;;;;;;;;;;;;AA+CA,IAAa,UAAb,MAAa,QAAO;CACD,OAAO,OAAgC,UAAU;CACjD,QAAQ,OAAO,eAAe,EAAE,UAAU,KAAI,CAAE;CAOhD,QAAQ,KAAK,KAAK,cAAc,aAAa,IAAI;CAO/C,aAAa,eAAe,KAAK,SAAS,KAAK,OAAO,UAAS,KAAM,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAE7F,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,OAAO;EAIxE,IAAI,KAAK,OAAO,KAAK,OAAO,eAAe,KAAK,KAAK;CACvD;CAeiB,YAAY,iBAAgB;CAC1B,cAAc,KAAK,UAAU;CAC7B,cAAc,KAAK,UAAU;CAG/B,kBAAkB,KAAK,KAAK,cAAc,aAAa,eAAe;CAM7E,eAAY;EACpB,IAAI,KAAK,oBAAoB,MAAM,OAAO,KAAK;EAC/C,IAAK,KAAK,KAAK,cAAmC,UAAU,OAAO;EACnE,OAAO,KAAK,UAAU,aAAY;CACpC;CAaS,OAAO,MAAmB,MAAK,GAAA,YAAA,CAAA,EAAA,WAA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B;EAmCA,eAAA,GAAA,kBAAA;CAAA,CAAA;;ADLa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgB,YAAA,CAAA;EAL5B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAoB,eAEf,kBAAkB;GAAI,UAAA;EAAA,CAAA"}
|
package/fesm2022/ngwr-knob.mjs
CHANGED
|
@@ -108,6 +108,11 @@ var WrKnob = class WrKnob {
|
|
|
108
108
|
}
|
|
109
109
|
onPointerMove(event) {
|
|
110
110
|
if (!this.dragging) return;
|
|
111
|
+
if (!this.interactive()) {
|
|
112
|
+
this.dragging = false;
|
|
113
|
+
this.touch.emit();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
111
116
|
this.updateFromPointer(event);
|
|
112
117
|
}
|
|
113
118
|
onPointerUp(event) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-knob.mjs","names":[],"sources":["../../../projects/lib/knob/knob.ts","../../../projects/lib/knob/knob.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n ElementRef,\n ViewEncapsulation,\n computed,\n inject,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrClamp, wrRound, wrCheckStyles } from 'ngwr/utils';\n\nconst ARC_START = -135; // 7 o'clock\nconst ARC_END = 135; // 5 o'clock — 270° sweep total\nconst ARC_SWEEP = ARC_END - ARC_START;\n\n/**\n * Radial dial input. A signal-forms native control: it implements\n * `FormValueControl<number>`, so `[formField]` binds straight to its `value`\n * model — no `ControlValueAccessor` in between. `[(value)]` works standalone.\n *\n * The dial shows the value clamped to `[min, max]`, and a drag or a key press\n * commits one in range; a value written from outside stays as it was. Drag the\n * indicator around the dial or use ←→ / ↑↓ to step.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-knob [formField]=\"form.volume\" [min]=\"0\" [max]=\"100\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-knob [(value)]=\"vol\" suffix=\"%\" valueColor=\"var(--wr-color-success)\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/knob\n */\n@Component({\n selector: 'wr-knob',\n templateUrl: './knob.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-knob', '[class]': 'classes()' },\n})\nexport class WrKnob implements FormValueControl<number> {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('knob');\n }\n\n /** Accessible name — the role needs one. Falls back to `knob.label`. */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'knob.label', 'Value');\n\n /** Minimum allowed value. @default 0 */\n readonly min = input<number | undefined>(0, { transform: (v: unknown): number => coerceNumberProperty(v, 0) });\n\n /** Maximum allowed value. @default 100 */\n readonly max = input<number | undefined>(100, { transform: (v: unknown): number => coerceNumberProperty(v, 100) });\n\n private readonly minValue = computed(() => this.min() ?? 0);\n private readonly maxValue = computed(() => this.max() ?? 100);\n\n /** Step granularity. @default 1 */\n readonly step = input(1, { transform: (v: unknown): number => Math.max(0.0001, coerceNumberProperty(v, 1)) });\n\n /** Dial diameter in CSS pixels. @default 120 */\n readonly size = input(120, { transform: (v: unknown): number => Math.max(32, coerceNumberProperty(v, 120)) });\n\n /** Stroke width of the dial arc, in CSS pixels. @default 8 */\n readonly strokeWidth = input(8, {\n transform: (v: unknown): number => Math.max(1, coerceNumberProperty(v, 8)),\n });\n\n /** Track (unfilled) color. @default color-mix(in srgb, var(--wr-border-base) 60%, transparent) */\n readonly trackColor = input<string>('color-mix(in srgb, var(--wr-border-base) 60%, transparent)');\n\n /** Filled-arc color. @default var(--wr-color-primary) */\n readonly valueColor = input<string>('var(--wr-color-primary)');\n\n /** Show the value text in the center. @default true */\n readonly showValue = input(true, { transform: coerceBooleanProperty });\n\n /** Optional suffix appended to the center text (e.g. `'%'`). */\n readonly suffix = input<string>('');\n\n /** Read-only — disables interaction but keeps the visual. @default false */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** Disable interaction. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Bound by `[formField]`, or two-way via `[(value)]`. */\n readonly value = model<number>(0);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n private dragging = false;\n\n protected readonly interactive = computed(() => !this.disabled() && !this.readonly());\n\n /**\n * Whether the control keeps its tab stop — `disabled` only, never `readonly`.\n *\n * The two states differ precisely here: a disabled control leaves the tab\n * order, a read-only one stays in it and keeps announcing `aria-valuenow`,\n * because a keyboard user still has to be able to READ a value they cannot\n * change. Driving `tabindex` off `interactive()` collapsed that distinction\n * and made `readonly()` unreachable — with an `aria-describedby` pointing at\n * an error message on an element nobody could focus.\n */\n protected readonly focusable = computed(() => !this.disabled());\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /**\n * The field's label wins over the built-in default, and an explicit\n * `ariaLabel` wins over both.\n *\n * `<wr-form-field label=\"…\">` renders a `<label for>` that cannot reach this\n * control — `for` binds only to a LABELABLE element and the focusable part\n * here carries a role instead — so the field's label named nothing and this\n * announced its own generic default. A consumer who wrote\n * `<wr-form-field label=\"Overall satisfaction\">` heard \"Value\".\n */\n protected readonly labelledBy = computed(() => (this.ariaLabel() ? null : this.fieldAria.labelledBy()));\n\n /** `null` once `aria-labelledby` is carrying the name, or the two are announced together. */\n protected readonly nameLabel = computed(() => (this.labelledBy() ? null : this.resolvedAriaLabel()));\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.disabled()) parts.push('wr-knob--disabled');\n if (this.readonly()) parts.push('wr-knob--readonly');\n return parts.join(' ');\n });\n\n // Geometry — drawn into a 100×100 viewBox, scaled by `size`.\n protected readonly cx = 50;\n protected readonly cy = 50;\n // A negative radius is invalid in the SVG path grammar, so the browser drops\n // the arc and the dial vanishes — which a fat stroke reaches at 99.\n protected readonly radius = computed(() => Math.max(1, 50 - this.strokeWidth() / 2 - 0.5));\n\n /**\n * The value the dial shows and announces: the model, held to `[min, max]`.\n * Only the display is clamped. Writing the clamped number back into the model\n * turned a form's out-of-range value into a different one and marked the\n * field dirty before anyone touched it — the rule `wr-input-number` and\n * `wr-slider` already follow. A key press or a drag commits a value in range.\n */\n protected readonly shown = computed(() => wrClamp(this.value(), this.minValue(), this.maxValue()));\n\n /** Ratio of the filled arc — `0` at min, `1` at max. */\n protected readonly ratio = computed(() => {\n const range = this.maxValue() - this.minValue();\n if (range <= 0) return 0;\n return (this.shown() - this.minValue()) / range;\n });\n\n /** SVG path `d` for the background arc. */\n protected readonly trackPath = computed(() => this.arcPath(ARC_START, ARC_END));\n\n /** SVG path `d` for the filled arc. */\n protected readonly valuePath = computed(() => {\n const end = ARC_START + ARC_SWEEP * this.ratio();\n return this.arcPath(ARC_START, end);\n });\n\n /** Position of the handle dot — `{ x, y }` in viewBox units. */\n protected readonly handlePos = computed(() => {\n const angle = ARC_START + ARC_SWEEP * this.ratio();\n const rad = (angle * Math.PI) / 180;\n return {\n x: this.cx + this.radius() * Math.sin(rad),\n y: this.cy - this.radius() * Math.cos(rad),\n };\n });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly surface = viewChild.required<ElementRef<HTMLElement>>('surface');\n\n /**\n * Focus the dial — what Signal Forms calls to focus this control, from\n * `focusBoundControl()`. The host carries no tab stop, so the call goes to\n * the `role=\"slider\"` surface. A disabled dial is left alone: its surface\n * keeps `tabindex=\"-1\"`, which a script could still focus, and a disabled\n * native control refuses the same call.\n */\n focus(options?: FocusOptions): void {\n if (this.focusable()) this.surface().nativeElement.focus(options);\n }\n\n // Pointer / keyboard\n\n protected onPointerDown(event: PointerEvent): void {\n if (!this.interactive()) return;\n // Any pointerdown used to start a drag, so the right button turned the dial;\n // the same guard keeps a second finger out of a drag already in progress.\n if (event.button !== 0 || !event.isPrimary) return;\n event.preventDefault();\n this.dragging = true;\n const surface = event.currentTarget as HTMLElement;\n surface.setPointerCapture(event.pointerId);\n // `preventDefault` above also suppresses the click's default focus, so the\n // arrows did nothing after a mouse drag until the dial was found again with\n // Tab. `wr-slider` focuses its thumb for the same reason.\n surface.focus();\n this.updateFromPointer(event);\n }\n\n protected onPointerMove(event: PointerEvent): void {\n if (!this.dragging) return;\n this.updateFromPointer(event);\n }\n\n protected onPointerUp(event: PointerEvent): void {\n if (!this.dragging) return;\n this.dragging = false;\n (event.currentTarget as HTMLElement).releasePointerCapture(event.pointerId);\n this.touch.emit();\n }\n\n /**\n * A bound field learns it may show its validation copy from `touch`, and\n * pointer-up cannot be the only source: a knob reached by Tab and moved with\n * the arrows would leave the field untouched forever. `wr-rating`, whose\n * template this one otherwise mirrors, emits on blur for exactly this reason.\n */\n protected onBlur(): void {\n this.touch.emit();\n }\n\n /**\n * The APG slider keys, and they do NOT mirror under `dir=\"rtl\"` — which is a\n * decision, not an oversight, and the one place it is written down.\n *\n * `wr-slider` swaps ArrowLeft and ArrowRight in RTL because its TRACK mirrors:\n * the thumb is placed with `inset-inline-start`, so the visual maximum moves to\n * the left and a key naming a side has to move with it. This dial does not\n * mirror. It is an SVG gauge drawn in a fixed 100×100 viewBox, and SVG content\n * is not reordered by the reading direction — the arc sweeps clockwise from 7\n * o'clock to 5 o'clock in every locale, the same way a clock face or a car's\n * rev counter does. So ArrowRight still moves the handle toward the visually\n * right-hand side of the arc in RTL, and swapping the keys would be the thing\n * that broke the mapping.\n *\n * That is why nothing here injects `Directionality`: there is no physical CSS\n * in the value path at all, only fixed SVG geometry.\n */\n protected onKeydown(event: KeyboardEvent): void {\n if (!this.interactive()) return;\n const step = event.shiftKey ? this.step() * 10 : this.step();\n let next: number | null;\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowUp':\n next = this.shown() + step;\n break;\n case 'ArrowLeft':\n case 'ArrowDown':\n next = this.shown() - step;\n break;\n case 'Home':\n next = this.minValue();\n break;\n case 'End':\n next = this.maxValue();\n break;\n default:\n return;\n }\n event.preventDefault();\n this.commit(this.snap(next));\n }\n\n /**\n * Nearest step, measured FROM `min`. A grid anchored at zero offers values the\n * arrows can never reach whenever `min` is not a multiple of `step` — with\n * `min: 5, step: 10` the middle of the arc used to commit 60, off a grid whose\n * points are 5, 15, … 55, 65. Rounded at six decimals because a tenth is not a\n * binary fraction: three arrow presses at `step: 0.1` otherwise announce\n * `aria-valuenow=\"0.30000000000000004\"` and print it in the dial. Same shape as\n * `wr-slider`'s `snap`, deliberately — including Home / End, so a range that is\n * not a whole number of steps stops at the last reachable value.\n */\n private snap(value: number): number {\n const min = this.minValue();\n const stepped = Math.round((value - min) / this.step()) * this.step() + min;\n return wrClamp(wrRound(stepped, 6), min, this.maxValue());\n }\n\n // Internals\n\n private updateFromPointer(event: PointerEvent): void {\n const rect = this.host.nativeElement.getBoundingClientRect();\n const dx = event.clientX - (rect.left + rect.width / 2);\n const dy = event.clientY - (rect.top + rect.height / 2);\n // Angle measured from 12 o'clock, clockwise.\n let angle = (Math.atan2(dx, -dy) * 180) / Math.PI;\n // Map [-180, 180] into the dial's arc range, clamping outside it.\n if (angle < ARC_START) angle = angle + 360 > ARC_END ? ARC_START : angle + 360;\n angle = wrClamp(angle, ARC_START, ARC_END);\n const ratio = (angle - ARC_START) / ARC_SWEEP;\n const range = this.maxValue() - this.minValue();\n const raw = this.minValue() + ratio * range;\n this.commit(this.snap(raw));\n }\n\n private commit(next: number): void {\n if (next === this.value()) return;\n this.value.set(next);\n }\n\n // Arc helper\n\n private arcPath(startDeg: number, endDeg: number): string {\n const r = this.radius();\n const s = (startDeg * Math.PI) / 180;\n const e = (endDeg * Math.PI) / 180;\n const sx = this.cx + r * Math.sin(s);\n const sy = this.cy - r * Math.cos(s);\n const ex = this.cx + r * Math.sin(e);\n const ey = this.cy - r * Math.cos(e);\n const largeArc = endDeg - startDeg > 180 ? 1 : 0;\n return `M ${sx} ${sy} A ${r} ${r} 0 ${largeArc} 1 ${ex} ${ey}`;\n }\n}\n","<div\n #surface\n class=\"wr-knob__surface\"\n role=\"slider\"\n [attr.aria-label]=\"nameLabel()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-valuemin]=\"min()\"\n [attr.aria-valuemax]=\"max()\"\n [attr.aria-valuenow]=\"shown()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n [attr.tabindex]=\"focusable() ? 0 : -1\"\n [style.width.px]=\"size()\"\n [style.height.px]=\"size()\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (keydown)=\"onKeydown($event)\"\n (blur)=\"onBlur()\"\n>\n <svg viewBox=\"0 0 100 100\" aria-hidden=\"true\">\n <path\n class=\"wr-knob__track\"\n [attr.d]=\"trackPath()\"\n [attr.stroke]=\"trackColor()\"\n [attr.stroke-width]=\"strokeWidth()\"\n fill=\"none\"\n stroke-linecap=\"round\"\n />\n <path\n class=\"wr-knob__value\"\n [attr.d]=\"valuePath()\"\n [attr.stroke]=\"valueColor()\"\n [attr.stroke-width]=\"strokeWidth()\"\n fill=\"none\"\n stroke-linecap=\"round\"\n />\n <circle\n class=\"wr-knob__handle\"\n [attr.cx]=\"handlePos().x\"\n [attr.cy]=\"handlePos().y\"\n [attr.r]=\"strokeWidth() / 2\"\n [attr.fill]=\"valueColor()\"\n />\n </svg>\n @if (showValue()) {\n <!--\n `dir=\"auto\"` because this is a number and a unit read as one phrase, and\n the browser is the only thing that knows which way that phrase runs. In an\n RTL paragraph the Unicode BiDi algorithm treats a digit run as neutral\n against the letters beside it, so `40 dB` was drawn `dB 40` — and `-5 dB`\n as `dB 5-`, with the sign on the wrong end of the number. `dir=\"auto\"`\n picks the direction from the first strong character in the composed text,\n so a Latin `suffix` keeps the number first and an Arabic one reads\n right-to-left, which is correct for both.\n\n `unicode-bidi: isolate` does NOT fix this and was measured doing nothing:\n isolation seals the element off from its SURROUNDINGS, and the flip\n happens inside it.\n -->\n <div class=\"wr-knob__text\" dir=\"auto\">\n {{ shown() }}<span class=\"wr-knob__suffix\">{{ suffix() }}</span>\n </div>\n }\n</div>\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,YAAY;AAClB,MAAM,UAAU;AAChB,MAAM,YAAY;AA4BlB,IAAa,SAAb,MAAa,OAAM;CACjB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,MAAM;CACzE;CAGS,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,oBAAoB,YAAY,KAAK,WAAW,cAAc,OAAO;CAG/E,MAAM,MAA0B,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,MAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,CAAC;CAAC,CAAA;CAGlG,MAAM,MAA0B,KAAG;EAAA,GAAA,YAAA,EAAA,WAAA,MAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,GAAG;CAAC,CAAA;CAE9F,WAAW,eAAe,KAAK,IAAG,KAAM,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAC1C,WAAW,eAAe,KAAK,IAAG,KAAM,KAAI,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAGpD,OAAO,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,OAAA,+BAAA,CAAA;EAAI,YAAY,M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GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,WAAS,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-knob.mjs","names":[],"sources":["../../../projects/lib/knob/knob.ts","../../../projects/lib/knob/knob.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n ElementRef,\n ViewEncapsulation,\n computed,\n inject,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrClamp, wrRound, wrCheckStyles } from 'ngwr/utils';\n\nconst ARC_START = -135; // 7 o'clock\nconst ARC_END = 135; // 5 o'clock — 270° sweep total\nconst ARC_SWEEP = ARC_END - ARC_START;\n\n/**\n * Radial dial input. A signal-forms native control: it implements\n * `FormValueControl<number>`, so `[formField]` binds straight to its `value`\n * model — no `ControlValueAccessor` in between. `[(value)]` works standalone.\n *\n * The dial shows the value clamped to `[min, max]`, and a drag or a key press\n * commits one in range; a value written from outside stays as it was. Drag the\n * indicator around the dial or use ←→ / ↑↓ to step.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-knob [formField]=\"form.volume\" [min]=\"0\" [max]=\"100\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-knob [(value)]=\"vol\" suffix=\"%\" valueColor=\"var(--wr-color-success)\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/knob\n */\n@Component({\n selector: 'wr-knob',\n templateUrl: './knob.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-knob', '[class]': 'classes()' },\n})\nexport class WrKnob implements FormValueControl<number> {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('knob');\n }\n\n /** Accessible name — the role needs one. Falls back to `knob.label`. */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'knob.label', 'Value');\n\n /** Minimum allowed value. @default 0 */\n readonly min = input<number | undefined>(0, { transform: (v: unknown): number => coerceNumberProperty(v, 0) });\n\n /** Maximum allowed value. @default 100 */\n readonly max = input<number | undefined>(100, { transform: (v: unknown): number => coerceNumberProperty(v, 100) });\n\n private readonly minValue = computed(() => this.min() ?? 0);\n private readonly maxValue = computed(() => this.max() ?? 100);\n\n /** Step granularity. @default 1 */\n readonly step = input(1, { transform: (v: unknown): number => Math.max(0.0001, coerceNumberProperty(v, 1)) });\n\n /** Dial diameter in CSS pixels. @default 120 */\n readonly size = input(120, { transform: (v: unknown): number => Math.max(32, coerceNumberProperty(v, 120)) });\n\n /** Stroke width of the dial arc, in CSS pixels. @default 8 */\n readonly strokeWidth = input(8, {\n transform: (v: unknown): number => Math.max(1, coerceNumberProperty(v, 8)),\n });\n\n /** Track (unfilled) color. @default color-mix(in srgb, var(--wr-border-base) 60%, transparent) */\n readonly trackColor = input<string>('color-mix(in srgb, var(--wr-border-base) 60%, transparent)');\n\n /** Filled-arc color. @default var(--wr-color-primary) */\n readonly valueColor = input<string>('var(--wr-color-primary)');\n\n /** Show the value text in the center. @default true */\n readonly showValue = input(true, { transform: coerceBooleanProperty });\n\n /** Optional suffix appended to the center text (e.g. `'%'`). */\n readonly suffix = input<string>('');\n\n /** Read-only — disables interaction but keeps the visual. @default false */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** Disable interaction. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Bound by `[formField]`, or two-way via `[(value)]`. */\n readonly value = model<number>(0);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n private dragging = false;\n\n protected readonly interactive = computed(() => !this.disabled() && !this.readonly());\n\n /**\n * Whether the control keeps its tab stop — `disabled` only, never `readonly`.\n *\n * The two states differ precisely here: a disabled control leaves the tab\n * order, a read-only one stays in it and keeps announcing `aria-valuenow`,\n * because a keyboard user still has to be able to READ a value they cannot\n * change. Driving `tabindex` off `interactive()` collapsed that distinction\n * and made `readonly()` unreachable — with an `aria-describedby` pointing at\n * an error message on an element nobody could focus.\n */\n protected readonly focusable = computed(() => !this.disabled());\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /**\n * The field's label wins over the built-in default, and an explicit\n * `ariaLabel` wins over both.\n *\n * `<wr-form-field label=\"…\">` renders a `<label for>` that cannot reach this\n * control — `for` binds only to a LABELABLE element and the focusable part\n * here carries a role instead — so the field's label named nothing and this\n * announced its own generic default. A consumer who wrote\n * `<wr-form-field label=\"Overall satisfaction\">` heard \"Value\".\n */\n protected readonly labelledBy = computed(() => (this.ariaLabel() ? null : this.fieldAria.labelledBy()));\n\n /** `null` once `aria-labelledby` is carrying the name, or the two are announced together. */\n protected readonly nameLabel = computed(() => (this.labelledBy() ? null : this.resolvedAriaLabel()));\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.disabled()) parts.push('wr-knob--disabled');\n if (this.readonly()) parts.push('wr-knob--readonly');\n return parts.join(' ');\n });\n\n // Geometry — drawn into a 100×100 viewBox, scaled by `size`.\n protected readonly cx = 50;\n protected readonly cy = 50;\n // A negative radius is invalid in the SVG path grammar, so the browser drops\n // the arc and the dial vanishes — which a fat stroke reaches at 99.\n protected readonly radius = computed(() => Math.max(1, 50 - this.strokeWidth() / 2 - 0.5));\n\n /**\n * The value the dial shows and announces: the model, held to `[min, max]`.\n * Only the display is clamped. Writing the clamped number back into the model\n * turned a form's out-of-range value into a different one and marked the\n * field dirty before anyone touched it — the rule `wr-input-number` and\n * `wr-slider` already follow. A key press or a drag commits a value in range.\n */\n protected readonly shown = computed(() => wrClamp(this.value(), this.minValue(), this.maxValue()));\n\n /** Ratio of the filled arc — `0` at min, `1` at max. */\n protected readonly ratio = computed(() => {\n const range = this.maxValue() - this.minValue();\n if (range <= 0) return 0;\n return (this.shown() - this.minValue()) / range;\n });\n\n /** SVG path `d` for the background arc. */\n protected readonly trackPath = computed(() => this.arcPath(ARC_START, ARC_END));\n\n /** SVG path `d` for the filled arc. */\n protected readonly valuePath = computed(() => {\n const end = ARC_START + ARC_SWEEP * this.ratio();\n return this.arcPath(ARC_START, end);\n });\n\n /** Position of the handle dot — `{ x, y }` in viewBox units. */\n protected readonly handlePos = computed(() => {\n const angle = ARC_START + ARC_SWEEP * this.ratio();\n const rad = (angle * Math.PI) / 180;\n return {\n x: this.cx + this.radius() * Math.sin(rad),\n y: this.cy - this.radius() * Math.cos(rad),\n };\n });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly surface = viewChild.required<ElementRef<HTMLElement>>('surface');\n\n /**\n * Focus the dial — what Signal Forms calls to focus this control, from\n * `focusBoundControl()`. The host carries no tab stop, so the call goes to\n * the `role=\"slider\"` surface. A disabled dial is left alone: its surface\n * keeps `tabindex=\"-1\"`, which a script could still focus, and a disabled\n * native control refuses the same call.\n */\n focus(options?: FocusOptions): void {\n if (this.focusable()) this.surface().nativeElement.focus(options);\n }\n\n // Pointer / keyboard\n\n protected onPointerDown(event: PointerEvent): void {\n if (!this.interactive()) return;\n // Any pointerdown used to start a drag, so the right button turned the dial;\n // the same guard keeps a second finger out of a drag already in progress.\n if (event.button !== 0 || !event.isPrimary) return;\n event.preventDefault();\n this.dragging = true;\n const surface = event.currentTarget as HTMLElement;\n surface.setPointerCapture(event.pointerId);\n // `preventDefault` above also suppresses the click's default focus, so the\n // arrows did nothing after a mouse drag until the dial was found again with\n // Tab. `wr-slider` focuses its thumb for the same reason.\n surface.focus();\n this.updateFromPointer(event);\n }\n\n protected onPointerMove(event: PointerEvent): void {\n if (!this.dragging) return;\n // Turned disabled or readonly mid-drag: the gesture is over.\n // The value may already have moved on pointerdown, so the field still hears `touch`.\n if (!this.interactive()) {\n this.dragging = false;\n this.touch.emit();\n return;\n }\n this.updateFromPointer(event);\n }\n\n protected onPointerUp(event: PointerEvent): void {\n if (!this.dragging) return;\n this.dragging = false;\n (event.currentTarget as HTMLElement).releasePointerCapture(event.pointerId);\n this.touch.emit();\n }\n\n /**\n * A bound field learns it may show its validation copy from `touch`, and\n * pointer-up cannot be the only source: a knob reached by Tab and moved with\n * the arrows would leave the field untouched forever. `wr-rating`, whose\n * template this one otherwise mirrors, emits on blur for exactly this reason.\n */\n protected onBlur(): void {\n this.touch.emit();\n }\n\n /**\n * The APG slider keys, and they do NOT mirror under `dir=\"rtl\"` — which is a\n * decision, not an oversight, and the one place it is written down.\n *\n * `wr-slider` swaps ArrowLeft and ArrowRight in RTL because its TRACK mirrors:\n * the thumb is placed with `inset-inline-start`, so the visual maximum moves to\n * the left and a key naming a side has to move with it. This dial does not\n * mirror. It is an SVG gauge drawn in a fixed 100×100 viewBox, and SVG content\n * is not reordered by the reading direction — the arc sweeps clockwise from 7\n * o'clock to 5 o'clock in every locale, the same way a clock face or a car's\n * rev counter does. So ArrowRight still moves the handle toward the visually\n * right-hand side of the arc in RTL, and swapping the keys would be the thing\n * that broke the mapping.\n *\n * That is why nothing here injects `Directionality`: there is no physical CSS\n * in the value path at all, only fixed SVG geometry.\n */\n protected onKeydown(event: KeyboardEvent): void {\n if (!this.interactive()) return;\n const step = event.shiftKey ? this.step() * 10 : this.step();\n let next: number | null;\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowUp':\n next = this.shown() + step;\n break;\n case 'ArrowLeft':\n case 'ArrowDown':\n next = this.shown() - step;\n break;\n case 'Home':\n next = this.minValue();\n break;\n case 'End':\n next = this.maxValue();\n break;\n default:\n return;\n }\n event.preventDefault();\n this.commit(this.snap(next));\n }\n\n /**\n * Nearest step, measured FROM `min`. A grid anchored at zero offers values the\n * arrows can never reach whenever `min` is not a multiple of `step` — with\n * `min: 5, step: 10` the middle of the arc used to commit 60, off a grid whose\n * points are 5, 15, … 55, 65. Rounded at six decimals because a tenth is not a\n * binary fraction: three arrow presses at `step: 0.1` otherwise announce\n * `aria-valuenow=\"0.30000000000000004\"` and print it in the dial. Same shape as\n * `wr-slider`'s `snap`, deliberately — including Home / End, so a range that is\n * not a whole number of steps stops at the last reachable value.\n */\n private snap(value: number): number {\n const min = this.minValue();\n const stepped = Math.round((value - min) / this.step()) * this.step() + min;\n return wrClamp(wrRound(stepped, 6), min, this.maxValue());\n }\n\n // Internals\n\n private updateFromPointer(event: PointerEvent): void {\n const rect = this.host.nativeElement.getBoundingClientRect();\n const dx = event.clientX - (rect.left + rect.width / 2);\n const dy = event.clientY - (rect.top + rect.height / 2);\n // Angle measured from 12 o'clock, clockwise.\n let angle = (Math.atan2(dx, -dy) * 180) / Math.PI;\n // Map [-180, 180] into the dial's arc range, clamping outside it.\n if (angle < ARC_START) angle = angle + 360 > ARC_END ? ARC_START : angle + 360;\n angle = wrClamp(angle, ARC_START, ARC_END);\n const ratio = (angle - ARC_START) / ARC_SWEEP;\n const range = this.maxValue() - this.minValue();\n const raw = this.minValue() + ratio * range;\n this.commit(this.snap(raw));\n }\n\n private commit(next: number): void {\n if (next === this.value()) return;\n this.value.set(next);\n }\n\n // Arc helper\n\n private arcPath(startDeg: number, endDeg: number): string {\n const r = this.radius();\n const s = (startDeg * Math.PI) / 180;\n const e = (endDeg * Math.PI) / 180;\n const sx = this.cx + r * Math.sin(s);\n const sy = this.cy - r * Math.cos(s);\n const ex = this.cx + r * Math.sin(e);\n const ey = this.cy - r * Math.cos(e);\n const largeArc = endDeg - startDeg > 180 ? 1 : 0;\n return `M ${sx} ${sy} A ${r} ${r} 0 ${largeArc} 1 ${ex} ${ey}`;\n }\n}\n","<div\n #surface\n class=\"wr-knob__surface\"\n role=\"slider\"\n [attr.aria-label]=\"nameLabel()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-valuemin]=\"min()\"\n [attr.aria-valuemax]=\"max()\"\n [attr.aria-valuenow]=\"shown()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n [attr.tabindex]=\"focusable() ? 0 : -1\"\n [style.width.px]=\"size()\"\n [style.height.px]=\"size()\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (keydown)=\"onKeydown($event)\"\n (blur)=\"onBlur()\"\n>\n <svg viewBox=\"0 0 100 100\" aria-hidden=\"true\">\n <path\n class=\"wr-knob__track\"\n [attr.d]=\"trackPath()\"\n [attr.stroke]=\"trackColor()\"\n [attr.stroke-width]=\"strokeWidth()\"\n fill=\"none\"\n stroke-linecap=\"round\"\n />\n <path\n class=\"wr-knob__value\"\n [attr.d]=\"valuePath()\"\n [attr.stroke]=\"valueColor()\"\n [attr.stroke-width]=\"strokeWidth()\"\n fill=\"none\"\n stroke-linecap=\"round\"\n />\n <circle\n class=\"wr-knob__handle\"\n [attr.cx]=\"handlePos().x\"\n [attr.cy]=\"handlePos().y\"\n [attr.r]=\"strokeWidth() / 2\"\n [attr.fill]=\"valueColor()\"\n />\n </svg>\n @if (showValue()) {\n <!--\n `dir=\"auto\"` because this is a number and a unit read as one phrase, and\n the browser is the only thing that knows which way that phrase runs. In an\n RTL paragraph the Unicode BiDi algorithm treats a digit run as neutral\n against the letters beside it, so `40 dB` was drawn `dB 40` — and `-5 dB`\n as `dB 5-`, with the sign on the wrong end of the number. `dir=\"auto\"`\n picks the direction from the first strong character in the composed text,\n so a Latin `suffix` keeps the number first and an Arabic one reads\n right-to-left, which is correct for both.\n\n `unicode-bidi: isolate` does NOT fix this and was measured doing nothing:\n isolation seals the element off from its SURROUNDINGS, and the flip\n happens inside it.\n -->\n <div class=\"wr-knob__text\" dir=\"auto\">\n {{ shown() }}<span class=\"wr-knob__suffix\">{{ suffix() }}</span>\n </div>\n }\n</div>\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,YAAY;AAClB,MAAM,UAAU;AAChB,MAAM,YAAY;AA4BlB,IAAa,SAAb,MAAa,OAAM;CACjB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,MAAM;CACzE;CAGS,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,oBAAoB,YAAY,KAAK,WAAW,cAAc,OAAO;CAG/E,MAAM,MAA0B,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,MAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,CAAC;CAAC,CAAA;CAGlG,MAAM,MAA0B,KAAG;EAAA,GAAA,YAAA,EAAA,WAAA,MAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,GAAG;CAAC,CAAA;CAE9F,WAAW,eAAe,KAAK,IAAG,KAAM,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAC1C,WAAW,eAAe,KAAK,IAAG,KAAM,KAAI,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAGpD,OAAO,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,OAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,KAAK,IAAI,MAAQ,qBAAqB,GAAG,CAAC,CAAC;CAAC,CAAA;CAGjG,OAAO,MAAM,KAAG;EAAA,GAAA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GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,WAAS,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -2,12 +2,12 @@ import * as i0 from "@angular/core";
|
|
|
2
2
|
import { Component, DestroyRef, ElementRef, EnvironmentInjector, Injector, PLATFORM_ID, Service, ViewContainerRef, ViewEncapsulation, computed, effect, inject, input, signal, untracked, viewChild } from "@angular/core";
|
|
3
3
|
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
|
4
4
|
import { isPlatformBrowser } from "@angular/common";
|
|
5
|
-
import { wrRestoreFocus, wrToClassList } from "ngwr/utils";
|
|
5
|
+
import { wrIsComposing, wrRestoreFocus, wrToClassList } from "ngwr/utils";
|
|
6
6
|
import { useI18nFormatter, useI18nText } from "ngwr/i18n";
|
|
7
7
|
import { Directionality } from "@angular/cdk/bidi";
|
|
8
8
|
import { TemplatePortal } from "@angular/cdk/portal";
|
|
9
9
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
10
|
-
import { WR_OVERLAY, wrFocusOverlay, wrFollowDirection } from "ngwr/overlay";
|
|
10
|
+
import { WR_OVERLAY, WrScrollBlock, wrFocusOverlay, wrFollowDirection } from "ngwr/overlay";
|
|
11
11
|
import { ConfigurableFocusTrapFactory, FocusMonitor } from "@angular/cdk/a11y";
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
@@ -119,6 +119,7 @@ var WrLightbox = class WrLightbox {
|
|
|
119
119
|
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
120
120
|
focusMonitor = inject(FocusMonitor);
|
|
121
121
|
overlay = inject(WR_OVERLAY);
|
|
122
|
+
scrollBlock = inject(WrScrollBlock);
|
|
122
123
|
vcr = inject(ViewContainerRef);
|
|
123
124
|
destroyRef = inject(DestroyRef);
|
|
124
125
|
injector = inject(Injector);
|
|
@@ -269,7 +270,7 @@ var WrLightbox = class WrLightbox {
|
|
|
269
270
|
hasBackdrop: true,
|
|
270
271
|
backdropClass: "wr-lightbox-backdrop",
|
|
271
272
|
positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),
|
|
272
|
-
scrollStrategy: this.
|
|
273
|
+
scrollStrategy: this.scrollBlock.strategy(),
|
|
273
274
|
panelClass: wrToClassList("wr-lightbox-overlay", this.panelClass())
|
|
274
275
|
});
|
|
275
276
|
wrFollowDirection(this.overlayRef, this.dir, this.injector);
|
|
@@ -282,6 +283,7 @@ var WrLightbox = class WrLightbox {
|
|
|
282
283
|
wrFocusOverlay(pane.querySelector(".wr-lightbox-viewer") ?? pane, this.focusTrap, this.autoFocus(), this.injector);
|
|
283
284
|
this.overlayRef.backdropClick().pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.open.set(false));
|
|
284
285
|
this.overlayRef.keydownEvents().pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
|
|
286
|
+
if (wrIsComposing(event)) return;
|
|
285
287
|
if (event.key === "Escape") {
|
|
286
288
|
event.preventDefault();
|
|
287
289
|
this.open.set(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-lightbox.mjs","names":[],"sources":["../../../projects/lib/lightbox/lightbox-groups.ts","../../../projects/lib/lightbox/lightbox.ts","../../../projects/lib/lightbox/lightbox.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Service, signal, type WritableSignal } from '@angular/core';\n\nimport type { WrLightbox } from './lightbox';\n\ninterface Entry {\n readonly member: WrLightbox;\n readonly host: HTMLElement;\n}\n\n/**\n * Every grouped `wr-lightbox`, keyed by its `group`.\n *\n * @internal\n */\n@Service()\nexport class WrLightboxGroups {\n private readonly groups = new Map<string, WritableSignal<readonly Entry[]>>();\n\n add(group: string, member: WrLightbox, host: HTMLElement): void {\n this.entries(group).update(list => [...list, { member, host }]);\n }\n\n remove(group: string, member: WrLightbox): void {\n const entries = this.entries(group);\n entries.update(list => list.filter(entry => entry.member !== member));\n if (!entries().length) this.groups.delete(group);\n }\n\n /**\n * Re-reads the order. Registration follows creation, and a member that only\n * MOVED in the document registers nothing, so the gallery asks again each\n * time it opens.\n */\n refresh(group: string): void {\n this.groups.get(group)?.update(list => [...list]);\n }\n\n /** The group's members in document order. */\n members(group: string): readonly WrLightbox[] {\n return [...this.entries(group)()]\n .sort((a, b) =>\n // eslint-disable-next-line no-bitwise -- compareDocumentPosition answers with a bitmask\n (a.host.compareDocumentPosition(b.host) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0 ? -1 : 1\n )\n .map(entry => entry.member);\n }\n\n private entries(group: string): WritableSignal<readonly Entry[]> {\n let entries = this.groups.get(group);\n if (!entries) {\n entries = signal<readonly Entry[]>([]);\n this.groups.set(group, entries);\n }\n return entries;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type ConfigurableFocusTrap, ConfigurableFocusTrapFactory, FocusMonitor } from '@angular/cdk/a11y';\nimport { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { type OverlayRef } from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport { isPlatformBrowser } from '@angular/common';\nimport type { Signal, TemplateRef } from '@angular/core';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n EnvironmentInjector,\n Injector,\n PLATFORM_ID,\n ViewContainerRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\nimport { WR_OVERLAY, type WrOverlayAutoFocus, wrFocusOverlay, wrFollowDirection } from 'ngwr/overlay';\nimport { wrToClassList, type WrClassInput, wrRestoreFocus } from 'ngwr/utils';\n\nimport { WrLightboxGroups } from './lightbox-groups';\n\n/** How far a horizontal swipe travels before it turns the page. */\nconst SWIPE_STEP_PX = 48;\n\nlet viewerUid = 0;\n\n/**\n * Image with click-to-zoom lightbox. The thumbnail is a plain `<img>`\n * with whatever sizing/`object-fit` you give it; clicking opens a CDK\n * overlay showing the full image, with Escape + close button + backdrop\n * to dismiss.\n *\n * Lightboxes that share a `group` form a gallery in document order: the viewer\n * gains previous and next buttons, a counter and the arrow keys.\n *\n * @example\n * ```html\n * <wr-lightbox\n * src=\"/photo.jpg\"\n * alt=\"Mountain\"\n * style=\"width: 16rem; height: 10rem; object-fit: cover\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/lightbox\n */\n@Component({\n selector: 'wr-lightbox',\n templateUrl: './lightbox.html',\n styleUrl: './lightbox.scss',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-lightbox',\n '[class]': 'classes()',\n '[style.aspect-ratio]': 'aspectRatio()',\n },\n})\nexport class WrLightbox {\n /** Accessible name of the thumbnail button. Falls back to `alt`, then `image.open`. */\n readonly openLabel = input<string | null>(null);\n\n /** Accessible name of the viewer's close button. Falls back to `image.close`, then `'Close preview'`. */\n readonly closeLabel = input<string | null>(null);\n\n protected readonly resolvedCloseLabel = useI18nText(this.closeLabel, 'image.close', 'Close preview');\n\n /** Image source. */\n readonly src = input.required<string>();\n\n /** Alt text. Required for a11y; falls back to an empty string. @default '' */\n readonly alt = input<string>('');\n\n /**\n * Lighter source for the THUMBNAIL — a small or blurred copy, so the grid does not\n * pull full-size images. The viewer always shows `src`; the thumbnail does not swap\n * to it later.\n */\n readonly preview = input<string | null>(null);\n\n // Both of these were hard-coded English literals in the template, next to a catalog\n // that already carried `image.open` translated and unread. `useI18nText` already\n // does the whole chain — a non-empty binding wins, then the catalog, then the\n // English default — so the alt text (which describes the actual picture) is what\n // gets forwarded, with `openLabel` ahead of it as the explicit override.\n protected readonly resolvedOpenLabel = useI18nText(\n computed(() => {\n // Not `??`: an empty `openLabel` is no label at all, so it has to fall through\n // to the alt text rather than winning as an empty string.\n const explicit = this.openLabel();\n if (explicit) return explicit;\n return this.alt();\n }),\n 'image.open',\n 'Open preview'\n );\n\n protected readonly resolvedViewerLabel = useI18nText(\n computed(() => this.shown().alt()),\n 'image.viewer',\n 'Image preview'\n );\n\n /** Disable the click-to-zoom lightbox. @default false */\n readonly disablePreview = input(false, { transform: coerceBooleanProperty });\n\n /** Caption shown under the full image in the lightbox. */\n readonly caption = input<string>('');\n\n /**\n * Reserve space before the image resolves by fixing the thumbnail's\n * `aspect-ratio` (e.g. `'16 / 9'`, `'4 / 3'`, or a number like `1.5`).\n * Prevents the layout jump when the intrinsic image size isn't known up\n * front — pair it with a `width` and the box keeps its height from first\n * paint. @default null\n */\n readonly aspectRatio = input<string | number | null>(null);\n\n /**\n * Where focus goes when the viewer opens. `'dialog'` puts it on the viewer\n * itself, with no ring, so the keyboard is inside and no button is lit;\n * `'first-tabbable'` puts it on the Close button; `false` leaves it on the\n * thumbnail. The viewer traps Tab in every mode, and closing returns focus to\n * the thumbnail.\n * @default 'dialog'\n */\n readonly autoFocus = input<WrOverlayAutoFocus>('dialog');\n\n /**\n * Extra CSS classes for the viewer's overlay pane.\n *\n * The pane is appended to the overlay container, not to this component, so\n * nothing in the consumer's own template encloses it and no descendant rule\n * written around the trigger can reach it. This input is the only per-instance\n * handle on it. A space-separated string works as well as an array.\n */\n readonly panelClass = input<WrClassInput>(null);\n\n /**\n * Gallery name. Every `wr-lightbox` with the same group, in document order,\n * can be paged through from whichever one was opened. A lightbox with\n * `disablePreview` stays out of it. @default null\n */\n readonly group = input<string | null>(null);\n\n /** Wrap from the last image of the group to the first, and back. @default false */\n readonly loop = input(false, { transform: coerceBooleanProperty });\n\n /** Accessible name of the viewer's previous button. Falls back to `common.previous`. */\n readonly previousLabel = input<string | null>(null);\n\n /** Accessible name of the viewer's next button. Falls back to `common.next`. */\n readonly nextLabel = input<string | null>(null);\n\n protected readonly resolvedPreviousLabel = useI18nText(this.previousLabel, 'common.previous', 'Previous');\n protected readonly resolvedNextLabel = useI18nText(this.nextLabel, 'common.next', 'Next');\n private readonly counterText = useI18nFormatter('image.counter', '{{current}} / {{total}}');\n private readonly positionText = useI18nFormatter('image.position', 'Image {{current}} of {{total}}');\n\n protected readonly open = signal(false);\n protected readonly loaded = signal(false);\n\n /**\n * Id the trigger's `aria-controls` points at while the viewer is open.\n *\n * @internal Public so the host bindings can read it.\n */\n protected readonly viewerId = `wr-lightbox-viewer-${++viewerUid}`;\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.open()) parts.push('wr-lightbox--open');\n if (!this.loaded()) parts.push('wr-lightbox--loading');\n return parts.join(' ');\n });\n\n // Query by name — `@if` blocks register their own TemplateRefs, so an\n // unqualified TemplateRef query would grab the thumbnail branch instead.\n protected readonly panelTpl = viewChild.required<TemplateRef<unknown>>('viewerTpl');\n\n private readonly groups = inject(WrLightboxGroups);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly focusMonitor = inject(FocusMonitor);\n private readonly overlay = inject(WR_OVERLAY);\n private readonly vcr = inject(ViewContainerRef);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n /**\n * The reading direction the open viewer has to keep up with, resolved off the\n * ENVIRONMENT injector rather than this component's — the same instance the\n * CDK read when it stamped the overlay, since `createOverlayRef` takes\n * `Directionality` from the `Overlay`'s injector and no node-level `[dir]` is\n * in that chain. The viewer is appended to the overlay container on `<body>`,\n * not into whatever region the thumbnail sits in, so reading the node\n * injector would rewrite a correctly-stamped panel to an island's direction\n * one pass after it opened rather than follow the application at all.\n *\n * `null` never happens in an app — `Directionality` is root-provided — but a\n * bare `TestBed` should still get a viewer that opens.\n */\n private readonly dir = inject(EnvironmentInjector).get(Directionality, null);\n private focusTrap: ConfigurableFocusTrap | null = null;\n private previouslyFocused: HTMLElement | null = null;\n private overlayRef: OverlayRef | null = null;\n\n /** The gallery this lightbox pages through; empty when it stands alone. */\n protected readonly gallery: Signal<readonly WrLightbox[]> = computed(() => {\n const group = this.group();\n if (!group) return [];\n const members = this.groups.members(group).filter(member => !member.disablePreview());\n return members.length > 1 && members.includes(this) ? members : [];\n });\n\n private readonly target = signal<WrLightbox | null>(null);\n private lastIndex = 0;\n\n /** The lightbox whose image the viewer is showing. */\n protected readonly shown: Signal<WrLightbox> = computed(() => {\n const target = this.target();\n return target && this.gallery().includes(target) ? target : this;\n });\n\n protected readonly index = computed(() => this.gallery().indexOf(this.shown()));\n protected readonly canPrevious = computed(() => this.loop() || this.index() > 0);\n protected readonly canNext = computed(() => this.loop() || this.index() < this.gallery().length - 1);\n\n protected readonly counter = computed(() => this.counterText(this.place()));\n\n protected readonly announcement = computed(() => {\n const alt = this.shown().alt();\n const position = this.positionText(this.place());\n return alt ? `${position}, ${alt}` : position;\n });\n\n private readonly preloaded = new Set<string>();\n\n constructor() {\n // Destroying the component while the viewer is open removes the projected\n // content (the portal uses this component's ViewContainerRef) but leaves the\n // overlay pane and its full-screen backdrop behind, with page scroll still\n // blocked. Dispose the overlay explicitly.\n this.destroyRef.onDestroy(() => this.closeOverlay());\n\n effect(() => {\n if (this.open()) this.openOverlay();\n else this.closeOverlay();\n });\n\n effect(onCleanup => {\n const group = this.group();\n if (!group) return;\n this.groups.add(group, this, this.host);\n onCleanup(() => this.groups.remove(group, this));\n });\n\n // The image on screen left the group: stay at its place in the order\n // instead of jumping back to the one that was opened.\n effect(() => {\n const target = this.target();\n if (!target) return;\n const gallery = this.gallery();\n const index = gallery.indexOf(target);\n if (index >= 0) {\n this.lastIndex = index;\n return;\n }\n untracked(() => this.target.set(gallery[Math.min(this.lastIndex, gallery.length - 1)] ?? null));\n });\n\n effect(() => {\n if (!this.isBrowser || !this.open()) return;\n const gallery = this.gallery();\n // The viewer's own <img> fetches this one.\n this.preloaded.add(this.shown().src());\n for (const delta of [-1, 1]) {\n const neighbour = gallery[this.wrap(this.index() + delta)];\n if (neighbour) this.preload(neighbour.src());\n }\n });\n }\n\n protected onClick(): void {\n if (this.disablePreview()) return;\n const group = this.group();\n if (group) this.groups.refresh(group);\n this.target.set(this);\n this.open.set(true);\n }\n\n /** Move through the gallery by one image; a no-op at an end unless `loop` is set. */\n protected step(delta: -1 | 1): void {\n this.show(this.wrap(this.index() + delta));\n }\n\n private show(index: number): void {\n const member = this.gallery()[index];\n if (member) this.target.set(member);\n }\n\n private wrap(index: number): number {\n const total = this.gallery().length;\n return this.loop() && total ? (index + total) % total : index;\n }\n\n private place(): { current: number; total: number } {\n return { current: this.index() + 1, total: this.gallery().length };\n }\n\n private preload(src: string): void {\n if (this.preloaded.has(src)) return;\n this.preloaded.add(src);\n new Image().src = src;\n }\n\n protected onClose(): void {\n this.open.set(false);\n }\n\n // Swipe-down-to-dismiss on the open viewer. The image follows the finger and\n // fades; releasing past ~20% of the viewer height closes it.\n private viewerStartX = 0;\n private viewerStartY = 0;\n private viewerSwiping = false;\n\n protected onViewerSwipeStart(event: TouchEvent): void {\n const touch = event.touches[0];\n if (!touch) return;\n this.viewerStartX = touch.clientX;\n this.viewerStartY = touch.clientY;\n this.viewerSwiping = true;\n }\n\n protected onViewerSwipeMove(event: TouchEvent, viewer: HTMLElement): void {\n if (!this.viewerSwiping) return;\n const touch = event.touches[0];\n if (!touch) return;\n const dy = touch.clientY - this.viewerStartY;\n if (dy <= 0 || this.isSideways(touch.clientX - this.viewerStartX, dy)) {\n viewer.style.transform = '';\n viewer.style.opacity = '';\n return;\n }\n event.preventDefault();\n viewer.style.transition = 'none';\n viewer.style.transform = `translateY(${dy}px)`;\n viewer.style.opacity = String(Math.max(0.3, 1 - dy / (viewer.offsetHeight || 1)));\n }\n\n protected onViewerSwipeEnd(event: TouchEvent, viewer: HTMLElement): void {\n if (!this.viewerSwiping) return;\n this.viewerSwiping = false;\n const touch = event.changedTouches[0];\n const dx = touch ? touch.clientX - this.viewerStartX : 0;\n const dy = touch ? touch.clientY - this.viewerStartY : 0;\n if (this.isSideways(dx, dy)) {\n if (Math.abs(dx) >= SWIPE_STEP_PX) this.step(dx < 0 !== this.isRtl() ? 1 : -1);\n } else if (dy > (viewer.offsetHeight || 0) * 0.2) {\n this.onClose();\n } else {\n viewer.style.transition = '';\n viewer.style.transform = '';\n viewer.style.opacity = '';\n }\n }\n\n /** A drag that belongs to the gallery rather than to swipe-down-to-dismiss. */\n private isSideways(dx: number, dy: number): boolean {\n return this.gallery().length > 0 && Math.abs(dx) > Math.abs(dy);\n }\n\n private isRtl(): boolean {\n return this.dir?.value === 'rtl';\n }\n\n /**\n * The thumbnail has settled, one way or the other. A failure counts: `--loading`\n * animates a shimmer AND sets `opacity: 0` on the image, so a broken `src` with no\n * error path left an invisible box shimmering for ever instead of showing its alt\n * text.\n */\n protected onSettled(): void {\n this.loaded.set(true);\n }\n\n // Overlay\n\n private openOverlay(): void {\n if (this.overlayRef) return;\n\n this.overlayRef = this.overlay.create({\n hasBackdrop: true,\n backdropClass: 'wr-lightbox-backdrop',\n positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),\n scrollStrategy: this.overlay.scrollStrategies.block(),\n panelClass: wrToClassList('wr-lightbox-overlay', this.panelClass()),\n });\n\n // Centred on both axes, so no geometry rides on the direction — but the\n // viewer's own chrome does. The ✕ is placed with `inset-inline-end` and the\n // caption reads as prose, both against the `dir` the CDK froze at create, so\n // a flip while the viewer is open leaves the button on the wrong corner.\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 // The viewer declares role=\"dialog\" + aria-modal=\"true\", which promises the\n // rest of the page is inert. Without a focus trap that promise is a lie:\n // Tab walks straight out of the viewer into the page behind the backdrop.\n const active = document.activeElement;\n this.previouslyFocused = active instanceof HTMLElement ? active : null;\n const pane = this.overlayRef.overlayElement;\n this.focusTrap = this.focusTrapFactory.create(pane);\n // Onto the viewer itself by default, the element that carries the dialog\n // role: the keyboard is inside and the Close button is not lit.\n wrFocusOverlay(\n pane.querySelector<HTMLElement>('.wr-lightbox-viewer') ?? pane,\n this.focusTrap,\n this.autoFocus(),\n this.injector\n );\n\n this.overlayRef\n .backdropClick()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => this.open.set(false));\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 } else {\n this.onGalleryKey(event);\n }\n });\n }\n\n private onGalleryKey(event: KeyboardEvent): void {\n const total = this.gallery().length;\n if (!total || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n\n switch (event.key) {\n case 'ArrowLeft':\n this.step(this.isRtl() ? 1 : -1);\n break;\n case 'ArrowRight':\n this.step(this.isRtl() ? -1 : 1);\n break;\n case 'Home':\n this.show(0);\n break;\n case 'End':\n this.show(total - 1);\n break;\n default:\n return;\n }\n event.preventDefault();\n }\n\n private closeOverlay(): void {\n if (!this.overlayRef) return;\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n this.overlayRef.dispose();\n this.overlayRef = null;\n // Send focus back where it came from, or it lands on <body> and the user\n // has to tab from the top of the page again.\n if (restore && typeof restore.focus === 'function') wrRestoreFocus(restore, this.focusMonitor);\n }\n}\n","@if (disablePreview()) {\n <img\n class=\"wr-lightbox__thumb\"\n [src]=\"preview() || src()\"\n [alt]=\"alt()\"\n (load)=\"onSettled()\"\n (error)=\"onSettled()\"\n loading=\"lazy\"\n decoding=\"async\"\n />\n} @else {\n <!-- The trigger opens a modal dialog, and used to say so nowhere: no hint that it\n opens anything, and nothing on the page tying it to the viewer it opened. -->\n <button\n type=\"button\"\n class=\"wr-lightbox__trigger\"\n aria-haspopup=\"dialog\"\n [attr.aria-controls]=\"open() ? viewerId : null\"\n [attr.aria-label]=\"resolvedOpenLabel()\"\n (click)=\"onClick()\"\n >\n <img\n class=\"wr-lightbox__thumb\"\n [src]=\"preview() || src()\"\n [alt]=\"alt()\"\n (load)=\"onSettled()\"\n (error)=\"onSettled()\"\n loading=\"lazy\"\n decoding=\"async\"\n />\n </button>\n}\n\n<ng-template #viewerTpl>\n <div\n #viewer\n class=\"wr-lightbox-viewer\"\n [id]=\"viewerId\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-label]=\"resolvedViewerLabel()\"\n (touchstart)=\"onViewerSwipeStart($event)\"\n (touchmove)=\"onViewerSwipeMove($event, viewer)\"\n (touchend)=\"onViewerSwipeEnd($event, viewer)\"\n (touchcancel)=\"onViewerSwipeEnd($event, viewer)\"\n >\n <button\n type=\"button\"\n class=\"wr-lightbox-viewer__close\"\n [attr.aria-label]=\"resolvedCloseLabel()\"\n (click)=\"onClose()\"\n (keydown.enter)=\"onClose()\"\n (keydown.space)=\"onClose()\"\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 </button>\n @if (gallery().length) {\n <span class=\"wr-lightbox-viewer__counter\" aria-hidden=\"true\">{{ counter() }}</span>\n <!-- `aria-disabled`, not `disabled`: a disabled button drops focus to <body>,\n out of the trap, the moment the last image is reached. -->\n <button\n type=\"button\"\n class=\"wr-lightbox-viewer__nav wr-lightbox-viewer__nav--previous\"\n [class.wr-lightbox-viewer__nav--disabled]=\"!canPrevious()\"\n [attr.aria-label]=\"resolvedPreviousLabel()\"\n [attr.aria-disabled]=\"canPrevious() ? null : 'true'\"\n (click)=\"step(-1)\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n <button\n type=\"button\"\n class=\"wr-lightbox-viewer__nav wr-lightbox-viewer__nav--next\"\n [class.wr-lightbox-viewer__nav--disabled]=\"!canNext()\"\n [attr.aria-label]=\"resolvedNextLabel()\"\n [attr.aria-disabled]=\"canNext() ? null : 'true'\"\n (click)=\"step(1)\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n }\n <!--\n Styled `cursor: zoom-out`, which is a promise: clicking the image closes. A\n REDUNDANT mouse affordance — the close button, Escape, the backdrop and\n swipe-down all do the same thing and all reach a keyboard — so the image stays\n out of the tab order rather than becoming a second close stop.\n -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <img class=\"wr-lightbox-viewer__full\" [src]=\"shown().src()\" [alt]=\"shown().alt()\" (click)=\"onClose()\" />\n @if (shown().caption()) {\n <div class=\"wr-lightbox-viewer__caption\">{{ shown().caption() }}</div>\n }\n @if (gallery().length) {\n <span class=\"wr-lightbox-viewer__status\" role=\"status\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AAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAW,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-lightbox.mjs","names":[],"sources":["../../../projects/lib/lightbox/lightbox-groups.ts","../../../projects/lib/lightbox/lightbox.ts","../../../projects/lib/lightbox/lightbox.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Service, signal, type WritableSignal } from '@angular/core';\n\nimport type { WrLightbox } from './lightbox';\n\ninterface Entry {\n readonly member: WrLightbox;\n readonly host: HTMLElement;\n}\n\n/**\n * Every grouped `wr-lightbox`, keyed by its `group`.\n *\n * @internal\n */\n@Service()\nexport class WrLightboxGroups {\n private readonly groups = new Map<string, WritableSignal<readonly Entry[]>>();\n\n add(group: string, member: WrLightbox, host: HTMLElement): void {\n this.entries(group).update(list => [...list, { member, host }]);\n }\n\n remove(group: string, member: WrLightbox): void {\n const entries = this.entries(group);\n entries.update(list => list.filter(entry => entry.member !== member));\n if (!entries().length) this.groups.delete(group);\n }\n\n /**\n * Re-reads the order. Registration follows creation, and a member that only\n * MOVED in the document registers nothing, so the gallery asks again each\n * time it opens.\n */\n refresh(group: string): void {\n this.groups.get(group)?.update(list => [...list]);\n }\n\n /** The group's members in document order. */\n members(group: string): readonly WrLightbox[] {\n return [...this.entries(group)()]\n .sort((a, b) =>\n // eslint-disable-next-line no-bitwise -- compareDocumentPosition answers with a bitmask\n (a.host.compareDocumentPosition(b.host) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0 ? -1 : 1\n )\n .map(entry => entry.member);\n }\n\n private entries(group: string): WritableSignal<readonly Entry[]> {\n let entries = this.groups.get(group);\n if (!entries) {\n entries = signal<readonly Entry[]>([]);\n this.groups.set(group, entries);\n }\n return entries;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type ConfigurableFocusTrap, ConfigurableFocusTrapFactory, FocusMonitor } from '@angular/cdk/a11y';\nimport { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { type OverlayRef } from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport { isPlatformBrowser } from '@angular/common';\nimport type { Signal, TemplateRef } from '@angular/core';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n EnvironmentInjector,\n Injector,\n PLATFORM_ID,\n ViewContainerRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\nimport { WR_OVERLAY, type WrOverlayAutoFocus, WrScrollBlock, wrFocusOverlay, wrFollowDirection } from 'ngwr/overlay';\nimport { wrIsComposing, wrToClassList, type WrClassInput, wrRestoreFocus } from 'ngwr/utils';\n\nimport { WrLightboxGroups } from './lightbox-groups';\n\n/** How far a horizontal swipe travels before it turns the page. */\nconst SWIPE_STEP_PX = 48;\n\nlet viewerUid = 0;\n\n/**\n * Image with click-to-zoom lightbox. The thumbnail is a plain `<img>`\n * with whatever sizing/`object-fit` you give it; clicking opens a CDK\n * overlay showing the full image, with Escape + close button + backdrop\n * to dismiss.\n *\n * Lightboxes that share a `group` form a gallery in document order: the viewer\n * gains previous and next buttons, a counter and the arrow keys.\n *\n * @example\n * ```html\n * <wr-lightbox\n * src=\"/photo.jpg\"\n * alt=\"Mountain\"\n * style=\"width: 16rem; height: 10rem; object-fit: cover\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/lightbox\n */\n@Component({\n selector: 'wr-lightbox',\n templateUrl: './lightbox.html',\n styleUrl: './lightbox.scss',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-lightbox',\n '[class]': 'classes()',\n '[style.aspect-ratio]': 'aspectRatio()',\n },\n})\nexport class WrLightbox {\n /** Accessible name of the thumbnail button. Falls back to `alt`, then `image.open`. */\n readonly openLabel = input<string | null>(null);\n\n /** Accessible name of the viewer's close button. Falls back to `image.close`, then `'Close preview'`. */\n readonly closeLabel = input<string | null>(null);\n\n protected readonly resolvedCloseLabel = useI18nText(this.closeLabel, 'image.close', 'Close preview');\n\n /** Image source. */\n readonly src = input.required<string>();\n\n /** Alt text. Required for a11y; falls back to an empty string. @default '' */\n readonly alt = input<string>('');\n\n /**\n * Lighter source for the THUMBNAIL — a small or blurred copy, so the grid does not\n * pull full-size images. The viewer always shows `src`; the thumbnail does not swap\n * to it later.\n */\n readonly preview = input<string | null>(null);\n\n // Both of these were hard-coded English literals in the template, next to a catalog\n // that already carried `image.open` translated and unread. `useI18nText` already\n // does the whole chain — a non-empty binding wins, then the catalog, then the\n // English default — so the alt text (which describes the actual picture) is what\n // gets forwarded, with `openLabel` ahead of it as the explicit override.\n protected readonly resolvedOpenLabel = useI18nText(\n computed(() => {\n // Not `??`: an empty `openLabel` is no label at all, so it has to fall through\n // to the alt text rather than winning as an empty string.\n const explicit = this.openLabel();\n if (explicit) return explicit;\n return this.alt();\n }),\n 'image.open',\n 'Open preview'\n );\n\n protected readonly resolvedViewerLabel = useI18nText(\n computed(() => this.shown().alt()),\n 'image.viewer',\n 'Image preview'\n );\n\n /** Disable the click-to-zoom lightbox. @default false */\n readonly disablePreview = input(false, { transform: coerceBooleanProperty });\n\n /** Caption shown under the full image in the lightbox. */\n readonly caption = input<string>('');\n\n /**\n * Reserve space before the image resolves by fixing the thumbnail's\n * `aspect-ratio` (e.g. `'16 / 9'`, `'4 / 3'`, or a number like `1.5`).\n * Prevents the layout jump when the intrinsic image size isn't known up\n * front — pair it with a `width` and the box keeps its height from first\n * paint. @default null\n */\n readonly aspectRatio = input<string | number | null>(null);\n\n /**\n * Where focus goes when the viewer opens. `'dialog'` puts it on the viewer\n * itself, with no ring, so the keyboard is inside and no button is lit;\n * `'first-tabbable'` puts it on the Close button; `false` leaves it on the\n * thumbnail. The viewer traps Tab in every mode, and closing returns focus to\n * the thumbnail.\n * @default 'dialog'\n */\n readonly autoFocus = input<WrOverlayAutoFocus>('dialog');\n\n /**\n * Extra CSS classes for the viewer's overlay pane.\n *\n * The pane is appended to the overlay container, not to this component, so\n * nothing in the consumer's own template encloses it and no descendant rule\n * written around the trigger can reach it. This input is the only per-instance\n * handle on it. A space-separated string works as well as an array.\n */\n readonly panelClass = input<WrClassInput>(null);\n\n /**\n * Gallery name. Every `wr-lightbox` with the same group, in document order,\n * can be paged through from whichever one was opened. A lightbox with\n * `disablePreview` stays out of it. @default null\n */\n readonly group = input<string | null>(null);\n\n /** Wrap from the last image of the group to the first, and back. @default false */\n readonly loop = input(false, { transform: coerceBooleanProperty });\n\n /** Accessible name of the viewer's previous button. Falls back to `common.previous`. */\n readonly previousLabel = input<string | null>(null);\n\n /** Accessible name of the viewer's next button. Falls back to `common.next`. */\n readonly nextLabel = input<string | null>(null);\n\n protected readonly resolvedPreviousLabel = useI18nText(this.previousLabel, 'common.previous', 'Previous');\n protected readonly resolvedNextLabel = useI18nText(this.nextLabel, 'common.next', 'Next');\n private readonly counterText = useI18nFormatter('image.counter', '{{current}} / {{total}}');\n private readonly positionText = useI18nFormatter('image.position', 'Image {{current}} of {{total}}');\n\n protected readonly open = signal(false);\n protected readonly loaded = signal(false);\n\n /**\n * Id the trigger's `aria-controls` points at while the viewer is open.\n *\n * @internal Public so the host bindings can read it.\n */\n protected readonly viewerId = `wr-lightbox-viewer-${++viewerUid}`;\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.open()) parts.push('wr-lightbox--open');\n if (!this.loaded()) parts.push('wr-lightbox--loading');\n return parts.join(' ');\n });\n\n // Query by name — `@if` blocks register their own TemplateRefs, so an\n // unqualified TemplateRef query would grab the thumbnail branch instead.\n protected readonly panelTpl = viewChild.required<TemplateRef<unknown>>('viewerTpl');\n\n private readonly groups = inject(WrLightboxGroups);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly focusMonitor = inject(FocusMonitor);\n private readonly overlay = inject(WR_OVERLAY);\n private readonly scrollBlock = inject(WrScrollBlock);\n private readonly vcr = inject(ViewContainerRef);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n /**\n * The reading direction the open viewer has to keep up with, resolved off the\n * ENVIRONMENT injector rather than this component's — the same instance the\n * CDK read when it stamped the overlay, since `createOverlayRef` takes\n * `Directionality` from the `Overlay`'s injector and no node-level `[dir]` is\n * in that chain. The viewer is appended to the overlay container on `<body>`,\n * not into whatever region the thumbnail sits in, so reading the node\n * injector would rewrite a correctly-stamped panel to an island's direction\n * one pass after it opened rather than follow the application at all.\n *\n * `null` never happens in an app — `Directionality` is root-provided — but a\n * bare `TestBed` should still get a viewer that opens.\n */\n private readonly dir = inject(EnvironmentInjector).get(Directionality, null);\n private focusTrap: ConfigurableFocusTrap | null = null;\n private previouslyFocused: HTMLElement | null = null;\n private overlayRef: OverlayRef | null = null;\n\n /** The gallery this lightbox pages through; empty when it stands alone. */\n protected readonly gallery: Signal<readonly WrLightbox[]> = computed(() => {\n const group = this.group();\n if (!group) return [];\n const members = this.groups.members(group).filter(member => !member.disablePreview());\n return members.length > 1 && members.includes(this) ? members : [];\n });\n\n private readonly target = signal<WrLightbox | null>(null);\n private lastIndex = 0;\n\n /** The lightbox whose image the viewer is showing. */\n protected readonly shown: Signal<WrLightbox> = computed(() => {\n const target = this.target();\n return target && this.gallery().includes(target) ? target : this;\n });\n\n protected readonly index = computed(() => this.gallery().indexOf(this.shown()));\n protected readonly canPrevious = computed(() => this.loop() || this.index() > 0);\n protected readonly canNext = computed(() => this.loop() || this.index() < this.gallery().length - 1);\n\n protected readonly counter = computed(() => this.counterText(this.place()));\n\n protected readonly announcement = computed(() => {\n const alt = this.shown().alt();\n const position = this.positionText(this.place());\n return alt ? `${position}, ${alt}` : position;\n });\n\n private readonly preloaded = new Set<string>();\n\n constructor() {\n // Destroying the component while the viewer is open removes the projected\n // content (the portal uses this component's ViewContainerRef) but leaves the\n // overlay pane and its full-screen backdrop behind, with page scroll still\n // blocked. Dispose the overlay explicitly.\n this.destroyRef.onDestroy(() => this.closeOverlay());\n\n effect(() => {\n if (this.open()) this.openOverlay();\n else this.closeOverlay();\n });\n\n effect(onCleanup => {\n const group = this.group();\n if (!group) return;\n this.groups.add(group, this, this.host);\n onCleanup(() => this.groups.remove(group, this));\n });\n\n // The image on screen left the group: stay at its place in the order\n // instead of jumping back to the one that was opened.\n effect(() => {\n const target = this.target();\n if (!target) return;\n const gallery = this.gallery();\n const index = gallery.indexOf(target);\n if (index >= 0) {\n this.lastIndex = index;\n return;\n }\n untracked(() => this.target.set(gallery[Math.min(this.lastIndex, gallery.length - 1)] ?? null));\n });\n\n effect(() => {\n if (!this.isBrowser || !this.open()) return;\n const gallery = this.gallery();\n // The viewer's own <img> fetches this one.\n this.preloaded.add(this.shown().src());\n for (const delta of [-1, 1]) {\n const neighbour = gallery[this.wrap(this.index() + delta)];\n if (neighbour) this.preload(neighbour.src());\n }\n });\n }\n\n protected onClick(): void {\n if (this.disablePreview()) return;\n const group = this.group();\n if (group) this.groups.refresh(group);\n this.target.set(this);\n this.open.set(true);\n }\n\n /** Move through the gallery by one image; a no-op at an end unless `loop` is set. */\n protected step(delta: -1 | 1): void {\n this.show(this.wrap(this.index() + delta));\n }\n\n private show(index: number): void {\n const member = this.gallery()[index];\n if (member) this.target.set(member);\n }\n\n private wrap(index: number): number {\n const total = this.gallery().length;\n return this.loop() && total ? (index + total) % total : index;\n }\n\n private place(): { current: number; total: number } {\n return { current: this.index() + 1, total: this.gallery().length };\n }\n\n private preload(src: string): void {\n if (this.preloaded.has(src)) return;\n this.preloaded.add(src);\n new Image().src = src;\n }\n\n protected onClose(): void {\n this.open.set(false);\n }\n\n // Swipe-down-to-dismiss on the open viewer. The image follows the finger and\n // fades; releasing past ~20% of the viewer height closes it.\n private viewerStartX = 0;\n private viewerStartY = 0;\n private viewerSwiping = false;\n\n protected onViewerSwipeStart(event: TouchEvent): void {\n const touch = event.touches[0];\n if (!touch) return;\n this.viewerStartX = touch.clientX;\n this.viewerStartY = touch.clientY;\n this.viewerSwiping = true;\n }\n\n protected onViewerSwipeMove(event: TouchEvent, viewer: HTMLElement): void {\n if (!this.viewerSwiping) return;\n const touch = event.touches[0];\n if (!touch) return;\n const dy = touch.clientY - this.viewerStartY;\n if (dy <= 0 || this.isSideways(touch.clientX - this.viewerStartX, dy)) {\n viewer.style.transform = '';\n viewer.style.opacity = '';\n return;\n }\n event.preventDefault();\n viewer.style.transition = 'none';\n viewer.style.transform = `translateY(${dy}px)`;\n viewer.style.opacity = String(Math.max(0.3, 1 - dy / (viewer.offsetHeight || 1)));\n }\n\n protected onViewerSwipeEnd(event: TouchEvent, viewer: HTMLElement): void {\n if (!this.viewerSwiping) return;\n this.viewerSwiping = false;\n const touch = event.changedTouches[0];\n const dx = touch ? touch.clientX - this.viewerStartX : 0;\n const dy = touch ? touch.clientY - this.viewerStartY : 0;\n if (this.isSideways(dx, dy)) {\n if (Math.abs(dx) >= SWIPE_STEP_PX) this.step(dx < 0 !== this.isRtl() ? 1 : -1);\n } else if (dy > (viewer.offsetHeight || 0) * 0.2) {\n this.onClose();\n } else {\n viewer.style.transition = '';\n viewer.style.transform = '';\n viewer.style.opacity = '';\n }\n }\n\n /** A drag that belongs to the gallery rather than to swipe-down-to-dismiss. */\n private isSideways(dx: number, dy: number): boolean {\n return this.gallery().length > 0 && Math.abs(dx) > Math.abs(dy);\n }\n\n private isRtl(): boolean {\n return this.dir?.value === 'rtl';\n }\n\n /**\n * The thumbnail has settled, one way or the other. A failure counts: `--loading`\n * animates a shimmer AND sets `opacity: 0` on the image, so a broken `src` with no\n * error path left an invisible box shimmering for ever instead of showing its alt\n * text.\n */\n protected onSettled(): void {\n this.loaded.set(true);\n }\n\n // Overlay\n\n private openOverlay(): void {\n if (this.overlayRef) return;\n\n this.overlayRef = this.overlay.create({\n hasBackdrop: true,\n backdropClass: 'wr-lightbox-backdrop',\n positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),\n scrollStrategy: this.scrollBlock.strategy(),\n panelClass: wrToClassList('wr-lightbox-overlay', this.panelClass()),\n });\n\n // Centred on both axes, so no geometry rides on the direction — but the\n // viewer's own chrome does. The ✕ is placed with `inset-inline-end` and the\n // caption reads as prose, both against the `dir` the CDK froze at create, so\n // a flip while the viewer is open leaves the button on the wrong corner.\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 // The viewer declares role=\"dialog\" + aria-modal=\"true\", which promises the\n // rest of the page is inert. Without a focus trap that promise is a lie:\n // Tab walks straight out of the viewer into the page behind the backdrop.\n const active = document.activeElement;\n this.previouslyFocused = active instanceof HTMLElement ? active : null;\n const pane = this.overlayRef.overlayElement;\n this.focusTrap = this.focusTrapFactory.create(pane);\n // Onto the viewer itself by default, the element that carries the dialog\n // role: the keyboard is inside and the Close button is not lit.\n wrFocusOverlay(\n pane.querySelector<HTMLElement>('.wr-lightbox-viewer') ?? pane,\n this.focusTrap,\n this.autoFocus(),\n this.injector\n );\n\n this.overlayRef\n .backdropClick()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => this.open.set(false));\n\n this.overlayRef\n .keydownEvents()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (wrIsComposing(event)) return;\n if (event.key === 'Escape') {\n event.preventDefault();\n this.open.set(false);\n } else {\n this.onGalleryKey(event);\n }\n });\n }\n\n private onGalleryKey(event: KeyboardEvent): void {\n const total = this.gallery().length;\n if (!total || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n\n switch (event.key) {\n case 'ArrowLeft':\n this.step(this.isRtl() ? 1 : -1);\n break;\n case 'ArrowRight':\n this.step(this.isRtl() ? -1 : 1);\n break;\n case 'Home':\n this.show(0);\n break;\n case 'End':\n this.show(total - 1);\n break;\n default:\n return;\n }\n event.preventDefault();\n }\n\n private closeOverlay(): void {\n if (!this.overlayRef) return;\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n this.overlayRef.dispose();\n this.overlayRef = null;\n // Send focus back where it came from, or it lands on <body> and the user\n // has to tab from the top of the page again.\n if (restore && typeof restore.focus === 'function') wrRestoreFocus(restore, this.focusMonitor);\n }\n}\n","@if (disablePreview()) {\n <img\n class=\"wr-lightbox__thumb\"\n [src]=\"preview() || src()\"\n [alt]=\"alt()\"\n (load)=\"onSettled()\"\n (error)=\"onSettled()\"\n loading=\"lazy\"\n decoding=\"async\"\n />\n} @else {\n <!-- The trigger opens a modal dialog, and used to say so nowhere: no hint that it\n opens anything, and nothing on the page tying it to the viewer it opened. -->\n <button\n type=\"button\"\n class=\"wr-lightbox__trigger\"\n aria-haspopup=\"dialog\"\n [attr.aria-controls]=\"open() ? viewerId : null\"\n [attr.aria-label]=\"resolvedOpenLabel()\"\n (click)=\"onClick()\"\n >\n <img\n class=\"wr-lightbox__thumb\"\n [src]=\"preview() || src()\"\n [alt]=\"alt()\"\n (load)=\"onSettled()\"\n (error)=\"onSettled()\"\n loading=\"lazy\"\n decoding=\"async\"\n />\n </button>\n}\n\n<ng-template #viewerTpl>\n <div\n #viewer\n class=\"wr-lightbox-viewer\"\n [id]=\"viewerId\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-label]=\"resolvedViewerLabel()\"\n (touchstart)=\"onViewerSwipeStart($event)\"\n (touchmove)=\"onViewerSwipeMove($event, viewer)\"\n (touchend)=\"onViewerSwipeEnd($event, viewer)\"\n (touchcancel)=\"onViewerSwipeEnd($event, viewer)\"\n >\n <button\n type=\"button\"\n class=\"wr-lightbox-viewer__close\"\n [attr.aria-label]=\"resolvedCloseLabel()\"\n (click)=\"onClose()\"\n (keydown.enter)=\"onClose()\"\n (keydown.space)=\"onClose()\"\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 </button>\n @if (gallery().length) {\n <span class=\"wr-lightbox-viewer__counter\" aria-hidden=\"true\">{{ counter() }}</span>\n <!-- `aria-disabled`, not `disabled`: a disabled button drops focus to <body>,\n out of the trap, the moment the last image is reached. -->\n <button\n type=\"button\"\n class=\"wr-lightbox-viewer__nav wr-lightbox-viewer__nav--previous\"\n [class.wr-lightbox-viewer__nav--disabled]=\"!canPrevious()\"\n [attr.aria-label]=\"resolvedPreviousLabel()\"\n [attr.aria-disabled]=\"canPrevious() ? null : 'true'\"\n (click)=\"step(-1)\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n <button\n type=\"button\"\n class=\"wr-lightbox-viewer__nav wr-lightbox-viewer__nav--next\"\n [class.wr-lightbox-viewer__nav--disabled]=\"!canNext()\"\n [attr.aria-label]=\"resolvedNextLabel()\"\n [attr.aria-disabled]=\"canNext() ? null : 'true'\"\n (click)=\"step(1)\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n }\n <!--\n Styled `cursor: zoom-out`, which is a promise: clicking the image closes. A\n REDUNDANT mouse affordance — the close button, Escape, the backdrop and\n swipe-down all do the same thing and all reach a keyboard — so the image stays\n out of the tab order rather than becoming a second close stop.\n -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <img class=\"wr-lightbox-viewer__full\" [src]=\"shown().src()\" [alt]=\"shown().alt()\" (click)=\"onClose()\" />\n @if (shown().caption()) {\n <div class=\"wr-lightbox-viewer__caption\">{{ shown().caption() }}</div>\n }\n @if (gallery().length) {\n <span class=\"wr-lightbox-viewer__status\" role=\"status\" aria-live=\"polite\">{{ announcement() }}</span>\n }\n </div>\n</ng-template>\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAa,mBAAb,MAAa,iBAAgB;CACV,yBAAS,IAAI,IAAG;CAEjC,IAAI,OAAe,QAAoB,MAAiB;EACtD,KAAK,QAAQ,KAAK,CAAC,CAAC,QAAO,SAAQ,CAAC,GAAG,MAAM;GAAE;GAAQ;EAAI,CAAE,CAAC;CAChE;CAEA,OAAO,OAAe,QAAkB;EACtC,MAAM,UAAU,KAAK,QAAQ,KAAK;EAClC,QAAQ,QAAO,SAAQ,KAAK,QAAO,UAAS,MAAM,WAAW,MAAM,CAAC;EACpE,IAAI,CAAC,QAAO,CAAE,CAAC,QAAQ,KAAK,OAAO,OAAO,KAAK;CACjD;CAOA,QAAQ,OAAa;EACnB,KAAK,OAAO,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
380
381
|
}
|
|
381
382
|
detect() {
|
|
@@ -484,6 +485,7 @@ var WrMention = class WrMention {
|
|
|
484
485
|
}
|
|
485
486
|
show() {
|
|
486
487
|
const el = this.host.nativeElement;
|
|
488
|
+
if (el.matches(":focus")) clearTimeout(this.blurClose);
|
|
487
489
|
const { top, left, lineHeight } = getCaretCoordinates(el, el.selectionStart ?? 0);
|
|
488
490
|
const field = el.getBoundingClientRect();
|
|
489
491
|
this.caretOffset.dx = left - field.left;
|