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-form.mjs","names":[],"sources":["../../../projects/lib/form/form.ts","../../../projects/lib/form/form-item.ts","../../../projects/lib/form/tokens.ts","../../../projects/lib/form/form-field.ts","../../../projects/lib/form/form-field.html","../../../projects/lib/form/field-aria.ts","../../../projects/lib/form/schema.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Directive, computed, inject, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Lays out the fields of a form: a column with a gap by default, a wrapping\n * row with `inline`, or rows of `columns` equal columns that fall back to one\n * column when the form itself is narrow.\n *\n * @example\n * ```html\n * <form wrForm columns=\"2\">\n * <wr-form-field label=\"First name\"><input wrInput /></wr-form-field>\n * <wr-form-field label=\"Last name\"><input wrInput /></wr-form-field>\n * <wr-form-field label=\"Email\" wrFormSpan><input wrInput /></wr-form-field>\n * </form>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form\n */\n@Directive({\n selector: '[wrForm]',\n host: {\n class: 'wr-form',\n '[class.wr-form--inline]': 'inline()',\n '[class.wr-form--columns]': 'grid()',\n '[style.--wr-form-columns]': 'columns()',\n },\n})\nexport class WrForm {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n }\n\n /**\n * Lay the fields out in a wrapping row, aligned on their bottom edge.\n * `columns` is ignored.\n *\n * @default false\n */\n readonly inline = input(false, { transform: coerceBooleanProperty });\n\n /**\n * How many equal columns a row holds. Below a form width of `30rem` every\n * field takes a full row.\n *\n * @default 1\n */\n readonly columns = input(1, {\n transform: (value: unknown): number => Math.max(1, Math.floor(coerceNumberProperty(value, 1))),\n });\n\n protected readonly grid = computed(() => !this.inline() && this.columns() > 1);\n}\n\n/**\n * Stretches a child of `[wrForm]` over several columns: all of them with no\n * value, or the given number.\n *\n * @example\n * ```html\n * <wr-form-field label=\"Address\" wrFormSpan=\"2\"><input wrInput /></wr-form-field>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form\n */\n@Directive({\n selector: '[wrFormSpan]',\n host: { class: 'wr-form__span', '[style.--wr-form-span]': 'track()' },\n})\nexport class WrFormSpan {\n private readonly form = inject(WrForm, { optional: true });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n }\n\n /**\n * Columns to span. Empty or `'full'` takes the whole row. A number above\n * the form's `columns` spans them all.\n *\n * @default 'full'\n */\n readonly span = input<number | 'full', unknown>('full', {\n alias: 'wrFormSpan',\n transform: value => {\n const count = Math.floor(coerceNumberProperty(value, 0));\n return count >= 1 ? count : 'full';\n },\n });\n\n protected readonly track = computed(() => {\n const span = this.span();\n if (span === 'full') return '1 / -1';\n return `span ${this.form ? Math.min(span, this.form.columns()) : span}`;\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 { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Wraps a label + control + error message into a single field row.\n *\n * Toggle `hasError` to apply error styling to the projected label and\n * any descendant input / textarea / checkbox.\n *\n * @example\n * ```html\n * <wr-form-item [hasError]=\"form.controls.email.invalid\">\n * <label>Email</label>\n * <input wrInput formControlName=\"email\" />\n * <wr-form-error>Invalid email</wr-form-error>\n * </wr-form-item>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form\n */\n@Component({\n selector: 'wr-form-item',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-form-item', '[class]': 'classes()' },\n})\nexport class WrFormItem {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n }\n\n /**\n * When `true`, applies error coloring to the projected label and inputs.\n *\n * @default false\n */\n readonly hasError = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.hasError()) parts.push('wr-form-item--error');\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 { InjectionToken, type Signal } from '@angular/core';\n\n/**\n * What a projected control can read from its surrounding `<wr-form-field>`.\n *\n * The field renders `<label [for]>` before it can see what was projected into\n * it, so the id has to travel the other way: the control adopts the id the\n * label already points at. Doing it through DI keeps it a render-time binding,\n * which is what SSR needs — stamping the id from `afterNextRender` would leave\n * every prerendered page with a label pointing at nothing.\n */\nexport interface WrFormFieldContext {\n /** Id the field's `<label for>` points at. */\n readonly controlId: Signal<string>;\n\n /**\n * The reverse direction, for the one case the paragraph above does not cover: a\n * projected control that already carries its own `id` keeps it, and the label has\n * to follow, or `for` names an element that does not exist and the field ends up\n * with no label at all. Called during the control's construction, so the label's\n * binding still resolves in the same render pass.\n */\n adoptControlId(id: string): void;\n\n /**\n * Validator keys currently in error, once the control is touched or dirty.\n * Empty when the field is valid or has not been interacted with.\n */\n readonly errorKeys: Signal<readonly string[]>;\n\n /** Id of the element listing the visible messages, or `null` when there are none. */\n readonly describedBy: Signal<string | null>;\n\n /**\n * Id of the field's own `<label>`, or `null` when it renders none.\n *\n * For the controls `<label for>` cannot reach. `for` only binds to a LABELABLE\n * element — button, input, meter, output, progress, select, textarea — so a\n * control whose focusable part is a `div[role=\"slider\"]`, a `role=\"button\"`\n * drop zone or a radiogroup got a label pointing at nothing: measured, five of\n * the eighteen value controls resolved `for` to no element in the document at\n * all. Those point `aria-labelledby` back at this instead, which is the\n * direction that works for a role.\n */\n readonly labelId?: Signal<string | null>;\n\n /**\n * Id of the field's hint, or `null` when it is showing none — including while\n * an error has replaced it, since the two never render together and an\n * `aria-describedby` naming an absent element is an author error.\n *\n * Separate from {@link describedBy} rather than folded into it because the two\n * carry different weight: a control keyed `aria-invalid` on \"the field is\n * describing me\" would announce itself invalid for a plain hint. Compose the\n * pair with `useFormFieldAria()` instead of reading either one directly.\n *\n * Optional so an app that provides its own `WR_FORM_FIELD` keeps compiling; a\n * field without it simply describes nothing but its errors.\n */\n readonly hintId?: Signal<string | null>;\n\n /**\n * Whether the field is marked `required`. Read through `useFormFieldAria()` as\n * `aria-required`. Optional so an app that provides its own `WR_FORM_FIELD`\n * keeps compiling.\n */\n readonly required?: Signal<boolean>;\n}\n\n/** Present only inside a `<wr-form-field>`; inject with `{ optional: true }`. */\nexport const WR_FORM_FIELD = new InjectionToken<WrFormFieldContext>('WR_FORM_FIELD');\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 { isPlatformBrowser } from '@angular/common';\nimport {\n Component,\n DestroyRef,\n type AfterContentChecked,\n PLATFORM_ID,\n ViewEncapsulation,\n computed,\n contentChild,\n contentChildren,\n effect,\n forwardRef,\n inject,\n input,\n isDevMode,\n signal,\n untracked,\n} from '@angular/core';\nimport { AbstractControl, NgControl, type ValidationErrors } from '@angular/forms';\n\nimport { EMPTY, type Subscription } from 'rxjs';\n\nimport { WrI18n, useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_FORM_FIELD, type WrFormFieldContext } from './tokens';\n\nlet uid = 0;\n\n/**\n * Error keys already reported on the server. Every prerendered route and every\n * request builds its fields afresh, so the per-field memo alone would repeat one\n * warning per page; the browser keeps it per field, where it names the field the\n * developer is looking at.\n */\nconst warnedOnServer = new Set<string>();\n\n/** Validator payloads are plain objects; anything else interpolates nothing. */\nfunction toParams(error: unknown): Record<string, unknown> | undefined {\n return error && typeof error === 'object' ? (error as Record<string, unknown>) : undefined;\n}\n\n/**\n * The sentence the validator carries itself, or `null`.\n *\n * Signal Forms validators take `{ message }` and keep it on the error object, and\n * the interop `NgControl` this field reads lists that object AS IS under its\n * `kind` (`signalErrorsToValidationErrors` in `@angular/forms`), so the message\n * arrives here untouched. A custom control's parse errors take the same road in\n * both forms flavours, which is how a `wr-date-picker` refusal is read. A classic\n * validator's payload has no `message` unless the app put one there.\n */\nfunction ownMessage(error: unknown): string | null {\n const message = toParams(error)?.['message'];\n return typeof message === 'string' && message.trim() !== '' ? message : null;\n}\n\n/**\n * The two Signal Forms kinds whose spelling and payload differ from the classic\n * validator that means the same thing.\n *\n * Reactive forms emit `minlength` / `maxlength` carrying `requiredLength`;\n * Signal Forms emit `minLength` / `maxLength` carrying `minLength` / `maxLength`.\n * Restated before the catalog lookup so one `validation.minlength` entry in an\n * app's catalog answers both spellings, with `{{requiredLength}}` filled either\n * way — the message is the SAME message, one sentence about a length reached by\n * two spellings of one rule, and asking every app for two keys would only get\n * one of them written.\n */\nconst SIGNAL_FORMS_ALIASES: Readonly<Record<string, { readonly key: string; readonly from: string }>> = {\n minLength: { key: 'minlength', from: 'minLength' },\n maxLength: { key: 'maxlength', from: 'maxLength' },\n};\n\n/**\n * A Signal Forms length error, restated in the classic shape the catalog lookup\n * reads. Anything else passes through untouched.\n */\nfunction normalizeError(key: string, error: unknown): { readonly key: string; readonly error: unknown } {\n const alias = SIGNAL_FORMS_ALIASES[key];\n if (!alias) return { key, error };\n\n const params = toParams(error);\n const bound = params?.[alias.from];\n return {\n key: alias.key,\n error: bound === undefined ? error : { ...params, requiredLength: bound },\n };\n}\n\n/**\n * One error message tied to a validator key. Renders only when the parent\n * form-field has a matching error in `control.errors`, and only once the\n * control is touched or dirty.\n *\n * A keyed message CLAIMS its key: the field renders no automatic message for it,\n * so per-field markup wins over the validator's own `message` and over the app's\n * `validation.*` catalog.\n *\n * @example\n * ```html\n * <wr-form-error key=\"required\">This field is required.</wr-form-error>\n * <wr-form-error key=\"email\">That doesn't look right.</wr-form-error>\n * ```\n */\n@Component({\n selector: 'wr-form-error',\n template: `<ng-content />`,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-form-error wr-form-field__error',\n role: 'alert',\n '[attr.data-key]': 'key() ?? null',\n '[class.wr-form-field__error--hidden]': '!visible()',\n },\n})\nexport class WrFormError {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n }\n\n /**\n * Validator key this message corresponds to (e.g. `'required'`).\n * Optional — without a key the message always renders, which is the\n * plain inline-error usage inside `<wr-form-item>`.\n */\n readonly key = input<string>();\n\n private readonly field = inject(WR_FORM_FIELD, { optional: true });\n\n /**\n * Whether this message is the one the current error calls for.\n *\n * The parent projects every `<wr-form-error>` through a single\n * `<ng-content select>`, which cannot filter — so each message decides for\n * itself. Without this, one invalid control rendered \"Email is required.\"\n * and \"That isn't a valid email.\" side by side, which is what the docs have\n * always described as gated behaviour.\n *\n * A keyless message always shows: that is the plain inline-error usage inside\n * `<wr-form-item>`, which has no error discovery at all.\n */\n protected readonly visible = computed(() => {\n const key = this.key();\n if (!key || !this.field) return true;\n return this.field.errorKeys().includes(key);\n });\n}\n\n/**\n * Wraps a label + control + hint + error messages into a single block —\n * the layout primitive every form ends up reinventing.\n *\n * - Auto-binds `label[for]` to the projected control via a generated id\n * (or use the form-control's `[id]` if you set one).\n * - Reads the projected control's `NgControl` to surface validation\n * errors only once the control is touched or dirty. A submit shows them\n * only by marking the controls touched, as `markAllAsTouched()` and Signal\n * Forms' `submit()` do.\n * - Optional `[required]` / `[optional]` markers next to the label.\n *\n * **ngwr ships no error texts.** Each error shows the first copy that exists for\n * it: a projected `<wr-form-error key>`, then the validator's own `message`\n * (`required(path.email, { message: 'Enter your email.' })`), then\n * `validation.<key>` in the app's i18n catalog, interpolated with the error's\n * payload. A key none of them answers renders nothing, and dev mode says so once.\n *\n * @example\n * ```html\n * <wr-form-field label=\"Email\" hint=\"We'll never share it.\">\n * <input wrInput [formControl]=\"email\" type=\"email\" />\n * <wr-form-error key=\"required\">Email is required.</wr-form-error>\n * <wr-form-error key=\"email\">Not a valid email.</wr-form-error>\n * </wr-form-field>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form-field\n */\n@Component({\n selector: 'wr-form-field',\n templateUrl: './form-field.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-form-field', '[class]': 'classes()' },\n providers: [\n {\n provide: WR_FORM_FIELD,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrFormField),\n },\n ],\n})\nexport class WrFormField implements WrFormFieldContext, AfterContentChecked {\n /** Label text shown above the control. */\n readonly label = input<string>('');\n\n /** Hint text shown below the control. Hidden when an error is visible. */\n readonly hint = input<string>('');\n\n /** Show a `*` next to the label and set `aria-required` on the projected control. @default false */\n readonly required = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Show an \"optional\" marker next to the label — the word comes from\n * `optionalLabel`. Mutually exclusive with `required`. @default false\n */\n readonly optional = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Word inside the optional marker's parentheses. Falls back to\n * `form.optional`, then `'optional'`. The parentheses are the template's, so\n * no locale has to repeat punctuation.\n */\n readonly optionalLabel = input<string | null>(null);\n\n // Unlike the `*` marker beside it, this one is NOT `aria-hidden` — it sits\n // inside the `<label>` and is read as part of the control's accessible name,\n // so an English word here reached a Russian screen reader.\n protected readonly resolvedOptional = useI18nText(this.optionalLabel, 'form.optional', 'optional');\n\n /**\n * Force a specific id on the label's `for` attribute. Auto-generated\n * otherwise, and adopted by the projected `wrInput` unless that element\n * already carries an `id` of its own.\n */\n readonly controlId = input<string>(`wr-form-field-${++uid}`);\n\n // What a projected control reported it actually kept. `null` until one does — most\n // controls simply adopt `controlId`, and only a control with its own `id` overrides\n // it from the other direction.\n private readonly adoptedId = signal<string | null>(null);\n\n /**\n * Id the `<label for>` renders. A control that came with its own `id` keeps it, so\n * the label follows that instead of the generated one — otherwise `for` points at\n * an element that is not in the document and the field is unlabelled.\n */\n protected readonly labelFor = computed(() => this.adoptedId() ?? this.controlId());\n\n /** @internal `WrFormFieldContext` — see the token's docs. */\n adoptControlId(id: string): void {\n this.adoptedId.set(id);\n }\n\n /**\n * Projected `NgControl` — used to read touched / dirty / errors.\n *\n * This catches `[formField]` too: Angular's Signal Forms directive provides\n * `NgControl` via its interop shim, so both forms flavours land here.\n */\n protected readonly ngControl = contentChild(NgControl);\n\n /**\n * Bumped on every event the projected control emits.\n *\n * `AbstractControl`'s `touched` / `dirty` / `errors` accessors are NOT\n * reactive under classic forms — Angular reads them inside `untracked()`, and\n * `errors` is a plain assigned field. A `computed` over them therefore caches\n * its first value and never recomputes, which in a zoneless app means the\n * error block never appears at all. `control.events` is the reactive source\n * Angular does expose, so the computed depends on this counter instead.\n * Signal Forms needs none of this — its interop getters read live signals —\n * and harmlessly contributes no events.\n *\n * Events are not the whole story, which is what {@link ngAfterContentChecked} is for.\n */\n private readonly revision = signal(0);\n\n /** What the last check saw on a reactive control — see {@link ngAfterContentChecked}. */\n private seen: {\n readonly errors: ValidationErrors | null;\n readonly touched: boolean;\n readonly dirty: boolean;\n } | null = null;\n\n /**\n * Catch the changes a reactive control makes WITHOUT an event.\n *\n * `updateValueAndValidity({ emitEvent: false })`, `markAsTouched({ emitEvent: false })`\n * and their siblings change `errors`, `touched` and `dirty` and emit nothing, so the\n * subscription above never hears them and the message stays whatever it was. That is\n * not only an app's own silent write: Angular reports a custom control's PARSE errors\n * to a `FormControl` exactly that way — a validator re-run with `emitEvent: false` —\n * so a `wr-date-picker` refusing typed text made its control invalid while the field\n * went on showing the message from before, or nothing — and a later pass of change\n * detection did not help, because the message was memoised on a revision only events\n * move.\n *\n * This runs whenever the view holding the field is checked, which is when the page\n * around the control changes — for the date picker, the moment its refusal turns\n * visible. It is `ngAfterContentChecked` and not `ngDoCheck` for an ordering reason\n * read out of Angular's `refreshView`: check hooks run BEFORE the view's effects, and\n * Angular's parse-error validator is re-run from an effect in that same view, so a\n * `DoCheck` saw the errors one pass late and lost the message whenever nothing\n * refreshed the view again. Content-checked hooks run after those effects and before\n * the field's own bindings. Only a change moves the revision.\n *\n * Signal Forms' interop control is skipped: it is reactive already, and its `errors`\n * getter builds a fresh object on every read, which a reference check would call a\n * change on every pass — and re-resolve every message with it.\n */\n ngAfterContentChecked(): void {\n const control = this.ngControl()?.control;\n if (!(control instanceof AbstractControl)) {\n this.seen = null;\n return;\n }\n const { errors, touched, dirty } = control;\n const seen = this.seen;\n if (seen?.errors === errors && seen.touched === touched && seen.dirty === dirty) return;\n this.seen = { errors, touched, dirty };\n // The first sighting is only the baseline: `errors` reads `ngControl()`, so the\n // message already recomputed when the control appeared.\n if (seen) this.revision.update(n => n + 1);\n }\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n let sub: Subscription | null = null;\n effect(() => {\n const control = this.ngControl()?.control;\n sub?.unsubscribe();\n sub = (control?.events ?? EMPTY).subscribe(() => this.revision.update(n => n + 1));\n });\n inject(DestroyRef).onDestroy(() => sub?.unsubscribe());\n }\n\n protected readonly errors = computed(() => {\n this.revision();\n const c = this.ngControl();\n if (!c) return null;\n if (!c.touched && !c.dirty) return null;\n return c.errors;\n });\n\n protected readonly hasError = computed(() => {\n const errs = this.errors();\n return !!errs && Object.keys(errs).length > 0;\n });\n\n /** @internal Read by the projected `<wr-form-error>` children to decide which of them renders. */\n readonly errorKeys = computed<readonly string[]>(() => Object.keys(this.errors() ?? {}));\n\n /** @internal Read by the projected control so a screen reader is pointed at the message. */\n readonly describedBy = computed(() => (this.hasError() ? `${this.controlId()}-errors` : null));\n\n /**\n * @internal Read by the projected control so the hint is announced with the field.\n *\n * The hint used to carry no id at all, so the only thing `aria-describedby`\n * could ever name was the error block: the sentence explaining what to type was\n * on screen and reached a screen-reader user through no path whatsoever, and\n * the one gate that could have said so does not exist — axe has no rule that\n * visible help text must be programmatically associated.\n *\n * `null` while an error is showing, because the template swaps the hint out for\n * the message; publishing the id anyway would point every control at an element\n * that had just left the document.\n */\n readonly hintId = computed(() => (!this.hasError() && this.hint() ? `${this.controlId()}-hint` : null));\n\n /** @internal `WrFormFieldContext` — the id a role-based control points `aria-labelledby` at. */\n readonly labelId = computed(() => (this.label() ? `${this.controlId()}-label` : null));\n\n /**\n * Render a message for any error the markup does not already answer: the\n * validator's own `message`, else `validation.<key>` from the app's i18n\n * catalog. ngwr ships no error texts, so a key neither of them answers renders\n * nothing, and dev mode warns once for it.\n *\n * On by default: a field with no `<wr-form-error>` at all is the common case.\n * Turn it off for a field whose copy is entirely hand-written. @default true\n */\n readonly autoErrors = input(true, { transform: coerceBooleanProperty });\n\n private readonly projectedErrors = contentChildren(WrFormError);\n private readonly i18n = inject(WrI18n, { optional: true });\n private readonly isServer = !isPlatformBrowser(inject(PLATFORM_ID));\n\n /** Error keys this field has already warned about — see {@link warnNoCopy}. */\n private readonly warned = new Set<string>();\n\n /**\n * Errors with no projected `<wr-form-error key>` to answer them, resolved to\n * text. Per-field markup always wins — it is the most specific thing the author\n * wrote — and a key nothing answers is left out rather than rendered empty.\n */\n protected readonly autoMessages = computed<readonly { key: string; text: string }[]>(() => {\n if (!this.autoErrors()) return [];\n const errors = this.errors();\n if (!errors) return [];\n\n const claimed = new Set(\n this.projectedErrors()\n .map(e => e.key())\n .filter(Boolean)\n );\n\n const messages: { key: string; text: string }[] = [];\n for (const [key, error] of Object.entries(errors)) {\n if (claimed.has(key)) continue;\n const text = this.resolve(key, error);\n if (text) messages.push({ key, text });\n else if (isDevMode()) untracked(() => this.warnNoCopy(key));\n }\n return messages;\n });\n\n private resolve(rawKey: string, rawError: unknown): string | null {\n const own = ownMessage(rawError);\n if (own) return own;\n\n // `t()` reads the service's revision signal, so this recomputes on a locale\n // switch and when a loader-backed catalog lands; a miss returns the key itself.\n // ngwr's own catalogs carry no `validation` namespace, so only the app answers.\n const { key, error } = normalizeError(rawKey, rawError);\n const translated = this.i18n?.t(`validation.${key}`, toParams(error));\n return translated && translated !== `validation.${key}` ? translated : null;\n }\n\n /**\n * Say once, in dev, that an error is showing with nothing to read.\n *\n * Nothing on screen gives it away: the field still goes red and the control is\n * still marked invalid, so an empty error block survives review. With no\n * built-in copy that is the ordinary state of a validator nobody wrote words\n * for, not an edge case. Once per field and key — and once per key on the\n * server, where every prerendered page builds its fields again. The catalog key\n * is the normalised one, the markup key the one the control reported, because\n * those are what each of the two reads.\n */\n private warnNoCopy(rawKey: string): void {\n if (this.warned.has(rawKey)) return;\n this.warned.add(rawKey);\n if (this.isServer) {\n if (warnedOnServer.has(rawKey)) return;\n warnedOnServer.add(rawKey);\n }\n\n const catalogKey = normalizeError(rawKey, undefined).key;\n const field = this.label() ? `\"${this.label()}\"` : `#${this.labelFor()}`;\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] <wr-form-field> ${field}: the \"${rawKey}\" error has no copy, so nothing is shown for it — ` +\n `ngwr ships no error texts. Supply one: { message } on the validator, \"validation.${catalogKey}\" ` +\n `in the app's i18n catalog, or <wr-form-error key=\"${rawKey}\"> inside the field.`\n );\n }\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.hasError()) parts.push('wr-form-field--invalid');\n if (this.required()) parts.push('wr-form-field--required');\n return parts.join(' ');\n });\n}\n","@if (label()) {\n <label class=\"wr-form-field__label\" [attr.id]=\"labelId()\" [attr.for]=\"labelFor()\">\n {{ label() }}\n @if (required()) {\n <span class=\"wr-form-field__required\" aria-hidden=\"true\">*</span>\n } @else if (optional()) {\n <span class=\"wr-form-field__optional\">({{ resolvedOptional() }})</span>\n }\n </label>\n}\n\n<div class=\"wr-form-field__control\"><ng-content /></div>\n\n@if (hasError()) {\n <div class=\"wr-form-field__errors\" [attr.id]=\"describedBy()\">\n <ng-content select=\"wr-form-error\" />\n @for (message of autoMessages(); track message.key) {\n <div class=\"wr-form-error wr-form-field__error\" role=\"alert\" [attr.data-key]=\"message.key\">\n {{ message.text }}\n </div>\n }\n </div>\n} @else if (hint()) {\n <small class=\"wr-form-field__hint\" [attr.id]=\"hintId()\">{{ hint() }}</small>\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 Signal, computed, inject } from '@angular/core';\n\nimport { WR_FORM_FIELD } from './tokens';\n\n/** What {@link useFormFieldAria} hands a control to bind on its own element. */\nexport interface WrFormFieldAria {\n /**\n * Id of the field's message block while it is showing one, of its hint\n * otherwise, and `null` when it is showing neither.\n */\n readonly describedBy: Signal<string | null>;\n /** `'true'` while the field has a validation error, `null` otherwise. */\n readonly ariaInvalid: Signal<'true' | null>;\n /** `'true'` while the field is `required`, `null` otherwise. */\n readonly ariaRequired: Signal<'true' | null>;\n /**\n * Id of the field's `<label>`, for a control `<label for>` cannot reach.\n *\n * `for` binds only to a LABELABLE element, so a control whose focusable part\n * is a `div` with a role gets nothing from it — measured, `wr-rating`,\n * `wr-knob` and `wr-file-upload` all rendered a field label whose `for` named\n * no element in the document. Point `aria-labelledby` at this instead; a\n * control that IS labelable should ignore it and let `for` do the work, or the\n * name is announced twice.\n */\n readonly labelledBy: Signal<string | null>;\n}\n\n/**\n * The two attributes that make a `<wr-form-field>`'s visible text — its error\n * message, or its hint — reach a screen reader. Bind both on whichever element\n * carries the control's role.\n *\n * Without them the copy the field renders is visible and nothing else: the\n * control announces itself as valid, and the text is associated with nothing.\n * No automated gate catches that — axe has no rule that a visible error or hint\n * must be programmatically associated with its control — so this helper exists\n * to make the wiring one line per control rather than three, and the specs are\n * the gate.\n *\n * The field renders an error OR a hint, never both, so `describedBy` names\n * whichever is on screen and `aria-invalid` is keyed SEPARATELY, on the field's\n * `errorKeys()`. Deriving it from `describedBy` instead — which is what every\n * control did while a hint had no id to name — makes a field with a plain hint\n * announce its control as invalid the moment the hint becomes describable.\n *\n * Must be called from an injection context (a field initialiser or a\n * constructor). Returns inert signals outside a `<wr-form-field>`.\n *\n * Pass `skipSelf` from a COMPOSITE control — one whose own template renders\n * other ngwr controls. Such a component shields its subtree by re-providing\n * `WR_FORM_FIELD` as `null`, or the inner parts each announce the outer field's\n * error as their own; a component sees its own providers, so it has to read the\n * real field from one level up.\n *\n * @example\n * ```ts\n * protected readonly fieldAria = useFormFieldAria();\n * ```\n * ```html\n * <input [attr.aria-invalid]=\"fieldAria.ariaInvalid()\" [attr.aria-describedby]=\"fieldAria.describedBy()\" />\n * ```\n */\nexport function useFormFieldAria(options?: { readonly skipSelf?: boolean }): WrFormFieldAria {\n const field = inject(WR_FORM_FIELD, { optional: true, skipSelf: options?.skipSelf ?? false });\n return {\n // `hintId` is optional on the interface so an app-provided field keeps\n // compiling; one without it describes nothing but its errors, as before.\n describedBy: computed(() => field?.describedBy() ?? field?.hintId?.() ?? null),\n ariaInvalid: computed<'true' | null>(() => ((field?.errorKeys().length ?? 0) > 0 ? 'true' : null)),\n ariaRequired: computed<'true' | null>(() => (field?.required?.() ? 'true' : null)),\n // `null` for a control that `<label for>` already reaches — pointing at the\n // same label twice would name it twice. Only the role-based controls read\n // this, and only because `for` cannot bind to a role.\n labelledBy: computed(() => field?.labelId?.() ?? null),\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 { createMetadataKey } from '@angular/forms/signals';\n\n/**\n * How a field is DRAWN, attached to the same Signal Forms schema that already\n * says how it is validated.\n *\n * The alternative was a second schema — one for rules, one for presentation —\n * and it was rejected before it was written: two descriptions of one form drift\n * the moment someone renames a field in one of them, and nothing would report\n * it. Angular's `metadata()` takes a typed key and a `LogicFn`, so the\n * presentation rides on the schema the validators are already in, and it is\n * REACTIVE for free: a label, a set of options or a placeholder may depend on\n * the value of another field.\n *\n * What this deliberately does NOT carry: `required`, `disabled`, `readonly`,\n * `hidden`, `min`, `max`, and every validation rule. Those are Angular's own\n * schema functions, they already drive the control through `[formField]`, and\n * duplicating them here would create a second source of truth for state the form\n * already owns. That is not only a judgement call — Angular REFUSES a `[min]` or\n * `[required]` binding on a field-bound control (NG8022), so the second source\n * of truth is a compile error rather than a drift.\n */\nexport type WrFieldKind =\n | 'input'\n | 'textarea'\n | 'number'\n | 'select'\n | 'multiselect'\n | 'tags'\n | 'checkbox'\n | 'switch'\n | 'radio'\n | 'segmented'\n | 'date'\n | 'daterange'\n | 'slider'\n | 'rating'\n | 'file'\n | 'array';\n\n/** One choice, for the kinds that offer a list. */\nexport interface WrFieldOption {\n readonly value: unknown;\n readonly label: string;\n readonly disabled?: boolean;\n}\n\n/**\n * A titled group of fields, drawn as a `<fieldset>` with a `<legend>`.\n *\n * Fields that name the same `title` are drawn together, where the first of them\n * stands in the model's key order. The description and the column count come\n * from the first field that states them.\n */\nexport interface WrFieldSection {\n readonly title: string;\n /** A line under the title, announced as the group's description. */\n readonly description?: string;\n /** Grid columns inside the section. Defaults to the form's own `columns`. */\n readonly columns?: number;\n}\n\n/**\n * The presentation of one field.\n *\n * `kind` is the only required member: everything else has a sane default, and a\n * schema that says no more than `{ kind: 'input' }` still renders a labelled,\n * error-bound control — the label falls back to the field's own name.\n */\nexport interface WrFieldSpec {\n readonly kind: WrFieldKind;\n /** Defaults to the field's key, de-camel-cased — `workEmail` becomes \"Work email\". */\n readonly label?: string;\n readonly placeholder?: string;\n /** Help text under the control. Errors replace it while the field is invalid. */\n readonly hint?: string;\n /** For `select`, `multiselect`, `radio` and `segmented`. Ignored by every other kind. */\n readonly options?: readonly WrFieldOption[];\n /** Native `type` for `kind: 'input'` — `email`, `password`, `url`, `tel`. */\n readonly type?: string;\n /**\n * Granularity for `number` and `slider`. The BOUNDS are deliberately absent:\n * Angular refuses a `[min]` or `[max]` binding on a `[formField]`-bound\n * control outright (NG8022), because the field owns them — write `min(path.x,\n * 18)` in the schema and the control picks it up. `step` is presentation, has\n * no schema function, and stays here.\n */\n readonly step?: number;\n /**\n * Columns this field spans in `<wr-schema-form>`'s grid. Clamped to the form's\n * own `columns`, and 1 by default — a field is one cell unless it asks to be\n * wider.\n */\n readonly span?: number;\n /**\n * The section this field is drawn in: a title, or a title with a description\n * and its own column count. A field with none is drawn straight on the form's\n * grid.\n */\n readonly section?: string | WrFieldSection;\n /** For `file`: accept several files, so the field holds `File[]` rather than `File | null`. */\n readonly multiple?: boolean;\n /** For `file`: the native `accept` list, e.g. `'image/*,.pdf'`. */\n readonly accept?: string;\n /**\n * For `array`: the value a new item starts as. It is what draws the Add\n * button, and an array with no `item` is a fixed list whose items can only be\n * removed. Describe the item's own fields with `applyEach(path.x, item => …)`,\n * and bound the list with `minLength` and `maxLength` on the array itself.\n */\n readonly item?: () => unknown;\n /**\n * For `array`: what one item is called, numbered in the item's heading:\n * \"Address 2\". Defaults to the field's label.\n */\n readonly itemLabel?: string;\n /** For `array`: grid columns inside each item. Defaults to 1. */\n readonly columns?: number;\n}\n\n/**\n * The metadata key `<wr-schema-form>` reads.\n *\n * ```ts\n * const userSchema = schema<User>(path => {\n * required(path.email, { message: 'Enter your email.' });\n * email(path.email, { message: 'That is not an email address.' });\n * metadata(path.email, WR_FIELD, () => ({ kind: 'input', type: 'email', label: 'Work email' }));\n * metadata(path.role, WR_FIELD, () => ({ kind: 'select', options: ROLES }));\n *\n * // A repeating group: the array is described once, its items through `applyEach`.\n * metadata(path.addresses, WR_FIELD, () => ({ kind: 'array', item: () => ({ city: '' }) }));\n * applyEach(path.addresses, item => {\n * metadata(item.city, WR_FIELD, () => ({ kind: 'input' }));\n * });\n * });\n * ```\n *\n * A field with no `WR_FIELD` metadata is not an error and is not guessed at —\n * `<wr-schema-form>` skips it, so a schema can describe more than one screen shows.\n */\nexport const WR_FIELD = createMetadataKey<WrFieldSpec>();\n\n/** `workEmail` -> `Work email`. The fallback label, and only ever a fallback. */\nexport function wrFieldLabel(key: string): string {\n const spaced = key.replace(/([a-z\\d])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' ');\n return spaced.charAt(0).toUpperCase() + spaced.slice(1).toLowerCase();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,IAAa,SAAb,MAAa,OAAM;CACjB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,MAAM;CACzE;CAQS,SAAS,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,SAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAQxD,UAAU,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EACxB,YAAY,UAA2B,KAAK,IAAI,GAAG,KAAK,MAAM,qBAAqB,OAAO,CAAC,CAAC,CAAC;CAAC,CAAA;CAG7E,OAAO,eAAe,CAAC,KAAK,OAAM,KAAM,KAAK,QAAO,IAAK,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAvBnE,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAM,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAN,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAM,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,QAAA;IAAA,mBAAA;IAAA,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AAQ,UAAU,GAAG;CAC9E,OAAO,OAAO,OAAO,CAAC,CAAC,CAAC,YAAW,IAAK,OAAO,MAAM,CAAC,CAAC,CAAC,YAAW;AACrE"}
|
|
1
|
+
{"version":3,"file":"ngwr-form.mjs","names":[],"sources":["../../../projects/lib/form/form.ts","../../../projects/lib/form/form-item.ts","../../../projects/lib/form/tokens.ts","../../../projects/lib/form/form-field.ts","../../../projects/lib/form/form-field.html","../../../projects/lib/form/field-aria.ts","../../../projects/lib/form/schema.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Directive, computed, inject, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Lays out the fields of a form: a column with a gap by default, a wrapping\n * row with `inline`, or rows of `columns` equal columns that fall back to one\n * column when the form itself is narrow.\n *\n * @example\n * ```html\n * <form wrForm columns=\"2\">\n * <wr-form-field label=\"First name\"><input wrInput /></wr-form-field>\n * <wr-form-field label=\"Last name\"><input wrInput /></wr-form-field>\n * <wr-form-field label=\"Email\" wrFormSpan><input wrInput /></wr-form-field>\n * </form>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form\n */\n@Directive({\n selector: '[wrForm]',\n host: {\n class: 'wr-form',\n '[class.wr-form--inline]': 'inline()',\n '[class.wr-form--columns]': 'grid()',\n '[style.--wr-form-columns]': 'columns()',\n },\n})\nexport class WrForm {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n }\n\n /**\n * Lay the fields out in a wrapping row, aligned on their bottom edge.\n * `columns` is ignored.\n *\n * @default false\n */\n readonly inline = input(false, { transform: coerceBooleanProperty });\n\n /**\n * How many equal columns a row holds. Below a form width of `30rem` every\n * field takes a full row.\n *\n * @default 1\n */\n readonly columns = input(1, {\n transform: (value: unknown): number => Math.max(1, Math.floor(coerceNumberProperty(value, 1))),\n });\n\n protected readonly grid = computed(() => !this.inline() && this.columns() > 1);\n}\n\n/**\n * Stretches a child of `[wrForm]` over several columns: all of them with no\n * value, or the given number.\n *\n * @example\n * ```html\n * <wr-form-field label=\"Address\" wrFormSpan=\"2\"><input wrInput /></wr-form-field>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form\n */\n@Directive({\n selector: '[wrFormSpan]',\n host: { class: 'wr-form__span', '[style.--wr-form-span]': 'track()' },\n})\nexport class WrFormSpan {\n private readonly form = inject(WrForm, { optional: true });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n }\n\n /**\n * Columns to span. Empty or `'full'` takes the whole row. A number above\n * the form's `columns` spans them all.\n *\n * @default 'full'\n */\n readonly span = input<number | 'full', unknown>('full', {\n alias: 'wrFormSpan',\n transform: value => {\n const count = Math.floor(coerceNumberProperty(value, 0));\n return count >= 1 ? count : 'full';\n },\n });\n\n protected readonly track = computed(() => {\n const span = this.span();\n if (span === 'full') return '1 / -1';\n return `span ${this.form ? Math.min(span, this.form.columns()) : span}`;\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 { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Wraps a label + control + error message into a single field row.\n *\n * Toggle `hasError` to apply error styling to the projected label and\n * any descendant input / textarea / checkbox.\n *\n * @example\n * ```html\n * <wr-form-item [hasError]=\"form.controls.email.invalid\">\n * <label>Email</label>\n * <input wrInput formControlName=\"email\" />\n * <wr-form-error>Invalid email</wr-form-error>\n * </wr-form-item>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form\n */\n@Component({\n selector: 'wr-form-item',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-form-item', '[class]': 'classes()' },\n})\nexport class WrFormItem {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n }\n\n /**\n * When `true`, applies error coloring to the projected label and inputs.\n *\n * @default false\n */\n readonly hasError = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.hasError()) parts.push('wr-form-item--error');\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 { InjectionToken, type Signal } from '@angular/core';\n\n/**\n * What a projected control can read from its surrounding `<wr-form-field>`.\n *\n * The field renders `<label [for]>` before it can see what was projected into\n * it, so the id has to travel the other way: the control adopts the id the\n * label already points at. Doing it through DI keeps it a render-time binding,\n * which is what SSR needs — stamping the id from `afterNextRender` would leave\n * every prerendered page with a label pointing at nothing.\n */\nexport interface WrFormFieldContext {\n /** Id the field's `<label for>` points at. */\n readonly controlId: Signal<string>;\n\n /**\n * The reverse direction, for the one case the paragraph above does not cover: a\n * projected control that already carries its own `id` keeps it, and the label has\n * to follow, or `for` names an element that does not exist and the field ends up\n * with no label at all. Called during the control's construction, so the label's\n * binding still resolves in the same render pass.\n */\n adoptControlId(id: string): void;\n\n /**\n * Validator keys currently in error, once the control is touched or dirty.\n * Empty when the field is valid or has not been interacted with.\n */\n readonly errorKeys: Signal<readonly string[]>;\n\n /** Id of the element listing the visible messages, or `null` when there are none. */\n readonly describedBy: Signal<string | null>;\n\n /**\n * Id of the field's own `<label>`, or `null` when it renders none.\n *\n * For the controls `<label for>` cannot reach. `for` only binds to a LABELABLE\n * element — button, input, meter, output, progress, select, textarea — so a\n * control whose focusable part is a `div[role=\"slider\"]`, a `role=\"button\"`\n * drop zone or a radiogroup got a label pointing at nothing: measured, five of\n * the eighteen value controls resolved `for` to no element in the document at\n * all. Those point `aria-labelledby` back at this instead, which is the\n * direction that works for a role.\n */\n readonly labelId?: Signal<string | null>;\n\n /**\n * Id of the field's hint, or `null` when it is showing none — including while\n * an error has replaced it, since the two never render together and an\n * `aria-describedby` naming an absent element is an author error.\n *\n * Separate from {@link describedBy} rather than folded into it because the two\n * carry different weight: a control keyed `aria-invalid` on \"the field is\n * describing me\" would announce itself invalid for a plain hint. Compose the\n * pair with `useFormFieldAria()` instead of reading either one directly.\n *\n * Optional so an app that provides its own `WR_FORM_FIELD` keeps compiling; a\n * field without it simply describes nothing but its errors.\n */\n readonly hintId?: Signal<string | null>;\n\n /**\n * Whether the field is marked `required`. Read through `useFormFieldAria()` as\n * `aria-required`. Optional so an app that provides its own `WR_FORM_FIELD`\n * keeps compiling.\n */\n readonly required?: Signal<boolean>;\n}\n\n/** Present only inside a `<wr-form-field>`; inject with `{ optional: true }`. */\nexport const WR_FORM_FIELD = new InjectionToken<WrFormFieldContext>('WR_FORM_FIELD');\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 { isPlatformBrowser } from '@angular/common';\nimport {\n Component,\n DestroyRef,\n type AfterContentChecked,\n PLATFORM_ID,\n ViewEncapsulation,\n computed,\n contentChild,\n contentChildren,\n effect,\n forwardRef,\n inject,\n input,\n isDevMode,\n signal,\n untracked,\n} from '@angular/core';\nimport { AbstractControl, NgControl, type ValidationErrors } from '@angular/forms';\n\nimport { EMPTY, type Subscription } from 'rxjs';\n\nimport { WrI18n, useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_FORM_FIELD, type WrFormFieldContext } from './tokens';\n\nlet uid = 0;\n\n/**\n * Error keys already reported on the server. Every prerendered route and every\n * request builds its fields afresh, so the per-field memo alone would repeat one\n * warning per page; the browser keeps it per field, where it names the field the\n * developer is looking at.\n */\nconst warnedOnServer = new Set<string>();\n\n/** Validator payloads are plain objects; anything else interpolates nothing. */\nfunction toParams(error: unknown): Record<string, unknown> | undefined {\n return error && typeof error === 'object' ? (error as Record<string, unknown>) : undefined;\n}\n\n/**\n * The sentence the validator carries itself, or `null`.\n *\n * Signal Forms validators take `{ message }` and keep it on the error object, and\n * the interop `NgControl` this field reads lists that object AS IS under its\n * `kind` (`signalErrorsToValidationErrors` in `@angular/forms`), so the message\n * arrives here untouched. A custom control's parse errors take the same road in\n * both forms flavours, which is how a `wr-date-picker` refusal is read. A classic\n * validator's payload has no `message` unless the app put one there.\n */\nfunction ownMessage(error: unknown): string | null {\n const message = toParams(error)?.['message'];\n return typeof message === 'string' && message.trim() !== '' ? message : null;\n}\n\n/**\n * The two Signal Forms kinds whose spelling and payload differ from the classic\n * validator that means the same thing.\n *\n * Reactive forms emit `minlength` / `maxlength` carrying `requiredLength`;\n * Signal Forms emit `minLength` / `maxLength` carrying `minLength` / `maxLength`.\n * Restated before the catalog lookup so one `validation.minlength` entry in an\n * app's catalog answers both spellings, with `{{requiredLength}}` filled either\n * way — the message is the SAME message, one sentence about a length reached by\n * two spellings of one rule, and asking every app for two keys would only get\n * one of them written.\n */\nconst SIGNAL_FORMS_ALIASES: Readonly<Record<string, { readonly key: string; readonly from: string }>> = {\n minLength: { key: 'minlength', from: 'minLength' },\n maxLength: { key: 'maxlength', from: 'maxLength' },\n};\n\n/**\n * A Signal Forms length error, restated in the classic shape the catalog lookup\n * reads. Anything else passes through untouched.\n */\nfunction normalizeError(key: string, error: unknown): { readonly key: string; readonly error: unknown } {\n const alias = SIGNAL_FORMS_ALIASES[key];\n if (!alias) return { key, error };\n\n const params = toParams(error);\n const bound = params?.[alias.from];\n return {\n key: alias.key,\n error: bound === undefined ? error : { ...params, requiredLength: bound },\n };\n}\n\n/**\n * One error message tied to a validator key. Renders only when the parent\n * form-field has a matching error in `control.errors`, and only once the\n * control is touched or dirty.\n *\n * A keyed message CLAIMS its key: the field renders no automatic message for it,\n * so per-field markup wins over the validator's own `message` and over the app's\n * `validation.*` catalog.\n *\n * @example\n * ```html\n * <wr-form-error key=\"required\">This field is required.</wr-form-error>\n * <wr-form-error key=\"email\">That doesn't look right.</wr-form-error>\n * ```\n */\n@Component({\n selector: 'wr-form-error',\n template: `<ng-content />`,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-form-error wr-form-field__error',\n role: 'alert',\n '[attr.data-key]': 'key() ?? null',\n '[class.wr-form-field__error--hidden]': '!visible()',\n },\n})\nexport class WrFormError {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n }\n\n /**\n * Validator key this message corresponds to (e.g. `'required'`).\n * Optional — without a key the message always renders, which is the\n * plain inline-error usage inside `<wr-form-item>`.\n */\n readonly key = input<string>();\n\n private readonly field = inject(WR_FORM_FIELD, { optional: true });\n\n /**\n * Whether this message is the one the current error calls for.\n *\n * The parent projects every `<wr-form-error>` through a single\n * `<ng-content select>`, which cannot filter — so each message decides for\n * itself. Without this, one invalid control rendered \"Email is required.\"\n * and \"That isn't a valid email.\" side by side, which is what the docs have\n * always described as gated behaviour.\n *\n * A keyless message always shows: that is the plain inline-error usage inside\n * `<wr-form-item>`, which has no error discovery at all.\n */\n protected readonly visible = computed(() => {\n const key = this.key();\n if (!key || !this.field) return true;\n return this.field.errorKeys().includes(key);\n });\n}\n\n/**\n * Wraps a label + control + hint + error messages into a single block —\n * the layout primitive every form ends up reinventing.\n *\n * - Auto-binds `label[for]` to the projected control via a generated id\n * (or use the form-control's `[id]` if you set one).\n * - Reads the projected control's `NgControl` to surface validation\n * errors only once the control is touched or dirty. A submit shows them\n * only by marking the controls touched, as `markAllAsTouched()` and Signal\n * Forms' `submit()` do.\n * - Optional `[required]` / `[optional]` markers next to the label.\n *\n * **ngwr ships no error texts.** Each error shows the first copy that exists for\n * it: a projected `<wr-form-error key>`, then the validator's own `message`\n * (`required(path.email, { message: 'Enter your email.' })`), then\n * `validation.<key>` in the app's i18n catalog, interpolated with the error's\n * payload. A key none of them answers renders nothing, and dev mode says so once.\n *\n * @example\n * ```html\n * <wr-form-field label=\"Email\" hint=\"We'll never share it.\">\n * <input wrInput [formControl]=\"email\" type=\"email\" />\n * <wr-form-error key=\"required\">Email is required.</wr-form-error>\n * <wr-form-error key=\"email\">Not a valid email.</wr-form-error>\n * </wr-form-field>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form-field\n */\n@Component({\n selector: 'wr-form-field',\n templateUrl: './form-field.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-form-field', '[class]': 'classes()' },\n providers: [\n {\n provide: WR_FORM_FIELD,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrFormField),\n },\n ],\n})\nexport class WrFormField implements WrFormFieldContext, AfterContentChecked {\n /** Label text shown above the control. */\n readonly label = input<string>('');\n\n /** Hint text shown below the control. Hidden when an error is visible. */\n readonly hint = input<string>('');\n\n /** Show a `*` next to the label and set `aria-required` on the projected control. @default false */\n readonly required = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Show an \"optional\" marker next to the label — the word comes from\n * `optionalLabel`. Mutually exclusive with `required`. @default false\n */\n readonly optional = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Word inside the optional marker's parentheses. Falls back to\n * `form.optional`, then `'optional'`. The parentheses are the template's, so\n * no locale has to repeat punctuation.\n */\n readonly optionalLabel = input<string | null>(null);\n\n // Unlike the `*` marker beside it, this one is NOT `aria-hidden` — it sits\n // inside the `<label>` and is read as part of the control's accessible name,\n // so an English word here reached a Russian screen reader.\n protected readonly resolvedOptional = useI18nText(this.optionalLabel, 'form.optional', 'optional');\n\n /**\n * Force a specific id on the label's `for` attribute. Auto-generated\n * otherwise, and adopted by the projected `wrInput` unless that element\n * already carries an `id` of its own.\n */\n readonly controlId = input<string>(`wr-form-field-${++uid}`);\n\n // What a projected control reported it actually kept. `null` until one does — most\n // controls simply adopt `controlId`, and only a control with its own `id` overrides\n // it from the other direction.\n private readonly adoptedId = signal<string | null>(null);\n\n /**\n * Id the `<label for>` renders. A control that came with its own `id` keeps it, so\n * the label follows that instead of the generated one — otherwise `for` points at\n * an element that is not in the document and the field is unlabelled.\n */\n protected readonly labelFor = computed(() => this.adoptedId() ?? this.controlId());\n\n /** @internal `WrFormFieldContext` — see the token's docs. */\n adoptControlId(id: string): void {\n this.adoptedId.set(id);\n }\n\n /**\n * Projected `NgControl` — used to read touched / dirty / errors.\n *\n * This catches `[formField]` too: Angular's Signal Forms directive provides\n * `NgControl` via its interop shim, so both forms flavours land here.\n */\n protected readonly ngControl = contentChild(NgControl);\n\n /**\n * Bumped on every event the projected control emits.\n *\n * `AbstractControl`'s `touched` / `dirty` / `errors` accessors are NOT\n * reactive under classic forms — Angular reads them inside `untracked()`, and\n * `errors` is a plain assigned field. A `computed` over them therefore caches\n * its first value and never recomputes, which in a zoneless app means the\n * error block never appears at all. `control.events` is the reactive source\n * Angular does expose, so the computed depends on this counter instead.\n * Signal Forms needs none of this — its interop getters read live signals —\n * and harmlessly contributes no events.\n *\n * Events are not the whole story, which is what {@link ngAfterContentChecked} is for.\n */\n private readonly revision = signal(0);\n\n /** What the last check saw on a reactive control — see {@link ngAfterContentChecked}. */\n private seen: {\n readonly errors: ValidationErrors | null;\n readonly touched: boolean;\n readonly dirty: boolean;\n } | null = null;\n\n /**\n * Catch the changes a reactive control makes WITHOUT an event.\n *\n * `updateValueAndValidity({ emitEvent: false })`, `markAsTouched({ emitEvent: false })`\n * and their siblings change `errors`, `touched` and `dirty` and emit nothing, so the\n * subscription above never hears them and the message stays whatever it was. That is\n * not only an app's own silent write: Angular reports a custom control's PARSE errors\n * to a `FormControl` exactly that way — a validator re-run with `emitEvent: false` —\n * so a `wr-date-picker` refusing typed text made its control invalid while the field\n * went on showing the message from before, or nothing — and a later pass of change\n * detection did not help, because the message was memoised on a revision only events\n * move.\n *\n * This runs whenever the view holding the field is checked, which is when the page\n * around the control changes — for the date picker, the moment its refusal turns\n * visible. It is `ngAfterContentChecked` and not `ngDoCheck` for an ordering reason\n * read out of Angular's `refreshView`: check hooks run BEFORE the view's effects, and\n * Angular's parse-error validator is re-run from an effect in that same view, so a\n * `DoCheck` saw the errors one pass late and lost the message whenever nothing\n * refreshed the view again. Content-checked hooks run after those effects and before\n * the field's own bindings. Only a change moves the revision.\n *\n * Signal Forms' interop control is skipped: it is reactive already, and its `errors`\n * getter builds a fresh object on every read, which a reference check would call a\n * change on every pass — and re-resolve every message with it.\n */\n ngAfterContentChecked(): void {\n const control = this.ngControl()?.control;\n if (!(control instanceof AbstractControl)) {\n this.seen = null;\n return;\n }\n const { errors, touched, dirty } = control;\n const seen = this.seen;\n if (seen?.errors === errors && seen.touched === touched && seen.dirty === dirty) return;\n this.seen = { errors, touched, dirty };\n // The first sighting is only the baseline: `errors` reads `ngControl()`, so the\n // message already recomputed when the control appeared.\n if (seen) this.revision.update(n => n + 1);\n }\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('form');\n let sub: Subscription | null = null;\n effect(() => {\n const control = this.ngControl()?.control;\n sub?.unsubscribe();\n sub = (control?.events ?? EMPTY).subscribe(() => this.revision.update(n => n + 1));\n });\n inject(DestroyRef).onDestroy(() => sub?.unsubscribe());\n }\n\n protected readonly errors = computed(() => {\n this.revision();\n const c = this.ngControl();\n if (!c) return null;\n if (!c.touched && !c.dirty) return null;\n return c.errors;\n });\n\n protected readonly hasError = computed(() => {\n const errs = this.errors();\n return !!errs && Object.keys(errs).length > 0;\n });\n\n /** @internal Read by the projected `<wr-form-error>` children to decide which of them renders. */\n readonly errorKeys = computed<readonly string[]>(() => Object.keys(this.errors() ?? {}));\n\n /** @internal Read by the projected control so a screen reader is pointed at the message. */\n readonly describedBy = computed(() => (this.hasError() ? `${this.controlId()}-errors` : null));\n\n /**\n * @internal Read by the projected control so the hint is announced with the field.\n *\n * The hint used to carry no id at all, so the only thing `aria-describedby`\n * could ever name was the error block: the sentence explaining what to type was\n * on screen and reached a screen-reader user through no path whatsoever, and\n * the one gate that could have said so does not exist — axe has no rule that\n * visible help text must be programmatically associated.\n *\n * `null` while an error is showing, because the template swaps the hint out for\n * the message; publishing the id anyway would point every control at an element\n * that had just left the document.\n */\n readonly hintId = computed(() => (!this.hasError() && this.hint() ? `${this.controlId()}-hint` : null));\n\n /** @internal `WrFormFieldContext` — the id a role-based control points `aria-labelledby` at. */\n readonly labelId = computed(() => (this.label() ? `${this.controlId()}-label` : null));\n\n /**\n * Render a message for any error the markup does not already answer: the\n * validator's own `message`, else `validation.<key>` from the app's i18n\n * catalog. ngwr ships no error texts, so a key neither of them answers renders\n * nothing, and dev mode warns once for it.\n *\n * On by default: a field with no `<wr-form-error>` at all is the common case.\n * Turn it off for a field whose copy is entirely hand-written. @default true\n */\n readonly autoErrors = input(true, { transform: coerceBooleanProperty });\n\n private readonly projectedErrors = contentChildren(WrFormError);\n private readonly i18n = inject(WrI18n, { optional: true });\n private readonly isServer = !isPlatformBrowser(inject(PLATFORM_ID));\n\n /** Error keys this field has already warned about — see {@link warnNoCopy}. */\n private readonly warned = new Set<string>();\n\n /**\n * Errors with no projected `<wr-form-error key>` to answer them, resolved to\n * text. Per-field markup always wins — it is the most specific thing the author\n * wrote — and a key nothing answers is left out rather than rendered empty.\n */\n protected readonly autoMessages = computed<readonly { key: string; text: string }[]>(() => {\n if (!this.autoErrors()) return [];\n const errors = this.errors();\n if (!errors) return [];\n\n const claimed = new Set(\n this.projectedErrors()\n .map(e => e.key())\n .filter(Boolean)\n );\n\n const messages: { key: string; text: string }[] = [];\n for (const [key, error] of Object.entries(errors)) {\n if (claimed.has(key)) continue;\n const text = this.resolve(key, error);\n if (text) messages.push({ key, text });\n else if (isDevMode()) untracked(() => this.warnNoCopy(key));\n }\n return messages;\n });\n\n private resolve(rawKey: string, rawError: unknown): string | null {\n const own = ownMessage(rawError);\n if (own) return own;\n\n // `t()` reads the service's revision signal, so this recomputes on a locale\n // switch and when a loader-backed catalog lands; a miss returns the key itself.\n // ngwr's own catalogs carry no `validation` namespace, so only the app answers.\n const { key, error } = normalizeError(rawKey, rawError);\n const translated = this.i18n?.t(`validation.${key}`, toParams(error));\n return translated && translated !== `validation.${key}` ? translated : null;\n }\n\n /**\n * Say once, in dev, that an error is showing with nothing to read.\n *\n * Nothing on screen gives it away: the field still goes red and the control is\n * still marked invalid, so an empty error block survives review. With no\n * built-in copy that is the ordinary state of a validator nobody wrote words\n * for, not an edge case. Once per field and key — and once per key on the\n * server, where every prerendered page builds its fields again. The catalog key\n * is the normalised one, the markup key the one the control reported, because\n * those are what each of the two reads.\n */\n private warnNoCopy(rawKey: string): void {\n if (this.warned.has(rawKey)) return;\n this.warned.add(rawKey);\n if (this.isServer) {\n if (warnedOnServer.has(rawKey)) return;\n warnedOnServer.add(rawKey);\n }\n\n const catalogKey = normalizeError(rawKey, undefined).key;\n const field = this.label() ? `\"${this.label()}\"` : `#${this.labelFor()}`;\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] <wr-form-field> ${field}: the \"${rawKey}\" error has no copy, so nothing is shown for it — ` +\n `ngwr ships no error texts. Supply one: { message } on the validator, \"validation.${catalogKey}\" ` +\n `in the app's i18n catalog, or <wr-form-error key=\"${rawKey}\"> inside the field.`\n );\n }\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.hasError()) parts.push('wr-form-field--invalid');\n if (this.required()) parts.push('wr-form-field--required');\n return parts.join(' ');\n });\n}\n","@if (label()) {\n <label class=\"wr-form-field__label\" [attr.id]=\"labelId()\" [attr.for]=\"labelFor()\">\n {{ label() }}\n @if (required()) {\n <span class=\"wr-form-field__required\" aria-hidden=\"true\">*</span>\n } @else if (optional()) {\n <span class=\"wr-form-field__optional\">({{ resolvedOptional() }})</span>\n }\n </label>\n}\n\n<div class=\"wr-form-field__control\"><ng-content /></div>\n\n@if (hasError()) {\n <div class=\"wr-form-field__errors\" [attr.id]=\"describedBy()\">\n <ng-content select=\"wr-form-error\" />\n @for (message of autoMessages(); track message.key) {\n <div class=\"wr-form-error wr-form-field__error\" role=\"alert\" [attr.data-key]=\"message.key\">\n {{ message.text }}\n </div>\n }\n </div>\n} @else if (hint()) {\n <small class=\"wr-form-field__hint\" [attr.id]=\"hintId()\">{{ hint() }}</small>\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 Signal, computed, inject } from '@angular/core';\n\nimport { WR_FORM_FIELD } from './tokens';\n\n/** What {@link useFormFieldAria} hands a control to bind on its own element. */\nexport interface WrFormFieldAria {\n /**\n * Id of the field's message block while it is showing one, of its hint\n * otherwise, and `null` when it is showing neither.\n */\n readonly describedBy: Signal<string | null>;\n /** `'true'` while the field has a validation error, `null` otherwise. */\n readonly ariaInvalid: Signal<'true' | null>;\n /** `'true'` while the field is `required`, `null` otherwise. */\n readonly ariaRequired: Signal<'true' | null>;\n /**\n * Id of the field's `<label>`, for a control `<label for>` cannot reach.\n *\n * `for` binds only to a LABELABLE element, so a control whose focusable part\n * is a `div` with a role gets nothing from it — measured, `wr-rating`,\n * `wr-knob` and `wr-file-upload` all rendered a field label whose `for` named\n * no element in the document. Point `aria-labelledby` at this instead; a\n * control that IS labelable should ignore it and let `for` do the work, or the\n * name is announced twice.\n */\n readonly labelledBy: Signal<string | null>;\n}\n\n/**\n * The two attributes that make a `<wr-form-field>`'s visible text — its error\n * message, or its hint — reach a screen reader. Bind both on whichever element\n * carries the control's role.\n *\n * Without them the copy the field renders is visible and nothing else: the\n * control announces itself as valid, and the text is associated with nothing.\n * No automated gate catches that — axe has no rule that a visible error or hint\n * must be programmatically associated with its control — so this helper exists\n * to make the wiring one line per control rather than three, and the specs are\n * the gate.\n *\n * The field renders an error OR a hint, never both, so `describedBy` names\n * whichever is on screen and `aria-invalid` is keyed SEPARATELY, on the field's\n * `errorKeys()`. Deriving it from `describedBy` instead — which is what every\n * control did while a hint had no id to name — makes a field with a plain hint\n * announce its control as invalid the moment the hint becomes describable.\n *\n * Must be called from an injection context (a field initialiser or a\n * constructor). Returns inert signals outside a `<wr-form-field>`.\n *\n * Pass `skipSelf` from a COMPOSITE control — one whose own template renders\n * other ngwr controls. Such a component shields its subtree by re-providing\n * `WR_FORM_FIELD` as `null`, or the inner parts each announce the outer field's\n * error as their own; a component sees its own providers, so it has to read the\n * real field from one level up.\n *\n * @example\n * ```ts\n * protected readonly fieldAria = useFormFieldAria();\n * ```\n * ```html\n * <input [attr.aria-invalid]=\"fieldAria.ariaInvalid()\" [attr.aria-describedby]=\"fieldAria.describedBy()\" />\n * ```\n */\nexport function useFormFieldAria(options?: { readonly skipSelf?: boolean }): WrFormFieldAria {\n const field = inject(WR_FORM_FIELD, { optional: true, skipSelf: options?.skipSelf ?? false });\n return {\n // `hintId` is optional on the interface so an app-provided field keeps\n // compiling; one without it describes nothing but its errors, as before.\n describedBy: computed(() => field?.describedBy() ?? field?.hintId?.() ?? null),\n ariaInvalid: computed<'true' | null>(() => ((field?.errorKeys().length ?? 0) > 0 ? 'true' : null)),\n ariaRequired: computed<'true' | null>(() => (field?.required?.() ? 'true' : null)),\n // `null` for a control that `<label for>` already reaches — pointing at the\n // same label twice would name it twice. Only the role-based controls read\n // this, and only because `for` cannot bind to a role.\n labelledBy: computed(() => field?.labelId?.() ?? null),\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 { createMetadataKey } from '@angular/forms/signals';\n\n/**\n * How a field is DRAWN, attached to the same Signal Forms schema that already\n * says how it is validated.\n *\n * The alternative was a second schema — one for rules, one for presentation —\n * and it was rejected before it was written: two descriptions of one form drift\n * the moment someone renames a field in one of them, and nothing would report\n * it. Angular's `metadata()` takes a typed key and a `LogicFn`, so the\n * presentation rides on the schema the validators are already in, and it is\n * REACTIVE for free: a label, a set of options or a placeholder may depend on\n * the value of another field.\n *\n * What this deliberately does NOT carry: `required`, `disabled`, `readonly`,\n * `hidden`, `min`, `max`, and every validation rule. Those are Angular's own\n * schema functions, they already drive the control through `[formField]`, and\n * duplicating them here would create a second source of truth for state the form\n * already owns. That is not only a judgement call — Angular REFUSES a `[min]` or\n * `[required]` binding on a field-bound control (NG8022), so the second source\n * of truth is a compile error rather than a drift.\n */\nexport type WrFieldKind =\n | 'input'\n | 'textarea'\n | 'number'\n | 'select'\n | 'multiselect'\n | 'tags'\n | 'checkbox'\n | 'switch'\n | 'radio'\n | 'segmented'\n | 'date'\n | 'daterange'\n | 'slider'\n | 'rating'\n | 'file'\n | 'array';\n\n/** One choice, for the kinds that offer a list. */\nexport interface WrFieldOption {\n readonly value: unknown;\n readonly label: string;\n readonly disabled?: boolean;\n}\n\n/**\n * A titled group of fields, drawn as a `<fieldset>` with a `<legend>`.\n *\n * Fields that name the same `title` are drawn together, where the first of them\n * stands in the model's key order. The description and the column count come\n * from the first field that states them.\n */\nexport interface WrFieldSection {\n readonly title: string;\n /** A line under the title, announced as the group's description. */\n readonly description?: string;\n /** Grid columns inside the section. Defaults to the form's own `columns`. */\n readonly columns?: number;\n}\n\n/**\n * The presentation of one field.\n *\n * `kind` is the only required member: everything else has a sane default, and a\n * schema that says no more than `{ kind: 'input' }` still renders a labelled,\n * error-bound control — the label falls back to the field's own name.\n */\nexport interface WrFieldSpec {\n readonly kind: WrFieldKind;\n /** Defaults to the field's key, de-camel-cased — `workEmail` becomes \"Work email\". */\n readonly label?: string;\n readonly placeholder?: string;\n /** Help text under the control. Errors replace it while the field is invalid. */\n readonly hint?: string;\n /** For `select`, `multiselect`, `radio` and `segmented`. Ignored by every other kind. */\n readonly options?: readonly WrFieldOption[];\n /** Native `type` for `kind: 'input'` — `email`, `password`, `url`, `tel`. */\n readonly type?: string;\n /**\n * Granularity for `number` and `slider`. The BOUNDS are deliberately absent:\n * Angular refuses a `[min]` or `[max]` binding on a `[formField]`-bound\n * control outright (NG8022), because the field owns them — write `min(path.x,\n * 18)` in the schema and the control picks it up. `step` is presentation, has\n * no schema function, and stays here.\n */\n readonly step?: number;\n /**\n * Columns this field spans in `<wr-schema-form>`'s grid. Clamped to the form's\n * own `columns`, and 1 by default — a field is one cell unless it asks to be\n * wider.\n */\n readonly span?: number;\n /**\n * The section this field is drawn in: a title, or a title with a description\n * and its own column count. A field with none is drawn straight on the form's\n * grid.\n */\n readonly section?: string | WrFieldSection;\n /** For `file`: accept several files, so the field holds `File[]` rather than `File | null`. */\n readonly multiple?: boolean;\n /** For `file`: the native `accept` list, e.g. `'image/*,.pdf'`. */\n readonly accept?: string;\n /** For `file`: the most bytes one file may have. A larger file is refused. Unset or `0` is no limit. */\n readonly maxSize?: number;\n /** For `file` with `multiple`: the most files the field holds. A file past it is refused. Unset or `0` is no limit. */\n readonly maxFiles?: number;\n /**\n * For `array`: the value a new item starts as. It is what draws the Add\n * button, and an array with no `item` is a fixed list whose items can only be\n * removed. Describe the item's own fields with `applyEach(path.x, item => …)`,\n * and bound the list with `minLength` and `maxLength` on the array itself.\n */\n readonly item?: () => unknown;\n /**\n * For `array`: what one item is called, numbered in the item's heading:\n * \"Address 2\". Defaults to the field's label.\n */\n readonly itemLabel?: string;\n /** For `array`: grid columns inside each item. Defaults to 1. */\n readonly columns?: number;\n}\n\n/**\n * The metadata key `<wr-schema-form>` reads.\n *\n * ```ts\n * const userSchema = schema<User>(path => {\n * required(path.email, { message: 'Enter your email.' });\n * email(path.email, { message: 'That is not an email address.' });\n * metadata(path.email, WR_FIELD, () => ({ kind: 'input', type: 'email', label: 'Work email' }));\n * metadata(path.role, WR_FIELD, () => ({ kind: 'select', options: ROLES }));\n *\n * // A repeating group: the array is described once, its items through `applyEach`.\n * metadata(path.addresses, WR_FIELD, () => ({ kind: 'array', item: () => ({ city: '' }) }));\n * applyEach(path.addresses, item => {\n * metadata(item.city, WR_FIELD, () => ({ kind: 'input' }));\n * });\n * });\n * ```\n *\n * A field with no `WR_FIELD` metadata is not an error and is not guessed at —\n * `<wr-schema-form>` skips it, so a schema can describe more than one screen shows.\n */\nexport const WR_FIELD = createMetadataKey<WrFieldSpec>();\n\n/** `workEmail` -> `Work email`. The fallback label, and only ever a fallback. */\nexport function wrFieldLabel(key: string): string {\n const spaced = key.replace(/([a-z\\d])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' ');\n return spaced.charAt(0).toUpperCase() + spaced.slice(1).toLowerCase();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,IAAa,SAAb,MAAa,OAAM;CACjB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,MAAM;CACzE;CAQS,SAAS,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,SAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAQxD,UAAU,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EACxB,YAAY,UAA2B,KAAK,IAAI,GAAG,KAAK,MAAM,qBAAqB,OAAO,CAAC,CAAC,CAAC;CAAC,CAAA;CAG7E,OAAO,eAAe,CAAC,KAAK,OAAM,KAAM,KAAK,QAAO,IAAK,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAvBnE,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAM,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAN,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAM,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,QAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA;GAAA,YAAA;IAAA,yBAAA;IAAA,0BAAA;IAAA,2BAAA;GAAA;G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
import { DestroyRef, Directive, ElementRef, NgZone, Service, computed, effect, inject, input, output, signal } from "@angular/core";
|
|
3
3
|
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
|
4
4
|
import { DOCUMENT as DOCUMENT$1 } from "@angular/common";
|
|
5
|
-
import { WR_KEYS, WR_KEY_LABELS } from "ngwr/utils";
|
|
5
|
+
import { WR_KEYS, WR_KEY_LABELS, wrIsComposing } from "ngwr/utils";
|
|
6
6
|
import { WrPlatform } from "ngwr/platform";
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
@@ -12,6 +12,7 @@ import { WrPlatform } from "ngwr/platform";
|
|
|
12
12
|
*/
|
|
13
13
|
const KEY_ALIASES = {
|
|
14
14
|
esc: "escape",
|
|
15
|
+
plus: "+",
|
|
15
16
|
space: " ",
|
|
16
17
|
spacebar: " ",
|
|
17
18
|
enter: "enter",
|
|
@@ -44,7 +45,9 @@ function isNonLatinLetter(key) {
|
|
|
44
45
|
return /^\p{L}$/u.test(key) && !/^\p{Script=Latin}$/u.test(key);
|
|
45
46
|
}
|
|
46
47
|
function wrParseHotkeySpec(spec, isMac = false) {
|
|
47
|
-
const
|
|
48
|
+
const text = spec.trim();
|
|
49
|
+
const plusKey = text.endsWith("+");
|
|
50
|
+
const tokens = (plusKey ? text.slice(0, -1) : text).split("+").map((t) => t.trim().toLowerCase()).filter(Boolean);
|
|
48
51
|
let ctrl = false;
|
|
49
52
|
let alt = false;
|
|
50
53
|
let shift = false;
|
|
@@ -80,7 +83,7 @@ function wrParseHotkeySpec(spec, isMac = false) {
|
|
|
80
83
|
alt,
|
|
81
84
|
shift,
|
|
82
85
|
meta,
|
|
83
|
-
key
|
|
86
|
+
key: plusKey ? "+" : key
|
|
84
87
|
};
|
|
85
88
|
}
|
|
86
89
|
function wrMatchesHotkey(event, parsed) {
|
|
@@ -155,7 +158,8 @@ const FALLBACK_OPTIONS = {
|
|
|
155
158
|
allowInInput: false,
|
|
156
159
|
priority: 0
|
|
157
160
|
};
|
|
158
|
-
function isEditableTarget(
|
|
161
|
+
function isEditableTarget(event) {
|
|
162
|
+
const target = event.composedPath()[0] ?? event.target;
|
|
159
163
|
if (!(target instanceof HTMLElement)) return false;
|
|
160
164
|
const tag = target.tagName;
|
|
161
165
|
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
|
|
@@ -227,10 +231,11 @@ var WrHotkey = class WrHotkey {
|
|
|
227
231
|
dispatch(target, event) {
|
|
228
232
|
const bucket = this.registries.get(target);
|
|
229
233
|
if (!bucket || bucket.size === 0) return;
|
|
234
|
+
if (wrIsComposing(event)) return;
|
|
230
235
|
const matches = [];
|
|
231
236
|
for (const binding of bucket) {
|
|
232
237
|
if (!wrMatchesHotkey(event, binding.parsed)) continue;
|
|
233
|
-
if (!binding.options.allowInInput && isEditableTarget(event
|
|
238
|
+
if (!binding.options.allowInInput && isEditableTarget(event)) continue;
|
|
234
239
|
matches.push(binding);
|
|
235
240
|
}
|
|
236
241
|
if (matches.length === 0) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-hotkey.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/hotkey/parse-spec.ts","../../../projects/lib/hotkey/format-chord.ts","../../../projects/lib/hotkey/wr-hotkey.ts","../../../projects/lib/hotkey/wr-hotkey-binding.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrHotkeySpec } from './types';\n\n/** Map of user-friendly aliases to canonical `KeyboardEvent.key` strings. */\nconst KEY_ALIASES: Readonly<Record<string, string>> = {\n esc: 'escape',\n space: ' ',\n spacebar: ' ',\n enter: 'enter',\n return: 'enter',\n up: 'arrowup',\n down: 'arrowdown',\n left: 'arrowleft',\n right: 'arrowright',\n del: 'delete',\n};\n\n/** What the US layout prints on each punctuation key, by `KeyboardEvent.code`. */\nconst PUNCTUATION_CODES: Readonly<Record<string, string>> = {\n Backquote: '`',\n Minus: '-',\n Equal: '=',\n BracketLeft: '[',\n BracketRight: ']',\n Backslash: '\\\\',\n Semicolon: ';',\n Quote: \"'\",\n Comma: ',',\n Period: '.',\n Slash: '/',\n};\n\n/** The key a spec names for a physical key, read off the US layout, or `null`. */\nfunction physicalKey(code: string): string | null {\n if (/^Key[A-Z]$/.test(code)) return code.slice(3).toLowerCase();\n if (/^Digit\\d$/.test(code)) return code.slice(5);\n return PUNCTUATION_CODES[code] ?? null;\n}\n\n/** One letter of a script other than Latin: what a Russian, Greek or Hebrew layout types. */\nfunction isNonLatinLetter(key: string): boolean {\n return /^\\p{L}$/u.test(key) && !/^\\p{Script=Latin}$/u.test(key);\n}\n\n/** Normalised representation of a hotkey spec — easy to match against an event. */\ninterface WrParsedHotkey {\n readonly ctrl: boolean;\n readonly alt: boolean;\n readonly shift: boolean;\n readonly meta: boolean;\n /** Lowercased `KeyboardEvent.key` value the spec matches. */\n readonly key: string;\n}\n\n/**\n * Parse a hotkey spec like `'mod+shift+k'` into a normalised structure.\n *\n * @param spec - the spec to parse\n * @param isMac - when true, `mod` resolves to `meta` (Cmd); otherwise `ctrl`\n */\nfunction wrParseHotkeySpec(spec: WrHotkeySpec, isMac = false): WrParsedHotkey {\n const tokens = spec\n .split('+')\n .map(t => t.trim().toLowerCase())\n .filter(Boolean);\n\n let ctrl = false;\n let alt = false;\n let shift = false;\n let meta = false;\n let key = '';\n\n for (const token of tokens) {\n switch (token) {\n case 'ctrl':\n case 'control':\n ctrl = true;\n break;\n case 'alt':\n case 'option':\n alt = true;\n break;\n case 'shift':\n shift = true;\n break;\n case 'cmd':\n case 'command':\n case 'meta':\n case 'super':\n case 'win':\n meta = true;\n break;\n case 'mod':\n if (isMac) meta = true;\n else ctrl = true;\n break;\n default:\n key = KEY_ALIASES[token] ?? token;\n break;\n }\n }\n\n return { ctrl, alt, shift, meta, key };\n}\n\n/**\n * Does `event` satisfy the parsed hotkey?\n *\n * The typed character decides, and the physical key only stands in when that\n * character is a letter of a non-Latin script. On a Russian layout the key\n * labelled K types `л`, so `mod+k` used to be dead for anyone who had not\n * switched to English; the same goes for Greek, Hebrew or Arabic. A Latin\n * layout never falls back, not even on a letter outside ASCII: on Dvorak the key\n * labelled K types `t`, and Turkish `ı` or German `ß` are keys of their own.\n * Nor does a chord holding Alt, since macOS Option and Windows AltGr type a\n * symbol on purpose, `€` on AltGr+E among them.\n */\nfunction wrMatchesHotkey(event: KeyboardEvent, parsed: WrParsedHotkey): boolean {\n if (event.ctrlKey !== parsed.ctrl) return false;\n if (event.altKey !== parsed.alt) return false;\n if (event.shiftKey !== parsed.shift) return false;\n if (event.metaKey !== parsed.meta) return false;\n if (event.key.toLowerCase() === parsed.key) return true;\n return !event.altKey && isNonLatinLetter(event.key) && physicalKey(event.code) === parsed.key;\n}\n\nexport { wrParseHotkeySpec, wrMatchesHotkey };\nexport type { WrParsedHotkey };\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 { WR_KEYS, WR_KEY_LABELS, type WrKey } from 'ngwr/utils';\n\nimport { wrParseHotkeySpec } from './parse-spec';\nimport type { WrHotkeyPlatform, WrHotkeySpec } from './types';\n\n/** Apple's modifier glyphs, in the order its menus write them. */\nconst MAC_MODIFIERS = { ctrl: '⌃', alt: '⌥', shift: '⇧', meta: '⌘' } as const;\n\n/** The named keys macOS writes as a glyph. The rest keep their label. */\nconst MAC_KEYS: Readonly<Partial<Record<WrKey, string>>> = {\n [WR_KEYS.ENTER]: '↩',\n [WR_KEYS.ESCAPE]: '⎋',\n [WR_KEYS.TAB]: '⇥',\n [WR_KEYS.BACKSPACE]: '⌫',\n [WR_KEYS.DELETE]: '⌦',\n [WR_KEYS.HOME]: '↖',\n [WR_KEYS.END]: '↘',\n [WR_KEYS.PAGE_UP]: '⇞',\n [WR_KEYS.PAGE_DOWN]: '⇟',\n};\n\n/** `WR_KEYS` by the lowercased form the spec parser produces. */\nconst KEY_BY_LOWER: ReadonlyMap<string, WrKey> = new Map(\n (Object.values(WR_KEYS) as WrKey[]).map(key => [key.toLowerCase(), key])\n);\n\n/** The key token as the spec typed it, since the parser lowercases: `'mod+F5'` keeps `F5`. */\nfunction asTyped(chord: string, lower: string): string {\n const token = chord.split('+').find(t => t.trim().toLowerCase() === lower);\n return token?.trim() ?? lower;\n}\n\n/**\n * The platform a chord is written for, from a user agent: `'mac'` when it\n * names a Mac (iPhone and iPad say \"like Mac OS X\", and their hardware\n * keyboards carry ⌘ too), `'other'` elsewhere. Reads `navigator.userAgent`\n * when called without one, and answers `'other'` where there is no\n * navigator, which is the server.\n */\nexport function wrHotkeyPlatform(userAgent: string | null = globalThis.navigator?.userAgent ?? null): WrHotkeyPlatform {\n return (userAgent ?? '').toLowerCase().includes('mac') ? 'mac' : 'other';\n}\n\n/**\n * A chord written the way the platform writes it: `'mod+k'` is `⌘K` on macOS\n * and `Ctrl+K` elsewhere, `'mod+shift+k'` is `⇧⌘K` and `Ctrl+Shift+K`.\n * Modifiers follow Apple's order (`⌃⌥⇧⌘`) on a Mac and Win, Ctrl, Alt, Shift\n * elsewhere. A named key is labelled from `WR_KEY_LABELS` in `ngwr/utils`, with\n * Apple's glyph on a Mac (`↩`, `⎋`, `⌫`); an arrow is its glyph everywhere; a\n * letter is uppercased; a key neither table knows is passed through as typed.\n *\n * `platform` defaults to {@link wrHotkeyPlatform}, which reads\n * `navigator.userAgent`. The server has none and gets the `Ctrl` form, so a\n * page that prints the default during hydration on a Mac renders `Ctrl+K` and\n * must not switch to `⌘K` until hydration is done: `wr-kbd` reads the platform\n * in `afterNextRender` for that reason. Pass `platform` from such a signal, or\n * let `wr-kbd` print the chord.\n *\n * `labels` replaces a word from `WR_KEY_LABELS` by its `WR_KEYS` value, for a\n * translation; `wr-kbd` passes the i18n catalog's. A glyph is never replaced.\n */\nexport function wrFormatChord(\n chord: WrHotkeySpec,\n platform: WrHotkeyPlatform = wrHotkeyPlatform(),\n labels: Readonly<Partial<Record<WrKey, string>>> = {}\n): string {\n const parsed = wrParseHotkeySpec(chord, platform === 'mac');\n const label = (key: WrKey): string => labels[key] ?? WR_KEY_LABELS[key];\n\n const known = KEY_BY_LOWER.get(parsed.key);\n let key: string;\n if (known) key = (platform === 'mac' ? MAC_KEYS[known] : undefined) ?? label(known);\n else if (parsed.key.length === 1) key = parsed.key.toUpperCase();\n else key = asTyped(chord, parsed.key);\n\n if (platform === 'mac') {\n const mods = (['ctrl', 'alt', 'shift', 'meta'] as const).filter(mod => parsed[mod]).map(mod => MAC_MODIFIERS[mod]);\n return `${mods.join('')}${key}`;\n }\n\n const parts: string[] = [];\n if (parsed.meta) parts.push(label(WR_KEYS.META));\n if (parsed.ctrl) parts.push(label(WR_KEYS.CONTROL));\n if (parsed.alt) parts.push(label(WR_KEYS.ALT));\n if (parsed.shift) parts.push(label(WR_KEYS.SHIFT));\n parts.push(key);\n return parts.join('+');\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 { DOCUMENT } from '@angular/common';\nimport { DestroyRef, Service, NgZone, type Signal, computed, inject, signal } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\n\nimport { wrHotkeyPlatform } from './format-chord';\nimport { wrMatchesHotkey, wrParseHotkeySpec, type WrParsedHotkey } from './parse-spec';\nimport type { WrHotkeyEntry, WrHotkeyHandle, WrHotkeyOptions, WrHotkeySpec } from './types';\n\ninterface Binding {\n readonly parsed: WrParsedHotkey;\n readonly handler: (event: KeyboardEvent) => void;\n readonly options: Required<Omit<WrHotkeyOptions, 'label'>>;\n readonly entry: WrHotkeyEntry;\n}\n\nconst FALLBACK_OPTIONS: Required<Omit<WrHotkeyOptions, 'label'>> = {\n element: undefined as unknown as HTMLElement,\n preventDefault: true,\n allowInInput: false,\n priority: 0,\n};\n\nfunction isEditableTarget(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) return false;\n const tag = target.tagName;\n if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return true;\n return target.isContentEditable;\n}\n\n/**\n * Global keybinding registry.\n *\n * Bindings are keyed off `KeyboardEvent.key` + modifier state, and a letter\n * shortcut also fires on a non-Latin layout, by the physical key. Multiple\n * handlers per chord fire in priority order; a handler that calls\n * `event.preventDefault()` stops lower-priority bindings on that key.\n *\n * The listener runs outside Angular — only matched bindings re-enter\n * the zone, so an idle page doesn't trigger CD on every keystroke.\n *\n * Use `[wrHotkey]` for declarative element-scoped bindings. `bindings` lists\n * what is registered, with the `label` each registration gave, for a cheat\n * sheet; `wrFormatChord` writes a chord the way the platform does.\n *\n * @example\n * ```ts\n * const hotkeys = inject(WrHotkey);\n * const handle = hotkeys.bind('mod+k', () => openCommandPalette(), { label: 'Open the palette' });\n * // ...later\n * handle.unbind();\n * ```\n *\n * @see https://ngwr.dev/reference/services/hotkey\n */\n@Service()\nexport class WrHotkey {\n private readonly doc = inject(DOCUMENT);\n private readonly zone = inject(NgZone);\n private readonly platform = inject(WrPlatform);\n private readonly destroyRef = inject(DestroyRef);\n\n private readonly isMac = wrHotkeyPlatform(this.platform.userAgent) === 'mac';\n\n /** Bindings grouped by listener target. */\n private readonly registries = new Map<EventTarget, Set<Binding>>();\n\n /** Every registered binding, in registration order. Above `bindings`, which reads it. */\n private readonly registered = signal<readonly Binding[]>([]);\n\n /**\n * The active bindings, in registration order, each with its chord as\n * registered and the `label` its registration gave. A binding leaves when its\n * handle unbinds, which `[wrHotkey]` does on destroy.\n */\n readonly bindings: Signal<readonly WrHotkeyEntry[]> = computed(() => this.registered().map(b => b.entry));\n\n constructor() {\n // Every listener belongs to this injector. Provided at the root that is the\n // whole application, but a route or component that provides its own\n // `WrHotkey` used to leave its `keydown` listeners on the document after it\n // was destroyed — still dispatching into handlers whose component was gone.\n this.destroyRef.onDestroy(() => {\n for (const target of [...this.listeners.keys()]) this.detach(target);\n this.registries.clear();\n this.registered.set([]);\n });\n }\n\n /** Register a binding. */\n bind(spec: WrHotkeySpec, handler: (event: KeyboardEvent) => void, options: WrHotkeyOptions = {}): WrHotkeyHandle {\n const parsed = wrParseHotkeySpec(spec, this.isMac);\n const { label = null, ...rest } = options;\n const resolved: Required<Omit<WrHotkeyOptions, 'label'>> = { ...FALLBACK_OPTIONS, ...rest };\n const target: EventTarget = resolved.element ?? this.doc;\n const binding: Binding = { parsed, handler, options: resolved, entry: { chord: spec, label } };\n\n let bucket = this.registries.get(target);\n if (!bucket) {\n bucket = new Set();\n this.registries.set(target, bucket);\n this.attach(target);\n }\n bucket.add(binding);\n this.registered.update(list => [...list, binding]);\n\n return {\n unbind: () => {\n // Look the bucket up again rather than closing over it, and let\n // `Set.delete` report whether this binding was still in it. The captured\n // bucket could be a REPLACED one: unbind the last binding, register a\n // new one for the same target, then call the old handle a second time —\n // which is ordinary, a directive releasing on destroy and on an input\n // change — and the stale empty set read as \"nothing left here\", taking\n // the live binding's listener down with it.\n const current = this.registries.get(target);\n if (!current?.delete(binding)) return;\n this.registered.update(list => list.filter(b => b !== binding));\n if (current.size === 0) {\n this.registries.delete(target);\n this.detach(target);\n }\n },\n };\n }\n\n // Internals\n\n private readonly listeners = new Map<EventTarget, EventListener>();\n\n private attach(target: EventTarget): void {\n const listener: EventListener = event => this.dispatch(target, event as KeyboardEvent);\n this.zone.runOutsideAngular(() => target.addEventListener('keydown', listener));\n this.listeners.set(target, listener);\n }\n\n private detach(target: EventTarget): void {\n const listener = this.listeners.get(target);\n if (!listener) return;\n target.removeEventListener('keydown', listener);\n this.listeners.delete(target);\n }\n\n private dispatch(target: EventTarget, event: KeyboardEvent): void {\n const bucket = this.registries.get(target);\n if (!bucket || bucket.size === 0) return;\n\n const matches: Binding[] = [];\n for (const binding of bucket) {\n if (!wrMatchesHotkey(event, binding.parsed)) continue;\n if (!binding.options.allowInInput && isEditableTarget(event.target)) continue;\n matches.push(binding);\n }\n if (matches.length === 0) return;\n\n matches.sort((a, b) => b.options.priority - a.options.priority);\n\n this.zone.run(() => {\n // Two different questions, one flag. `preventDefault` is browser\n // suppression; `defaultPrevented` after a handler ran is how this service\n // reads \"that handler claimed the chord\". Applying the option first and\n // then reading the flag back meant the service saw its OWN mark as a\n // claim, so under the shipped default (`preventDefault: true`) only the\n // top-priority binding on a chord ever ran. Deferring the option's call to\n // the end keeps the flag inside the loop reporting only what a HANDLER\n // did — the rule this class already documents — and leaves a binding free\n // to suppress the browser AND claim the chord. The entry snapshot matters\n // too: another listener earlier in the propagation path may have\n // prevented the event already, and that is nobody's claim here.\n const preventedOnEntry = event.defaultPrevented;\n let suppress = false;\n\n for (const binding of matches) {\n binding.handler(event);\n if (binding.options.preventDefault) suppress = true;\n if (!preventedOnEntry && event.defaultPrevented) break;\n }\n\n if (suppress) event.preventDefault();\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { DestroyRef, Directive, ElementRef, effect, inject, input, output } from '@angular/core';\n\nimport type { WrHotkeyHandle, WrHotkeySpec } from './types';\nimport { WrHotkey } from './wr-hotkey';\n\n/**\n * Declarative wrapper around {@link WrHotkey}.\n *\n * Binds on init (and re-binds when the spec changes), unbinds on destroy.\n * Defaults to global scope so the binding works regardless of focus —\n * pass `[scoped]=\"true\"` to limit it to the host element.\n *\n * @example\n * ```html\n * <button (wrHotkeyMatch)=\"open()\" [wrHotkey]=\"'mod+k'\">Open palette</button>\n * <div tabindex=\"0\" [wrHotkey]=\"'escape'\" [scoped]=\"true\" (wrHotkeyMatch)=\"close()\">…</div>\n * ```\n */\n@Directive({ selector: '[wrHotkey]' })\nexport class WrHotkeyBinding {\n /**\n * The chord to listen for — `'mod+k'`, `'shift+?'`, or the full spec object.\n * `mod` resolves to ⌘ on macOS and Ctrl everywhere else.\n */\n readonly wrHotkey = input.required<WrHotkeySpec>();\n\n /** Scope the binding to the host element instead of `document`. @default false */\n readonly scoped = input(false, { transform: coerceBooleanProperty });\n\n /** Fire even when an input / textarea has focus. @default false */\n readonly allowInInput = input(false, { transform: coerceBooleanProperty });\n\n /** Suppress the default action when the binding fires. @default true */\n readonly preventDefault = input(true, { transform: coerceBooleanProperty });\n\n /** What the shortcut does, listed by `WrHotkey.bindings` for a cheat sheet. @default null */\n readonly hotkeyLabel = input<string | null>(null);\n\n /** Emits the original KeyboardEvent on match. */\n readonly wrHotkeyMatch = output<KeyboardEvent>();\n\n private readonly hotkeys = inject(WrHotkey);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private handle: WrHotkeyHandle | null = null;\n\n constructor() {\n effect(() => {\n this.handle?.unbind();\n this.handle = this.hotkeys.bind(this.wrHotkey(), event => this.wrHotkeyMatch.emit(event), {\n element: this.scoped() ? this.host.nativeElement : undefined,\n allowInInput: this.allowInInput(),\n preventDefault: this.preventDefault(),\n label: this.hotkeyLabel() ?? undefined,\n });\n });\n inject(DestroyRef).onDestroy(() => this.handle?.unbind());\n }\n}\n"],"mappings":";;;;;;;;;;;;AAUA,MAAM,cAAgD;CACpD,KAAK;CACL,OAAO;CACP,UAAU;CACV,OAAO;CACP,QAAQ;CACR,IAAI;CACJ,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;AACN;AAGD,MAAM,oBAAsD;CAC1D,WAAW;CACX,OAAO;CACP,OAAO;CACP,aAAa;CACb,cAAc;CACd,WAAW;CACX,WAAW;CACX,OAAO;CACP,OAAO;CACP,QAAQ;CACR,OAAO;AACR;AAGD,SAAS,YAAY,MAAY;CAC/B,IAAI,aAAa,KAAK,IAAI,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,YAAW;CAC7D,IAAI,YAAY,KAAK,IAAI,GAAG,OAAO,KAAK,MAAM,CAAC;CAC/C,OAAO,kBAAkB,SAAS;AACpC;AAGA,SAAS,iBAAiB,KAAW;CACnC,O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Af,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAe,YAAA,CAAA;EAD3B,MAAA;EAAU,MAAA,CAAA,EAAE,UAAU,aAAY,CAAE"}
|
|
1
|
+
{"version":3,"file":"ngwr-hotkey.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/hotkey/parse-spec.ts","../../../projects/lib/hotkey/format-chord.ts","../../../projects/lib/hotkey/wr-hotkey.ts","../../../projects/lib/hotkey/wr-hotkey-binding.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrHotkeySpec } from './types';\n\n/** Map of user-friendly aliases to canonical `KeyboardEvent.key` strings. */\nconst KEY_ALIASES: Readonly<Record<string, string>> = {\n esc: 'escape',\n plus: '+',\n space: ' ',\n spacebar: ' ',\n enter: 'enter',\n return: 'enter',\n up: 'arrowup',\n down: 'arrowdown',\n left: 'arrowleft',\n right: 'arrowright',\n del: 'delete',\n};\n\n/** What the US layout prints on each punctuation key, by `KeyboardEvent.code`. */\nconst PUNCTUATION_CODES: Readonly<Record<string, string>> = {\n Backquote: '`',\n Minus: '-',\n Equal: '=',\n BracketLeft: '[',\n BracketRight: ']',\n Backslash: '\\\\',\n Semicolon: ';',\n Quote: \"'\",\n Comma: ',',\n Period: '.',\n Slash: '/',\n};\n\n/** The key a spec names for a physical key, read off the US layout, or `null`. */\nfunction physicalKey(code: string): string | null {\n if (/^Key[A-Z]$/.test(code)) return code.slice(3).toLowerCase();\n if (/^Digit\\d$/.test(code)) return code.slice(5);\n return PUNCTUATION_CODES[code] ?? null;\n}\n\n/** One letter of a script other than Latin: what a Russian, Greek or Hebrew layout types. */\nfunction isNonLatinLetter(key: string): boolean {\n return /^\\p{L}$/u.test(key) && !/^\\p{Script=Latin}$/u.test(key);\n}\n\n/** Normalised representation of a hotkey spec — easy to match against an event. */\ninterface WrParsedHotkey {\n readonly ctrl: boolean;\n readonly alt: boolean;\n readonly shift: boolean;\n readonly meta: boolean;\n /** Lowercased `KeyboardEvent.key` value the spec matches. */\n readonly key: string;\n}\n\n/**\n * Parse a hotkey spec like `'mod+shift+k'` into a normalised structure.\n *\n * @param spec - the spec to parse\n * @param isMac - when true, `mod` resolves to `meta` (Cmd); otherwise `ctrl`\n */\nfunction wrParseHotkeySpec(spec: WrHotkeySpec, isMac = false): WrParsedHotkey {\n // A trailing `+` is the plus key itself: `mod++`, `ctrl+shift++`.\n const text = spec.trim();\n const plusKey = text.endsWith('+');\n const tokens = (plusKey ? text.slice(0, -1) : text)\n .split('+')\n .map(t => t.trim().toLowerCase())\n .filter(Boolean);\n\n let ctrl = false;\n let alt = false;\n let shift = false;\n let meta = false;\n let key = '';\n\n for (const token of tokens) {\n switch (token) {\n case 'ctrl':\n case 'control':\n ctrl = true;\n break;\n case 'alt':\n case 'option':\n alt = true;\n break;\n case 'shift':\n shift = true;\n break;\n case 'cmd':\n case 'command':\n case 'meta':\n case 'super':\n case 'win':\n meta = true;\n break;\n case 'mod':\n if (isMac) meta = true;\n else ctrl = true;\n break;\n default:\n key = KEY_ALIASES[token] ?? token;\n break;\n }\n }\n\n return { ctrl, alt, shift, meta, key: plusKey ? '+' : key };\n}\n\n/**\n * Does `event` satisfy the parsed hotkey?\n *\n * The typed character decides, and the physical key only stands in when that\n * character is a letter of a non-Latin script. On a Russian layout the key\n * labelled K types `л`, so `mod+k` used to be dead for anyone who had not\n * switched to English; the same goes for Greek, Hebrew or Arabic. A Latin\n * layout never falls back, not even on a letter outside ASCII: on Dvorak the key\n * labelled K types `t`, and Turkish `ı` or German `ß` are keys of their own.\n * Nor does a chord holding Alt, since macOS Option and Windows AltGr type a\n * symbol on purpose, `€` on AltGr+E among them.\n */\nfunction wrMatchesHotkey(event: KeyboardEvent, parsed: WrParsedHotkey): boolean {\n if (event.ctrlKey !== parsed.ctrl) return false;\n if (event.altKey !== parsed.alt) return false;\n if (event.shiftKey !== parsed.shift) return false;\n if (event.metaKey !== parsed.meta) return false;\n if (event.key.toLowerCase() === parsed.key) return true;\n return !event.altKey && isNonLatinLetter(event.key) && physicalKey(event.code) === parsed.key;\n}\n\nexport { wrParseHotkeySpec, wrMatchesHotkey };\nexport type { WrParsedHotkey };\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 { WR_KEYS, WR_KEY_LABELS, type WrKey } from 'ngwr/utils';\n\nimport { wrParseHotkeySpec } from './parse-spec';\nimport type { WrHotkeyPlatform, WrHotkeySpec } from './types';\n\n/** Apple's modifier glyphs, in the order its menus write them. */\nconst MAC_MODIFIERS = { ctrl: '⌃', alt: '⌥', shift: '⇧', meta: '⌘' } as const;\n\n/** The named keys macOS writes as a glyph. The rest keep their label. */\nconst MAC_KEYS: Readonly<Partial<Record<WrKey, string>>> = {\n [WR_KEYS.ENTER]: '↩',\n [WR_KEYS.ESCAPE]: '⎋',\n [WR_KEYS.TAB]: '⇥',\n [WR_KEYS.BACKSPACE]: '⌫',\n [WR_KEYS.DELETE]: '⌦',\n [WR_KEYS.HOME]: '↖',\n [WR_KEYS.END]: '↘',\n [WR_KEYS.PAGE_UP]: '⇞',\n [WR_KEYS.PAGE_DOWN]: '⇟',\n};\n\n/** `WR_KEYS` by the lowercased form the spec parser produces. */\nconst KEY_BY_LOWER: ReadonlyMap<string, WrKey> = new Map(\n (Object.values(WR_KEYS) as WrKey[]).map(key => [key.toLowerCase(), key])\n);\n\n/** The key token as the spec typed it, since the parser lowercases: `'mod+F5'` keeps `F5`. */\nfunction asTyped(chord: string, lower: string): string {\n const token = chord.split('+').find(t => t.trim().toLowerCase() === lower);\n return token?.trim() ?? lower;\n}\n\n/**\n * The platform a chord is written for, from a user agent: `'mac'` when it\n * names a Mac (iPhone and iPad say \"like Mac OS X\", and their hardware\n * keyboards carry ⌘ too), `'other'` elsewhere. Reads `navigator.userAgent`\n * when called without one, and answers `'other'` where there is no\n * navigator, which is the server.\n */\nexport function wrHotkeyPlatform(userAgent: string | null = globalThis.navigator?.userAgent ?? null): WrHotkeyPlatform {\n return (userAgent ?? '').toLowerCase().includes('mac') ? 'mac' : 'other';\n}\n\n/**\n * A chord written the way the platform writes it: `'mod+k'` is `⌘K` on macOS\n * and `Ctrl+K` elsewhere, `'mod+shift+k'` is `⇧⌘K` and `Ctrl+Shift+K`.\n * Modifiers follow Apple's order (`⌃⌥⇧⌘`) on a Mac and Win, Ctrl, Alt, Shift\n * elsewhere. A named key is labelled from `WR_KEY_LABELS` in `ngwr/utils`, with\n * Apple's glyph on a Mac (`↩`, `⎋`, `⌫`); an arrow is its glyph everywhere; a\n * letter is uppercased; a key neither table knows is passed through as typed.\n *\n * `platform` defaults to {@link wrHotkeyPlatform}, which reads\n * `navigator.userAgent`. The server has none and gets the `Ctrl` form, so a\n * page that prints the default during hydration on a Mac renders `Ctrl+K` and\n * must not switch to `⌘K` until hydration is done: `wr-kbd` reads the platform\n * in `afterNextRender` for that reason. Pass `platform` from such a signal, or\n * let `wr-kbd` print the chord.\n *\n * `labels` replaces a word from `WR_KEY_LABELS` by its `WR_KEYS` value, for a\n * translation; `wr-kbd` passes the i18n catalog's. A glyph is never replaced.\n */\nexport function wrFormatChord(\n chord: WrHotkeySpec,\n platform: WrHotkeyPlatform = wrHotkeyPlatform(),\n labels: Readonly<Partial<Record<WrKey, string>>> = {}\n): string {\n const parsed = wrParseHotkeySpec(chord, platform === 'mac');\n const label = (key: WrKey): string => labels[key] ?? WR_KEY_LABELS[key];\n\n const known = KEY_BY_LOWER.get(parsed.key);\n let key: string;\n if (known) key = (platform === 'mac' ? MAC_KEYS[known] : undefined) ?? label(known);\n else if (parsed.key.length === 1) key = parsed.key.toUpperCase();\n else key = asTyped(chord, parsed.key);\n\n if (platform === 'mac') {\n const mods = (['ctrl', 'alt', 'shift', 'meta'] as const).filter(mod => parsed[mod]).map(mod => MAC_MODIFIERS[mod]);\n return `${mods.join('')}${key}`;\n }\n\n const parts: string[] = [];\n if (parsed.meta) parts.push(label(WR_KEYS.META));\n if (parsed.ctrl) parts.push(label(WR_KEYS.CONTROL));\n if (parsed.alt) parts.push(label(WR_KEYS.ALT));\n if (parsed.shift) parts.push(label(WR_KEYS.SHIFT));\n parts.push(key);\n return parts.join('+');\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 { DOCUMENT } from '@angular/common';\nimport { DestroyRef, Service, NgZone, type Signal, computed, inject, signal } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrIsComposing } from 'ngwr/utils';\n\nimport { wrHotkeyPlatform } from './format-chord';\nimport { wrMatchesHotkey, wrParseHotkeySpec, type WrParsedHotkey } from './parse-spec';\nimport type { WrHotkeyEntry, WrHotkeyHandle, WrHotkeyOptions, WrHotkeySpec } from './types';\n\ninterface Binding {\n readonly parsed: WrParsedHotkey;\n readonly handler: (event: KeyboardEvent) => void;\n readonly options: Required<Omit<WrHotkeyOptions, 'label'>>;\n readonly entry: WrHotkeyEntry;\n}\n\nconst FALLBACK_OPTIONS: Required<Omit<WrHotkeyOptions, 'label'>> = {\n element: undefined as unknown as HTMLElement,\n preventDefault: true,\n allowInInput: false,\n priority: 0,\n};\n\n/** `event.target` is retargeted to the host of an open shadow root, so the real origin is the first of the composed path. */\nfunction isEditableTarget(event: Event): boolean {\n const target = event.composedPath()[0] ?? event.target;\n if (!(target instanceof HTMLElement)) return false;\n const tag = target.tagName;\n if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return true;\n return target.isContentEditable;\n}\n\n/**\n * Global keybinding registry.\n *\n * Bindings are keyed off `KeyboardEvent.key` + modifier state, and a letter\n * shortcut also fires on a non-Latin layout, by the physical key. Multiple\n * handlers per chord fire in priority order; a handler that calls\n * `event.preventDefault()` stops lower-priority bindings on that key.\n *\n * The listener runs outside Angular — only matched bindings re-enter\n * the zone, so an idle page doesn't trigger CD on every keystroke.\n *\n * Use `[wrHotkey]` for declarative element-scoped bindings. `bindings` lists\n * what is registered, with the `label` each registration gave, for a cheat\n * sheet; `wrFormatChord` writes a chord the way the platform does.\n *\n * @example\n * ```ts\n * const hotkeys = inject(WrHotkey);\n * const handle = hotkeys.bind('mod+k', () => openCommandPalette(), { label: 'Open the palette' });\n * // ...later\n * handle.unbind();\n * ```\n *\n * @see https://ngwr.dev/reference/services/hotkey\n */\n@Service()\nexport class WrHotkey {\n private readonly doc = inject(DOCUMENT);\n private readonly zone = inject(NgZone);\n private readonly platform = inject(WrPlatform);\n private readonly destroyRef = inject(DestroyRef);\n\n private readonly isMac = wrHotkeyPlatform(this.platform.userAgent) === 'mac';\n\n /** Bindings grouped by listener target. */\n private readonly registries = new Map<EventTarget, Set<Binding>>();\n\n /** Every registered binding, in registration order. Above `bindings`, which reads it. */\n private readonly registered = signal<readonly Binding[]>([]);\n\n /**\n * The active bindings, in registration order, each with its chord as\n * registered and the `label` its registration gave. A binding leaves when its\n * handle unbinds, which `[wrHotkey]` does on destroy.\n */\n readonly bindings: Signal<readonly WrHotkeyEntry[]> = computed(() => this.registered().map(b => b.entry));\n\n constructor() {\n // Every listener belongs to this injector. Provided at the root that is the\n // whole application, but a route or component that provides its own\n // `WrHotkey` used to leave its `keydown` listeners on the document after it\n // was destroyed — still dispatching into handlers whose component was gone.\n this.destroyRef.onDestroy(() => {\n for (const target of [...this.listeners.keys()]) this.detach(target);\n this.registries.clear();\n this.registered.set([]);\n });\n }\n\n /** Register a binding. */\n bind(spec: WrHotkeySpec, handler: (event: KeyboardEvent) => void, options: WrHotkeyOptions = {}): WrHotkeyHandle {\n const parsed = wrParseHotkeySpec(spec, this.isMac);\n const { label = null, ...rest } = options;\n const resolved: Required<Omit<WrHotkeyOptions, 'label'>> = { ...FALLBACK_OPTIONS, ...rest };\n const target: EventTarget = resolved.element ?? this.doc;\n const binding: Binding = { parsed, handler, options: resolved, entry: { chord: spec, label } };\n\n let bucket = this.registries.get(target);\n if (!bucket) {\n bucket = new Set();\n this.registries.set(target, bucket);\n this.attach(target);\n }\n bucket.add(binding);\n this.registered.update(list => [...list, binding]);\n\n return {\n unbind: () => {\n // Look the bucket up again rather than closing over it, and let\n // `Set.delete` report whether this binding was still in it. The captured\n // bucket could be a REPLACED one: unbind the last binding, register a\n // new one for the same target, then call the old handle a second time —\n // which is ordinary, a directive releasing on destroy and on an input\n // change — and the stale empty set read as \"nothing left here\", taking\n // the live binding's listener down with it.\n const current = this.registries.get(target);\n if (!current?.delete(binding)) return;\n this.registered.update(list => list.filter(b => b !== binding));\n if (current.size === 0) {\n this.registries.delete(target);\n this.detach(target);\n }\n },\n };\n }\n\n // Internals\n\n private readonly listeners = new Map<EventTarget, EventListener>();\n\n private attach(target: EventTarget): void {\n const listener: EventListener = event => this.dispatch(target, event as KeyboardEvent);\n this.zone.runOutsideAngular(() => target.addEventListener('keydown', listener));\n this.listeners.set(target, listener);\n }\n\n private detach(target: EventTarget): void {\n const listener = this.listeners.get(target);\n if (!listener) return;\n target.removeEventListener('keydown', listener);\n this.listeners.delete(target);\n }\n\n private dispatch(target: EventTarget, event: KeyboardEvent): void {\n const bucket = this.registries.get(target);\n if (!bucket || bucket.size === 0) return;\n // A key that drives an IME candidate window is not a shortcut.\n if (wrIsComposing(event)) return;\n\n const matches: Binding[] = [];\n for (const binding of bucket) {\n if (!wrMatchesHotkey(event, binding.parsed)) continue;\n if (!binding.options.allowInInput && isEditableTarget(event)) continue;\n matches.push(binding);\n }\n if (matches.length === 0) return;\n\n matches.sort((a, b) => b.options.priority - a.options.priority);\n\n this.zone.run(() => {\n // Two different questions, one flag. `preventDefault` is browser\n // suppression; `defaultPrevented` after a handler ran is how this service\n // reads \"that handler claimed the chord\". Applying the option first and\n // then reading the flag back meant the service saw its OWN mark as a\n // claim, so under the shipped default (`preventDefault: true`) only the\n // top-priority binding on a chord ever ran. Deferring the option's call to\n // the end keeps the flag inside the loop reporting only what a HANDLER\n // did — the rule this class already documents — and leaves a binding free\n // to suppress the browser AND claim the chord. The entry snapshot matters\n // too: another listener earlier in the propagation path may have\n // prevented the event already, and that is nobody's claim here.\n const preventedOnEntry = event.defaultPrevented;\n let suppress = false;\n\n for (const binding of matches) {\n binding.handler(event);\n if (binding.options.preventDefault) suppress = true;\n if (!preventedOnEntry && event.defaultPrevented) break;\n }\n\n if (suppress) event.preventDefault();\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { DestroyRef, Directive, ElementRef, effect, inject, input, output } from '@angular/core';\n\nimport type { WrHotkeyHandle, WrHotkeySpec } from './types';\nimport { WrHotkey } from './wr-hotkey';\n\n/**\n * Declarative wrapper around {@link WrHotkey}.\n *\n * Binds on init (and re-binds when the spec changes), unbinds on destroy.\n * Defaults to global scope so the binding works regardless of focus —\n * pass `[scoped]=\"true\"` to limit it to the host element.\n *\n * @example\n * ```html\n * <button (wrHotkeyMatch)=\"open()\" [wrHotkey]=\"'mod+k'\">Open palette</button>\n * <div tabindex=\"0\" [wrHotkey]=\"'escape'\" [scoped]=\"true\" (wrHotkeyMatch)=\"close()\">…</div>\n * ```\n */\n@Directive({ selector: '[wrHotkey]' })\nexport class WrHotkeyBinding {\n /**\n * The chord to listen for — `'mod+k'`, `'shift+?'`, or the full spec object.\n * `mod` resolves to ⌘ on macOS and Ctrl everywhere else.\n */\n readonly wrHotkey = input.required<WrHotkeySpec>();\n\n /** Scope the binding to the host element instead of `document`. @default false */\n readonly scoped = input(false, { transform: coerceBooleanProperty });\n\n /** Fire even when an input / textarea has focus. @default false */\n readonly allowInInput = input(false, { transform: coerceBooleanProperty });\n\n /** Suppress the default action when the binding fires. @default true */\n readonly preventDefault = input(true, { transform: coerceBooleanProperty });\n\n /** What the shortcut does, listed by `WrHotkey.bindings` for a cheat sheet. @default null */\n readonly hotkeyLabel = input<string | null>(null);\n\n /** Emits the original KeyboardEvent on match. */\n readonly wrHotkeyMatch = output<KeyboardEvent>();\n\n private readonly hotkeys = inject(WrHotkey);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private handle: WrHotkeyHandle | null = null;\n\n constructor() {\n effect(() => {\n this.handle?.unbind();\n this.handle = this.hotkeys.bind(this.wrHotkey(), event => this.wrHotkeyMatch.emit(event), {\n element: this.scoped() ? this.host.nativeElement : undefined,\n allowInInput: this.allowInInput(),\n preventDefault: this.preventDefault(),\n label: this.hotkeyLabel() ?? undefined,\n });\n });\n inject(DestroyRef).onDestroy(() => this.handle?.unbind());\n }\n}\n"],"mappings":";;;;;;;;;;;;AAUA,MAAM,cAAgD;CACpD,KAAK;CACL,MAAM;CACN,OAAO;CACP,UAAU;CACV,OAAO;CACP,QAAQ;CACR,IAAI;CACJ,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;AACN;AAGD,MAAM,oBAAsD;CAC1D,WAAW;CACX,OAAO;CACP,OAAO;CACP,aAAa;CACb,cAAc;CACd,WAAW;CACX,WAAW;CACX,OAAO;CACP,OAAO;CACP,QAAQ;CACR,OAAO;AACR;AAGD,SAAS,YAAY,MAAY;CAC/B,IAAI,aAAa,KAAK,IAAI,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,YAAW;CAC7D,IAAI,YAAY,KAAK,IAAI,GAAG,OAAO,KAAK,MAAM,CAAC;CAC/C,OAAO,kBAAkB,SAAS;AACpC;AAGA,SAAS,iBAAiB,KAAW;CACnC,OAAO,WAAW,KAAK,GAAG,KAAK,CAAC,sBAAsB,KAAK,GAAG;AAChE;AAkBA,SAAS,kBAAkB,MAAoB,QAAQ,OAAK;CAE1D,MAAM,OAAO,KAAK,KAAI;CACtB,MAAM,UAAU,KAAK,SAAS,GAAG;CACjC,MAAM,UAAU,UAAU,KAAK,MAAM,GAAG,EAAE,IAAI,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;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAe,YAAA,CAAA;EAD3B,MAAA;EAAU,MAAA,CAAA,EAAE,UAAU,aAAY,CAAE"}
|
|
@@ -79,7 +79,9 @@ const wrAr = {
|
|
|
79
79
|
splitter: { divider: "تغيير حجم الأجزاء" },
|
|
80
80
|
stepper: {
|
|
81
81
|
optional: "اختياري",
|
|
82
|
-
completed: "مكتملة"
|
|
82
|
+
completed: "مكتملة",
|
|
83
|
+
error: "خطأ",
|
|
84
|
+
warning: "تحذير"
|
|
83
85
|
},
|
|
84
86
|
transfer: {
|
|
85
87
|
source: "المتاح",
|
|
@@ -90,7 +92,8 @@ const wrAr = {
|
|
|
90
92
|
toTarget: "النقل إلى المحدد",
|
|
91
93
|
toSource: "النقل إلى المتاح",
|
|
92
94
|
count: "{{checked}} / {{total}}",
|
|
93
|
-
selectAllAria: "{{pane}} — {{action}}"
|
|
95
|
+
selectAllAria: "{{pane}} — {{action}}",
|
|
96
|
+
searchAria: "{{title}} - {{search}}"
|
|
94
97
|
},
|
|
95
98
|
form: { optional: "اختياري" },
|
|
96
99
|
select: {
|
|
@@ -198,7 +201,10 @@ const wrAr = {
|
|
|
198
201
|
imageCropper: {
|
|
199
202
|
empty: "لا توجد صورة",
|
|
200
203
|
window: "منطقة الاقتصاص",
|
|
201
|
-
keyHelp: "مفاتيح الأسهم تحرّك منطقة الاقتصاص. اضغط باستمرار على Alt مع أحد مفاتيح الأسهم لتغيير حجمها، وعلى Shift لخطوات أكبر. يُعلن عن المنطقة بقيم اليسار والأعلى والعرض والارتفاع بالبكسل داخل الصورة."
|
|
204
|
+
keyHelp: "مفاتيح الأسهم تحرّك منطقة الاقتصاص. اضغط باستمرار على Alt مع أحد مفاتيح الأسهم لتغيير حجمها، وعلى Shift لخطوات أكبر. يُعلن عن المنطقة بقيم اليسار والأعلى والعرض والارتفاع بالبكسل داخل الصورة.",
|
|
205
|
+
transformHelp: "مفتاحا زائد وناقص يكبّران الصورة ويصغّرانها. المفتاح R يديرها في اتجاه عقارب الساعة، و Shift مع R في الاتجاه المعاكس.",
|
|
206
|
+
zoomed: "نسبة التكبير {{percent}}%",
|
|
207
|
+
rotated: "تم التدوير {{degrees}}°"
|
|
202
208
|
},
|
|
203
209
|
sortableList: {
|
|
204
210
|
keyHelp: "اضغط مفتاح المسافة لالتقاط هذا العنصر، ثم استخدم مفاتيح الأسهم لتحريكه. اضغط مفتاح المسافة مرة أخرى لإفلاته، أو Escape لإعادته إلى مكانه.",
|
|
@@ -247,7 +253,9 @@ const wrAr = {
|
|
|
247
253
|
},
|
|
248
254
|
donutChart: {
|
|
249
255
|
label: "مخطط دائري مجوف",
|
|
250
|
-
pieLabel: "مخطط دائري"
|
|
256
|
+
pieLabel: "مخطط دائري",
|
|
257
|
+
value: "القيمة",
|
|
258
|
+
share: "الحصة"
|
|
251
259
|
},
|
|
252
260
|
chartLegend: {
|
|
253
261
|
toggleLabel: "إظهار السلاسل أو إخفاؤها",
|
|
@@ -459,7 +467,12 @@ const wrAr = {
|
|
|
459
467
|
fit: "ملاءمة العرض"
|
|
460
468
|
},
|
|
461
469
|
progress: { label: "التقدم" },
|
|
462
|
-
meterGroup: {
|
|
470
|
+
meterGroup: {
|
|
471
|
+
label: "مقياس",
|
|
472
|
+
value: "القيمة",
|
|
473
|
+
share: "الحصة"
|
|
474
|
+
},
|
|
475
|
+
sparkline: { value: "القيمة" },
|
|
463
476
|
knob: { label: "القيمة" },
|
|
464
477
|
slider: {
|
|
465
478
|
label: "القيمة",
|