@memberjunction/ng-ui-components 6.2.0-edge.0 → 6.2.0-edge.2

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.
Files changed (81) hide show
  1. package/README.md +43 -10
  2. package/dist/lib/a11y/named-control.base.d.ts +91 -0
  3. package/dist/lib/a11y/named-control.base.d.ts.map +1 -0
  4. package/dist/lib/a11y/named-control.base.js +121 -0
  5. package/dist/lib/a11y/named-control.base.js.map +1 -0
  6. package/dist/lib/a11y/unnamed-control-guard.d.ts +52 -0
  7. package/dist/lib/a11y/unnamed-control-guard.d.ts.map +1 -0
  8. package/dist/lib/a11y/unnamed-control-guard.js +94 -0
  9. package/dist/lib/a11y/unnamed-control-guard.js.map +1 -0
  10. package/dist/lib/accordion/accordion.component.d.ts +16 -4
  11. package/dist/lib/accordion/accordion.component.d.ts.map +1 -1
  12. package/dist/lib/accordion/accordion.component.js +36 -12
  13. package/dist/lib/accordion/accordion.component.js.map +1 -1
  14. package/dist/lib/applied-filters/applied-filters.component.js.map +1 -1
  15. package/dist/lib/button/button.directive.d.ts +34 -6
  16. package/dist/lib/button/button.directive.d.ts.map +1 -1
  17. package/dist/lib/button/button.directive.js +85 -25
  18. package/dist/lib/button/button.directive.js.map +1 -1
  19. package/dist/lib/card-grid/card-grid.component.d.ts +3 -1
  20. package/dist/lib/card-grid/card-grid.component.d.ts.map +1 -1
  21. package/dist/lib/card-grid/card-grid.component.js +13 -9
  22. package/dist/lib/card-grid/card-grid.component.js.map +1 -1
  23. package/dist/lib/clickable/clickable.directive.d.ts +11 -3
  24. package/dist/lib/clickable/clickable.directive.d.ts.map +1 -1
  25. package/dist/lib/clickable/clickable.directive.js +25 -5
  26. package/dist/lib/clickable/clickable.directive.js.map +1 -1
  27. package/dist/lib/combobox/combobox.component.d.ts +44 -3
  28. package/dist/lib/combobox/combobox.component.d.ts.map +1 -1
  29. package/dist/lib/combobox/combobox.component.js +135 -51
  30. package/dist/lib/combobox/combobox.component.js.map +1 -1
  31. package/dist/lib/confirm-dialog/confirm-dialog.component.d.ts +6 -0
  32. package/dist/lib/confirm-dialog/confirm-dialog.component.d.ts.map +1 -1
  33. package/dist/lib/confirm-dialog/confirm-dialog.component.js +16 -4
  34. package/dist/lib/confirm-dialog/confirm-dialog.component.js.map +1 -1
  35. package/dist/lib/datepicker/datepicker.component.d.ts +28 -2
  36. package/dist/lib/datepicker/datepicker.component.d.ts.map +1 -1
  37. package/dist/lib/datepicker/datepicker.component.js +114 -42
  38. package/dist/lib/datepicker/datepicker.component.js.map +1 -1
  39. package/dist/lib/dialog/dialog.component.d.ts +82 -2
  40. package/dist/lib/dialog/dialog.component.d.ts.map +1 -1
  41. package/dist/lib/dialog/dialog.component.js +302 -12
  42. package/dist/lib/dialog/dialog.component.js.map +1 -1
  43. package/dist/lib/dialog/dialog.service.js.map +1 -1
  44. package/dist/lib/dropdown/dropdown.component.d.ts +19 -44
  45. package/dist/lib/dropdown/dropdown.component.d.ts.map +1 -1
  46. package/dist/lib/dropdown/dropdown.component.js +45 -76
  47. package/dist/lib/dropdown/dropdown.component.js.map +1 -1
  48. package/dist/lib/dropdown/dropdown.scss +0 -16
  49. package/dist/lib/filter-panel/filter-panel.component.d.ts +8 -0
  50. package/dist/lib/filter-panel/filter-panel.component.d.ts.map +1 -1
  51. package/dist/lib/filter-panel/filter-panel.component.js +25 -9
  52. package/dist/lib/filter-panel/filter-panel.component.js.map +1 -1
  53. package/dist/lib/numeric-input/numeric-input.component.d.ts +15 -1
  54. package/dist/lib/numeric-input/numeric-input.component.d.ts.map +1 -1
  55. package/dist/lib/numeric-input/numeric-input.component.js +36 -9
  56. package/dist/lib/numeric-input/numeric-input.component.js.map +1 -1
  57. package/dist/lib/page-search/page-search.component.d.ts +32 -3
  58. package/dist/lib/page-search/page-search.component.d.ts.map +1 -1
  59. package/dist/lib/page-search/page-search.component.js +68 -12
  60. package/dist/lib/page-search/page-search.component.js.map +1 -1
  61. package/dist/lib/switch/switch.component.d.ts +22 -1
  62. package/dist/lib/switch/switch.component.d.ts.map +1 -1
  63. package/dist/lib/switch/switch.component.js +50 -16
  64. package/dist/lib/switch/switch.component.js.map +1 -1
  65. package/dist/lib/tabs/tab-chrome-guard.d.ts +2 -0
  66. package/dist/lib/tabs/tab-chrome-guard.d.ts.map +1 -1
  67. package/dist/lib/tabs/tab-chrome-guard.js +5 -1
  68. package/dist/lib/tabs/tab-chrome-guard.js.map +1 -1
  69. package/dist/lib/window/window.component.d.ts +10 -0
  70. package/dist/lib/window/window.component.d.ts.map +1 -1
  71. package/dist/lib/window/window.component.js +27 -7
  72. package/dist/lib/window/window.component.js.map +1 -1
  73. package/dist/lib/workspace-tabs/workspace-tab-strip.component.d.ts +10 -0
  74. package/dist/lib/workspace-tabs/workspace-tab-strip.component.d.ts.map +1 -1
  75. package/dist/lib/workspace-tabs/workspace-tab-strip.component.js +27 -7
  76. package/dist/lib/workspace-tabs/workspace-tab-strip.component.js.map +1 -1
  77. package/dist/public-api.d.ts +2 -0
  78. package/dist/public-api.d.ts.map +1 -1
  79. package/dist/public-api.js +2 -0
  80. package/dist/public-api.js.map +1 -1
  81. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"confirm-dialog.component.js","sourceRoot":"","sources":["../../../src/lib/confirm-dialog/confirm-dialog.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;;;;IA4ErD,uBAAmG;;;IAAhG,cAAA,+FAAwE,CAAA;;;IAIzE,4BAA+B;IAAA,YAAa;IAAA,iBAAI;;;IAAjB,cAAa;IAAb,oCAAa;;;IAG5C,4BAA8B;IAAA,YAAmB;IAAA,iBAAI;;;IAAvB,cA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,CAAC,YAC/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CT;;kBAiCA,KAAK;;kBAEL,MAAM;;kBAGN,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAML,KAAK;;kBAOL,KAAK;mBAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE;;kBAGrC,MAAM;;kBAGN,MAAM;;kFAzCI,wBAAwB","sourcesContent":["import { Component, EventEmitter, Input, Output, booleanAttribute } from '@angular/core';\nimport { MJDialogComponent, MJDialogActionsComponent } from '../dialog/dialog.component';\nimport { MJButtonDirective } from '../button/button.directive';\n\n/**\n * Visual intent of an `<mj-confirm-dialog>`. Drives the header icon and the\n * confirm button's color, so callers rarely restate either.\n *\n * - `default` — a neutral question (e.g. \"Discard unsaved changes?\"). Blue confirm button.\n * - `danger` — a destructive / irreversible action (delete). Red confirm button.\n * - `warning` — a non-destructive but consequential action. Blue confirm button, caution icon.\n * - `info` — an informational confirmation. Blue confirm button, info icon.\n */\nexport type MJConfirmDialogType = 'default' | 'danger' | 'warning' | 'info';\n\nconst DEFAULT_ICONS: Record<MJConfirmDialogType, string> = {\n default: 'fa-solid fa-circle-question',\n danger: 'fa-solid fa-triangle-exclamation',\n warning: 'fa-solid fa-triangle-exclamation',\n info: 'fa-solid fa-circle-info',\n};\n\n/**\n * mj-confirm-dialog — Canonical confirmation prompt. The shared replacement for\n * native `window.confirm()` and the many hand-rolled \"Are you sure?\" modals\n * (`@if (showDeleteConfirm) { … backdrop + centered dialog }`) scattered across\n * the app, plus the duplicate local `mj-confirm-dialog` / `mj-ev-confirm-dialog`\n * components.\n *\n * Built on `<mj-dialog>` (so it inherits the backdrop, animations, mobile\n * full-screen behavior, and Esc/backdrop handling) and uses `role=\"alertdialog\"`\n * for screen readers. Buttons follow the MJ convention: the affirmative action\n * is **leftmost**, Cancel on the right.\n *\n * Visibility is two-way bindable. Cancelling (Cancel button, backdrop, Esc, or\n * the ✕) auto-closes and emits `Cancelled`. Confirming emits `Confirmed` and\n * **leaves the dialog open** so the handler can run async work — set `Visible`\n * to `false` (or update your bound property) when done. Bind `[Processing]` to a\n * loading flag during that async work to show a spinner, disable both buttons,\n * and block dismissal until it completes.\n *\n * Usage:\n * ```html\n * <!-- Simple destructive confirm -->\n * <mj-confirm-dialog\n * [(Visible)]=\"showDeleteConfirm\"\n * Type=\"danger\"\n * Title=\"Delete view\"\n * Message=\"Are you sure you want to delete this view?\"\n * DetailMessage=\"This action cannot be undone.\"\n * ConfirmText=\"Delete\"\n * (Confirmed)=\"onDeleteConfirmed()\">\n * </mj-confirm-dialog>\n *\n * <!-- Async confirm with a spinner while the work runs -->\n * <mj-confirm-dialog\n * [(Visible)]=\"confirmOpen\"\n * [Processing]=\"isDeleting\"\n * Type=\"danger\" Title=\"Delete user\" Message=\"Remove this user permanently?\"\n * ConfirmText=\"Delete\" (Confirmed)=\"deleteUser()\">\n * </mj-confirm-dialog>\n * ```\n */\n@Component({\n selector: 'mj-confirm-dialog',\n standalone: true,\n imports: [MJDialogComponent, MJDialogActionsComponent, MJButtonDirective],\n template: `\n <mj-dialog\n [Visible]=\"Visible\"\n [Title]=\"Title\"\n Size=\"sm\"\n Role=\"alertdialog\"\n [Closeable]=\"!Processing\"\n (Close)=\"onDismiss()\">\n\n <div class=\"mj-confirm\">\n @if (ResolvedIcon) {\n <i class=\"mj-confirm__icon mj-confirm__icon--{{ Type }} {{ ResolvedIcon }}\" aria-hidden=\"true\"></i>\n }\n <div class=\"mj-confirm__body\">\n @if (Message) {\n <p class=\"mj-confirm__message\">{{ Message }}</p>\n }\n @if (DetailMessage) {\n <p class=\"mj-confirm__detail\">{{ DetailMessage }}</p>\n }\n <ng-content></ng-content>\n </div>\n </div>\n\n <mj-dialog-actions>\n <button\n mjButton\n [variant]=\"ConfirmVariant\"\n [disabled]=\"Processing\"\n (click)=\"onConfirm()\">\n @if (Processing) {\n <i class=\"fa-solid fa-spinner fa-spin\" aria-hidden=\"true\"></i>\n }\n {{ ConfirmText }}\n </button>\n <button\n mjButton\n variant=\"secondary\"\n [disabled]=\"Processing\"\n (click)=\"onCancel()\">\n {{ CancelText }}\n </button>\n </mj-dialog-actions>\n </mj-dialog>\n `,\n styles: [`\n .mj-confirm {\n display: flex;\n align-items: flex-start;\n gap: var(--mj-space-3);\n }\n .mj-confirm__icon {\n flex-shrink: 0;\n font-size: 1.5rem;\n margin-top: 0.05em;\n color: var(--mj-text-muted);\n }\n .mj-confirm__icon--danger { color: var(--mj-status-error); }\n .mj-confirm__icon--warning { color: var(--mj-status-warning); }\n .mj-confirm__icon--info { color: var(--mj-status-info); }\n\n .mj-confirm__body { flex: 1; min-width: 0; }\n .mj-confirm__message {\n margin: 0;\n color: var(--mj-text-primary);\n line-height: 1.5;\n }\n .mj-confirm__detail {\n margin: var(--mj-space-2) 0 0;\n font-size: var(--mj-text-sm);\n color: var(--mj-text-secondary);\n line-height: 1.45;\n }\n `]\n})\nexport class MJConfirmDialogComponent {\n /** Whether the dialog is shown. Two-way bindable: `[(Visible)]`. */\n @Input() Visible = false;\n /** Two-way `Visible` change channel — fires when the dialog auto-closes on cancel. */\n @Output() VisibleChange = new EventEmitter<boolean>();\n\n /** Heading shown in the dialog title bar. */\n @Input() Title = 'Confirm';\n\n /** Primary prompt text. For rich content, project default `<ng-content>` instead. */\n @Input() Message = 'Are you sure?';\n\n /** Optional secondary line, rendered smaller/muted beneath the message. */\n @Input() DetailMessage = '';\n\n /** Visual intent — drives the header icon + confirm button color. Defaults to 'default'. */\n @Input() Type: MJConfirmDialogType = 'default';\n\n /** Affirmative button label. */\n @Input() ConfirmText = 'Confirm';\n\n /** Dismiss button label. */\n @Input() CancelText = 'Cancel';\n\n /**\n * Font Awesome icon class (e.g. \"fa-solid fa-trash\") for the header. When\n * omitted, a sensible default is chosen from `Type`. Set to `''` for no icon.\n */\n @Input() Icon: string | null = null;\n\n /**\n * When true, shows a spinner on the confirm button, disables both buttons, and\n * blocks dismissal (Esc / backdrop / ✕) — bind this to your loading flag while\n * the `Confirmed` handler runs async work.\n */\n @Input({ transform: booleanAttribute }) Processing = false;\n\n /** Fired when the user confirms. The dialog stays open; close it when ready. */\n @Output() Confirmed = new EventEmitter<void>();\n\n /** Fired when the user cancels (button, backdrop, Esc, or ✕). The dialog auto-closes. */\n @Output() Cancelled = new EventEmitter<void>();\n\n /** mjButton variant for the confirm button — red for `danger`, blue otherwise. */\n get ConfirmVariant(): 'primary' | 'danger' {\n return this.Type === 'danger' ? 'danger' : 'primary';\n }\n\n /**\n * Icon actually rendered: the explicit `Icon` when provided (including `\"\"`\n * to suppress it), otherwise the per-type default.\n */\n get ResolvedIcon(): string {\n if (this.Icon != null) {\n return this.Icon;\n }\n return DEFAULT_ICONS[this.Type] ?? DEFAULT_ICONS.default;\n }\n\n onConfirm(): void {\n this.Confirmed.emit();\n }\n\n onCancel(): void {\n this.close();\n this.Cancelled.emit();\n }\n\n /** Backdrop / Esc / ✕ from the underlying dialog — ignored while Processing. */\n onDismiss(): void {\n if (this.Processing) {\n return;\n }\n this.onCancel();\n }\n\n private close(): void {\n this.Visible = false;\n this.VisibleChange.emit(false);\n }\n}\n"]}
1
+ {"version":3,"file":"confirm-dialog.component.js","sourceRoot":"","sources":["../../../src/lib/confirm-dialog/confirm-dialog.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;;;;IA4ErD,uBAAmG;;;IAAhG,cAAA,+FAAwE,CAAA;;;IAIzE,4BAA+B;IAAA,YAAa;IAAA,iBAAI;;;IAAjB,cAAa;IAAb,oCAAa;;;IAG5C,4BAA8B;IAAA,YAAmB;IAAA,iB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BACH;YAEvB,cAEC;YAFD,yCAEC;YACD,cACF;YADE,gDACF;YAIE,cAAuB;YAAvB,yCAAuB;YAEvB,cACF;YADE,+CACF;4BA1CI,iBAAiB,EAAE,wBAAwB,EAAE,iBAAiB;;iFA4E7D,wBAAwB;cA/EpC,SAAS;2BACE,mBAAmB,cACjB,IAAI,WACP,CAAC,iBAAiB,EAAE,wBAAwB,EAAE,iBAAiB,CAAC,YAC/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CT;;kBAiCA,KAAK;;kBAEL,MAAM;;kBAGN,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAML,KAAK;;kBAOL,KAAK;mBAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE;;kBAGrC,MAAM;;kBAGN,MAAM;;kFAzCI,wBAAwB","sourcesContent":["import { Component, EventEmitter, Input, Output, booleanAttribute } from '@angular/core';\nimport { MJDialogComponent, MJDialogActionsComponent } from '../dialog/dialog.component';\nimport { MJButtonDirective } from '../button/button.directive';\n\n/**\n * Visual intent of an `<mj-confirm-dialog>`. Drives the header icon and the\n * confirm button's color, so callers rarely restate either.\n *\n * - `default` — a neutral question (e.g. \"Discard unsaved changes?\"). Blue confirm button.\n * - `danger` — a destructive / irreversible action (delete). Red confirm button.\n * - `warning` — a non-destructive but consequential action. Blue confirm button, caution icon.\n * - `info` — an informational confirmation. Blue confirm button, info icon.\n */\nexport type MJConfirmDialogType = 'default' | 'danger' | 'warning' | 'info';\n\nconst DEFAULT_ICONS: Record<MJConfirmDialogType, string> = {\n default: 'fa-solid fa-circle-question',\n danger: 'fa-solid fa-triangle-exclamation',\n warning: 'fa-solid fa-triangle-exclamation',\n info: 'fa-solid fa-circle-info',\n};\n\n/**\n * mj-confirm-dialog — Canonical confirmation prompt. The shared replacement for\n * native `window.confirm()` and the many hand-rolled \"Are you sure?\" modals\n * (`@if (showDeleteConfirm) { … backdrop + centered dialog }`) scattered across\n * the app, plus the duplicate local `mj-confirm-dialog` / `mj-ev-confirm-dialog`\n * components.\n *\n * Built on `<mj-dialog>` (so it inherits the backdrop, animations, mobile\n * full-screen behavior, and Esc/backdrop handling) and uses `role=\"alertdialog\"`\n * for screen readers. Buttons follow the MJ convention: the affirmative action\n * is **leftmost**, Cancel on the right.\n *\n * Visibility is two-way bindable. Cancelling (Cancel button, backdrop, Esc, or\n * the ✕) auto-closes and emits `Cancelled`. Confirming emits `Confirmed` and\n * **leaves the dialog open** so the handler can run async work — set `Visible`\n * to `false` (or update your bound property) when done. Bind `[Processing]` to a\n * loading flag during that async work to show a spinner, disable both buttons,\n * and block dismissal until it completes.\n *\n * Usage:\n * ```html\n * <!-- Simple destructive confirm -->\n * <mj-confirm-dialog\n * [(Visible)]=\"showDeleteConfirm\"\n * Type=\"danger\"\n * Title=\"Delete view\"\n * Message=\"Are you sure you want to delete this view?\"\n * DetailMessage=\"This action cannot be undone.\"\n * ConfirmText=\"Delete\"\n * (Confirmed)=\"onDeleteConfirmed()\">\n * </mj-confirm-dialog>\n *\n * <!-- Async confirm with a spinner while the work runs -->\n * <mj-confirm-dialog\n * [(Visible)]=\"confirmOpen\"\n * [Processing]=\"isDeleting\"\n * Type=\"danger\" Title=\"Delete user\" Message=\"Remove this user permanently?\"\n * ConfirmText=\"Delete\" (Confirmed)=\"deleteUser()\">\n * </mj-confirm-dialog>\n * ```\n */\n@Component({\n selector: 'mj-confirm-dialog',\n standalone: true,\n imports: [MJDialogComponent, MJDialogActionsComponent, MJButtonDirective],\n template: `\n <mj-dialog\n [Visible]=\"Visible\"\n [Title]=\"Title\"\n Size=\"sm\"\n Role=\"alertdialog\"\n [Closeable]=\"!Processing\"\n (Close)=\"onDismiss()\">\n\n <div class=\"mj-confirm\">\n @if (ResolvedIcon) {\n <i class=\"mj-confirm__icon mj-confirm__icon--{{ Type }} {{ ResolvedIcon }}\" aria-hidden=\"true\"></i>\n }\n <div class=\"mj-confirm__body\">\n @if (Message) {\n <p class=\"mj-confirm__message\">{{ Message }}</p>\n }\n @if (DetailMessage) {\n <p class=\"mj-confirm__detail\">{{ DetailMessage }}</p>\n }\n <ng-content></ng-content>\n </div>\n </div>\n\n <mj-dialog-actions>\n <button\n mjButton\n [variant]=\"ConfirmVariant\"\n [disabled]=\"Processing\"\n (click)=\"onConfirm()\">\n @if (Processing) {\n <i class=\"fa-solid fa-spinner fa-spin\" aria-hidden=\"true\"></i>\n }\n {{ ConfirmText }}\n </button>\n <button\n mjButton\n variant=\"secondary\"\n [disabled]=\"Processing\"\n (click)=\"onCancel()\">\n {{ CancelText }}\n </button>\n </mj-dialog-actions>\n </mj-dialog>\n `,\n styles: [`\n .mj-confirm {\n display: flex;\n align-items: flex-start;\n gap: var(--mj-space-3);\n }\n .mj-confirm__icon {\n flex-shrink: 0;\n font-size: 1.5rem;\n margin-top: 0.05em;\n color: var(--mj-text-muted);\n }\n .mj-confirm__icon--danger { color: var(--mj-status-error); }\n .mj-confirm__icon--warning { color: var(--mj-status-warning); }\n .mj-confirm__icon--info { color: var(--mj-status-info); }\n\n .mj-confirm__body { flex: 1; min-width: 0; }\n .mj-confirm__message {\n margin: 0;\n color: var(--mj-text-primary);\n line-height: 1.5;\n }\n .mj-confirm__detail {\n margin: var(--mj-space-2) 0 0;\n font-size: var(--mj-text-sm);\n color: var(--mj-text-secondary);\n line-height: 1.45;\n }\n `]\n})\nexport class MJConfirmDialogComponent {\n /** Whether the dialog is shown. Two-way bindable: `[(Visible)]`. */\n @Input() Visible = false;\n /** Two-way `Visible` change channel — fires when the dialog auto-closes on cancel. */\n @Output() VisibleChange = new EventEmitter<boolean>();\n\n /** Heading shown in the dialog title bar. */\n @Input() Title = 'Confirm';\n\n /** Primary prompt text. For rich content, project default `<ng-content>` instead. */\n @Input() Message = 'Are you sure?';\n\n /** Optional secondary line, rendered smaller/muted beneath the message. */\n @Input() DetailMessage = '';\n\n /** Visual intent — drives the header icon + confirm button color. Defaults to 'default'. */\n @Input() Type: MJConfirmDialogType = 'default';\n\n /** Affirmative button label. */\n @Input() ConfirmText = 'Confirm';\n\n /** Dismiss button label. */\n @Input() CancelText = 'Cancel';\n\n /**\n * Font Awesome icon class (e.g. \"fa-solid fa-trash\") for the header. When\n * omitted, a sensible default is chosen from `Type`. Set to `''` for no icon.\n */\n @Input() Icon: string | null = null;\n\n /**\n * When true, shows a spinner on the confirm button, disables both buttons, and\n * blocks dismissal (Esc / backdrop / ✕) — bind this to your loading flag while\n * the `Confirmed` handler runs async work.\n */\n @Input({ transform: booleanAttribute }) Processing = false;\n\n /** Fired when the user confirms. The dialog stays open; close it when ready. */\n @Output() Confirmed = new EventEmitter<void>();\n\n /** Fired when the user cancels (button, backdrop, Esc, or ✕). The dialog auto-closes. */\n @Output() Cancelled = new EventEmitter<void>();\n\n /** mjButton variant for the confirm button — red for `danger`, blue otherwise. */\n get ConfirmVariant(): 'primary' | 'danger' {\n return this.Type === 'danger' ? 'danger' : 'primary';\n }\n\n /**\n * Icon actually rendered: the explicit `Icon` when provided (including `\"\"`\n * to suppress it), otherwise the per-type default.\n */\n get ResolvedIcon(): string {\n if (this.Icon != null) {\n return this.Icon;\n }\n return DEFAULT_ICONS[this.Type] ?? DEFAULT_ICONS.default;\n }\n\n OnConfirm(): void {\n this.Confirmed.emit();\n }\n\n /** @deprecated Use {@link OnConfirm}. */\n onConfirm(): void {\n return this.OnConfirm();\n }\n\n OnCancel(): void {\n this.close();\n this.Cancelled.emit();\n }\n\n /** @deprecated Use {@link OnCancel}. */\n onCancel(): void {\n return this.OnCancel();\n }\n\n /** Backdrop / Esc / ✕ from the underlying dialog — ignored while Processing. */\n OnDismiss(): void {\n if (this.Processing) {\n return;\n }\n this.OnCancel();\n }\n\n /** @deprecated Use {@link OnDismiss}. */\n onDismiss(): void {\n return this.OnDismiss();\n }\n\n private close(): void {\n this.Visible = false;\n this.VisibleChange.emit(false);\n }\n}\n"]}
@@ -1,12 +1,25 @@
1
- import { EventEmitter, OnDestroy } from '@angular/core';
1
+ import { AfterViewInit, EventEmitter, OnDestroy } from '@angular/core';
2
2
  import { ControlValueAccessor } from '@angular/forms';
3
3
  import { ConnectedPosition } from '@angular/cdk/overlay';
4
4
  import { CalendarDay } from '../calendar/calendar-utils';
5
+ import { MJNamedControlBase } from '../a11y/named-control.base';
5
6
  import * as i0 from "@angular/core";
6
7
  /**
7
8
  * mj-datepicker — Date picker with calendar popup. Replaces `<kendo-datepicker>`.
9
+ *
10
+ * Without an accessible name the date field announces as "edit, blank" and its calendar popup as a
11
+ * generic "Calendar" — so a form with a start date and an end date presents two identical grids
12
+ * (WCAG 2.1 4.1.2). Use {@link MJNamedControlBase.AriaLabelledBy} when a visible label exists,
13
+ * {@link MJNamedControlBase.AriaLabel} when none does; the toggle button and the calendar take
14
+ * their names from the same source. The field is a real `<input>`, so
15
+ * {@link MJNamedControlBase.InputId} IS a valid `<label for>` target.
16
+ *
17
+ * @example
18
+ * ```html
19
+ * <mj-datepicker AriaLabel="Due date" [(ngModel)]="dueDate" [Min]="minDate" />
20
+ * ```
8
21
  */
9
- export declare class MJDatepickerComponent implements ControlValueAccessor, OnDestroy {
22
+ export declare class MJDatepickerComponent extends MJNamedControlBase implements ControlValueAccessor, AfterViewInit, OnDestroy {
10
23
  Min: Date | null;
11
24
  Max: Date | null;
12
25
  Format: string;
@@ -21,6 +34,7 @@ export declare class MJDatepickerComponent implements ControlValueAccessor, OnDe
21
34
  get Disabled(): boolean;
22
35
  ValueChange: EventEmitter<Date | null>;
23
36
  private triggerEl;
37
+ private dateInputEl;
24
38
  readonly hostClass = true;
25
39
  private cdr;
26
40
  IsOpen: boolean;
@@ -34,6 +48,15 @@ export declare class MJDatepickerComponent implements ControlValueAccessor, OnDe
34
48
  private onChange;
35
49
  private onTouched;
36
50
  get MonthYearLabel(): string;
51
+ /** `aria-labelledby` id list for the toggle button when a VISIBLE label names the field. */
52
+ get ToggleLabelledBy(): string;
53
+ /** `aria-label` for the toggle button in the no-visible-label case. */
54
+ get ToggleLabel(): string;
55
+ /** `aria-labelledby` id list for the calendar grid when a VISIBLE label names the field. */
56
+ get CalendarLabelledBy(): string;
57
+ /** `aria-label` for the calendar grid in the no-visible-label case. */
58
+ get CalendarLabel(): string;
59
+ ngAfterViewInit(): void;
37
60
  Toggle(): void;
38
61
  Open(): void;
39
62
  Close(): void;
@@ -63,6 +86,9 @@ export declare class MJDatepickerComponent implements ControlValueAccessor, OnDe
63
86
  OnInputChange(event: Event): void;
64
87
  OnBlur(): void;
65
88
  OnKeyDown(event: KeyboardEvent): void;
89
+ /** Tab in the calendar closes it and returns to the field. The key is not cancelled, so the browser moves on from that field. */
90
+ OnCalendarKeyDown(event: KeyboardEvent): void;
91
+ private returnTabToField;
66
92
  writeValue(value: Date | string | null): void;
67
93
  registerOnChange(fn: (value: Date | null) => void): void;
68
94
  registerOnTouched(fn: () => void): void;
@@ -1 +1 @@
1
- {"version":3,"file":"datepicker.component.d.ts","sourceRoot":"","sources":["../../../src/lib/datepicker/datepicker.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,YAAY,EAAkD,SAAS,EAA6B,MAAM,eAAe,CAAC;AAC7J,OAAO,EAAqB,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAiB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAgE,MAAM,4BAA4B,CAAC;;AAEvH;;GAEG;AACH,qBAkDa,qBAAsB,YAAW,oBAAoB,EAAE,SAAS;IAClE,GAAG,EAAE,IAAI,GAAG,IAAI,CAAQ;IACxB,GAAG,EAAE,IAAI,GAAG,IAAI,CAAQ;IACxB,MAAM,SAAgB;IACtB,WAAW,SAAM;IAC1B;;;;;OAKG;IACH,IACI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAsD;IACjF,IAAI,QAAQ,IAAI,OAAO,CAA+B;IAC5C,WAAW,4BAAmC;IAClC,OAAO,CAAC,SAAS,CAA2B;IACzB,QAAQ,C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
@@ -2,12 +2,15 @@ import { Component, Input, Output, EventEmitter, forwardRef, HostBinding, ViewCh
2
2
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
3
3
  import { OverlayModule } from '@angular/cdk/overlay';
4
4
  import { WEEK_DAYS, BuildCalendarWeeks, FormatDate, GetMonthYearLabel } from '../calendar/calendar-utils';
5
+ import { MJNamedControlBase } from '../a11y/named-control.base';
6
+ import { WarnIfUnnamed } from '../a11y/unnamed-control-guard';
5
7
  import * as i0 from "@angular/core";
6
8
  import * as i1 from "@angular/cdk/overlay";
7
9
  const _c0 = ["trigger"];
10
+ const _c1 = ["dateInput"];
8
11
  const _forTrack0 = ($index, $item) => $item.date.getTime();
9
- function MJDatepickerComponent_ng_template_7_For_10_Template(rf, ctx) { if (rf & 1) {
10
- i0.ɵɵelementStart(0, "span", 15);
12
+ function MJDatepickerComponent_ng_template_11_For_10_Template(rf, ctx) { if (rf & 1) {
13
+ i0.ɵɵelementStart(0, "span", 16);
11
14
  i0.ɵɵtext(1);
12
15
  i0.ɵɵelementEnd();
13
16
  } if (rf & 2) {
@@ -15,10 +18,10 @@ function MJDatepickerComponent_ng_template_7_For_10_Template(rf, ctx) { if (rf &
15
18
  i0.ɵɵadvance();
16
19
  i0.ɵɵtextInterpolate(day_r3);
17
20
  } }
18
- function MJDatepickerComponent_ng_template_7_For_12_For_2_Template(rf, ctx) { if (rf & 1) {
21
+ function MJDatepickerComponent_ng_template_11_For_12_For_2_Template(rf, ctx) { if (rf & 1) {
19
22
  const _r4 = i0.ɵɵgetCurrentView();
20
- i0.ɵɵelementStart(0, "button", 20);
21
- i0.ɵɵlistener("click", function MJDatepickerComponent_ng_template_7_For_12_For_2_Template_button_click_0_listener() { const day_r5 = i0.ɵɵrestoreView(_r4).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.SelectDate(day_r5)); });
23
+ i0.ɵɵelementStart(0, "button", 21);
24
+ i0.ɵɵlistener("click", function MJDatepickerComponent_ng_template_11_For_12_For_2_Template_button_click_0_listener() { const day_r5 = i0.ɵɵrestoreView(_r4).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.SelectDate(day_r5)); });
22
25
  i0.ɵɵtext(1);
23
26
  i0.ɵɵelementEnd();
24
27
  } if (rf & 2) {
@@ -30,38 +33,41 @@ function MJDatepickerComponent_ng_template_7_For_12_For_2_Template(rf, ctx) { if
30
33
  i0.ɵɵadvance();
31
34
  i0.ɵɵtextInterpolate(day_r5.dayNumber);
32
35
  } }
33
- function MJDatepickerComponent_ng_template_7_For_12_Template(rf, ctx) { if (rf & 1) {
34
- i0.ɵɵelementStart(0, "div", 16);
35
- i0.ɵɵrepeaterCreate(1, MJDatepickerComponent_ng_template_7_For_12_For_2_Template, 2, 9, "button", 19, _forTrack0);
36
+ function MJDatepickerComponent_ng_template_11_For_12_Template(rf, ctx) { if (rf & 1) {
37
+ i0.ɵɵelementStart(0, "div", 17);
38
+ i0.ɵɵrepeaterCreate(1, MJDatepickerComponent_ng_template_11_For_12_For_2_Template, 2, 9, "button", 20, _forTrack0);
36
39
  i0.ɵɵelementEnd();
37
40
  } if (rf & 2) {
38
41
  const week_r6 = ctx.$implicit;
39
42
  i0.ɵɵadvance();
40
43
  i0.ɵɵrepeater(week_r6);
41
44
  } }
42
- function MJDatepickerComponent_ng_template_7_Template(rf, ctx) { if (rf & 1) {
45
+ function MJDatepickerComponent_ng_template_11_Template(rf, ctx) { if (rf & 1) {
43
46
  const _r1 = i0.ɵɵgetCurrentView();
44
- i0.ɵɵelementStart(0, "div", 7)(1, "div", 8)(2, "button", 9);
45
- i0.ɵɵlistener("click", function MJDatepickerComponent_ng_template_7_Template_button_click_2_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.PreviousMonth()); });
46
- i0.ɵɵelement(3, "i", 10);
47
+ i0.ɵɵelementStart(0, "div", 8);
48
+ i0.ɵɵlistener("keydown", function MJDatepickerComponent_ng_template_11_Template_div_keydown_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnCalendarKeyDown($event)); });
49
+ i0.ɵɵelementStart(1, "div", 9)(2, "button", 10);
50
+ i0.ɵɵlistener("click", function MJDatepickerComponent_ng_template_11_Template_button_click_2_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.PreviousMonth()); });
51
+ i0.ɵɵelement(3, "i", 11);
47
52
  i0.ɵɵelementEnd();
48
- i0.ɵɵelementStart(4, "span", 11);
53
+ i0.ɵɵelementStart(4, "span", 12);
49
54
  i0.ɵɵtext(5);
50
55
  i0.ɵɵelementEnd();
51
- i0.ɵɵelementStart(6, "button", 12);
52
- i0.ɵɵlistener("click", function MJDatepickerComponent_ng_template_7_Template_button_click_6_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.NextMonth()); });
53
- i0.ɵɵelement(7, "i", 13);
56
+ i0.ɵɵelementStart(6, "button", 13);
57
+ i0.ɵɵlistener("click", function MJDatepickerComponent_ng_template_11_Template_button_click_6_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.NextMonth()); });
58
+ i0.ɵɵelement(7, "i", 14);
54
59
  i0.ɵɵelementEnd()();
55
- i0.ɵɵelementStart(8, "div", 14);
56
- i0.ɵɵrepeaterCreate(9, MJDatepickerComponent_ng_template_7_For_10_Template, 2, 1, "span", 15, i0.ɵɵrepeaterTrackByIdentity);
60
+ i0.ɵɵelementStart(8, "div", 15);
61
+ i0.ɵɵrepeaterCreate(9, MJDatepickerComponent_ng_template_11_For_10_Template, 2, 1, "span", 16, i0.ɵɵrepeaterTrackByIdentity);
57
62
  i0.ɵɵelementEnd();
58
- i0.ɵɵrepeaterCreate(11, MJDatepickerComponent_ng_template_7_For_12_Template, 3, 0, "div", 16, i0.ɵɵrepeaterTrackByIndex);
59
- i0.ɵɵelementStart(13, "div", 17)(14, "button", 18);
60
- i0.ɵɵlistener("click", function MJDatepickerComponent_ng_template_7_Template_button_click_14_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.SelectToday()); });
63
+ i0.ɵɵrepeaterCreate(11, MJDatepickerComponent_ng_template_11_For_12_Template, 3, 0, "div", 17, i0.ɵɵrepeaterTrackByIndex);
64
+ i0.ɵɵelementStart(13, "div", 18)(14, "button", 19);
65
+ i0.ɵɵlistener("click", function MJDatepickerComponent_ng_template_11_Template_button_click_14_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.SelectToday()); });
61
66
  i0.ɵɵtext(15, "Today");
62
67
  i0.ɵɵelementEnd()()();
63
68
  } if (rf & 2) {
64
69
  const ctx_r1 = i0.ɵɵnextContext();
70
+ i0.ɵɵattribute("aria-labelledby", ctx_r1.CalendarLabelledBy || null)("aria-label", ctx_r1.CalendarLabelledBy ? null : ctx_r1.CalendarLabel);
65
71
  i0.ɵɵadvance(5);
66
72
  i0.ɵɵtextInterpolate(ctx_r1.MonthYearLabel);
67
73
  i0.ɵɵadvance(4);
@@ -71,8 +77,20 @@ function MJDatepickerComponent_ng_template_7_Template(rf, ctx) { if (rf & 1) {
71
77
  } }
72
78
  /**
73
79
  * mj-datepicker — Date picker with calendar popup. Replaces `<kendo-datepicker>`.
80
+ *
81
+ * Without an accessible name the date field announces as "edit, blank" and its calendar popup as a
82
+ * generic "Calendar" — so a form with a start date and an end date presents two identical grids
83
+ * (WCAG 2.1 4.1.2). Use {@link MJNamedControlBase.AriaLabelledBy} when a visible label exists,
84
+ * {@link MJNamedControlBase.AriaLabel} when none does; the toggle button and the calendar take
85
+ * their names from the same source. The field is a real `<input>`, so
86
+ * {@link MJNamedControlBase.InputId} IS a valid `<label for>` target.
87
+ *
88
+ * @example
89
+ * ```html
90
+ * <mj-datepicker AriaLabel="Due date" [(ngModel)]="dueDate" [Min]="minDate" />
91
+ * ```
74
92
  */
75
- export class MJDatepickerComponent {
93
+ export class MJDatepickerComponent extends MJNamedControlBase {
76
94
  Min = null;
77
95
  Max = null;
78
96
  Format = 'MM/dd/yyyy';
@@ -87,6 +105,7 @@ export class MJDatepickerComponent {
87
105
  get Disabled() { return this.disabledInput; }
88
106
  ValueChange = new EventEmitter();
89
107
  triggerEl;
108
+ dateInputEl;
90
109
  hostClass = true;
91
110
  cdr = inject(ChangeDetectorRef);
92
111
  IsOpen = false;
@@ -103,6 +122,15 @@ export class MJDatepickerComponent {
103
122
  onChange = () => { };
104
123
  onTouched = () => { };
105
124
  get MonthYearLabel() { return GetMonthYearLabel(this.viewDate); }
125
+ /** `aria-labelledby` id list for the toggle button when a VISIBLE label names the field. */
126
+ get ToggleLabelledBy() { return this.SecondaryLabelledBy('toggle-word'); }
127
+ /** `aria-label` for the toggle button in the no-visible-label case. */
128
+ get ToggleLabel() { return this.SecondaryLabel('Open calendar for', 'Open calendar'); }
129
+ /** `aria-labelledby` id list for the calendar grid when a VISIBLE label names the field. */
130
+ get CalendarLabelledBy() { return this.SecondaryLabelledBy('calendar-word'); }
131
+ /** `aria-label` for the calendar grid in the no-visible-label case. */
132
+ get CalendarLabel() { return this.SecondaryLabel('Calendar for', 'Calendar'); }
133
+ ngAfterViewInit() { WarnIfUnnamed(this.dateInputEl?.nativeElement, 'mj-datepicker'); }
106
134
  Toggle() { if (this.IsDisabled)
107
135
  return; this.IsOpen ? this.Close() : this.Open(); }
108
136
  Open() {
@@ -188,6 +216,19 @@ export class MJDatepickerComponent {
188
216
  this.Close();
189
217
  else if (event.key === 'Enter' && !this.IsOpen)
190
218
  this.Open();
219
+ else if (event.key === 'Tab')
220
+ this.returnTabToField();
221
+ }
222
+ /** Tab in the calendar closes it and returns to the field. The key is not cancelled, so the browser moves on from that field. */
223
+ OnCalendarKeyDown(event) {
224
+ if (event.key === 'Tab')
225
+ this.returnTabToField();
226
+ }
227
+ returnTabToField() {
228
+ if (!this.IsOpen)
229
+ return;
230
+ this.dateInputEl?.nativeElement.focus();
231
+ this.Close();
191
232
  }
192
233
  writeValue(value) {
193
234
  if (value == null) {
@@ -206,49 +247,76 @@ export class MJDatepickerComponent {
206
247
  registerOnTouched(fn) { this.onTouched = fn; }
207
248
  setDisabledState(isDisabled) { this.formDisabled = isDisabled; this.syncDisabled(); }
208
249
  ngOnDestroy() { this.Close(); }
209
- static ɵfac = function MJDatepickerComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MJDatepickerComponent)(); };
250
+ static ɵfac = /*@__PURE__*/ (() => { let ɵMJDatepickerComponent_BaseFactory; return function MJDatepickerComponent_Factory(__ngFactoryType__) { return (ɵMJDatepickerComponent_BaseFactory || (ɵMJDatepickerComponent_BaseFactory = i0.ɵɵgetInheritedFactory(MJDatepickerComponent)))(__ngFactoryType__ || MJDatepickerComponent); }; })();
210
251
  static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MJDatepickerComponent, selectors: [["mj-datepicker"]], viewQuery: function MJDatepickerComponent_Query(rf, ctx) { if (rf & 1) {
211
- i0.ɵɵviewQuery(_c0, 5);
252
+ i0.ɵɵviewQuery(_c0, 5)(_c1, 5);
212
253
  } if (rf & 2) {
213
254
  let _t;
214
255
  i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.triggerEl = _t.first);
256
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dateInputEl = _t.first);
215
257
  } }, hostVars: 2, hostBindings: function MJDatepickerComponent_HostBindings(rf, ctx) { if (rf & 2) {
216
258
  i0.ɵɵclassProp("mj-datepicker-host", ctx.hostClass);
217
- } }, inputs: { Min: "Min", Max: "Max", Format: "Format", Placeholder: "Placeholder", Disabled: "Disabled" }, outputs: { ValueChange: "ValueChange" }, features: [i0.ɵɵProvidersFeature([{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MJDatepickerComponent), multi: true }])], decls: 8, vars: 10, consts: [["trigger", "", "overlayOrigin", "cdkOverlayOrigin"], ["dateInput", ""], ["cdkOverlayOrigin", "", 1, "mj-datepicker"], ["type", "text", 1, "mj-input", "mj-datepicker-input", 3, "input", "blur", "keydown", "placeholder", "disabled", "value"], ["type", "button", "tabindex", "-1", "aria-label", "Open calendar", 1, "mj-datepicker-toggle", 3, "click", "disabled"], [1, "fa-solid", "fa-calendar"], ["cdkConnectedOverlay", "", "cdkConnectedOverlayBackdropClass", "mj-dropdown-backdrop", 3, "backdropClick", "detach", "cdkConnectedOverlayOrigin", "cdkConnectedOverlayOpen", "cdkConnectedOverlayPositions", "cdkConnectedOverlayHasBackdrop"], ["role", "grid", "aria-label", "Calendar", 1, "mj-calendar"], [1, "mj-calendar-header"], ["type", "button", "aria-label", "Previous month", 1, "mj-calendar-nav", 3, "click"], [1, "fa-solid", "fa-chevron-left"], [1, "mj-calendar-title"], ["type", "button", "aria-label", "Next month", 1, "mj-calendar-nav", 3, "click"], [1, "fa-solid", "fa-chevron-right"], ["role", "row", 1, "mj-calendar-weekdays"], ["role", "columnheader", 1, "mj-calendar-weekday"], ["role", "row", 1, "mj-calendar-row"], [1, "mj-calendar-footer"], ["type", "button", 1, "mj-calendar-today", 3, "click"], ["type", "button", "role", "gridcell", 1, "mj-calendar-day", 3, "mj-calendar-day--selected", "mj-calendar-day--today", "mj-calendar-day--other-month", "disabled"], ["type", "button", "role", "gridcell", 1, "mj-calendar-day", 3, "click", "disabled"]], template: function MJDatepickerComponent_Template(rf, ctx) { if (rf & 1) {
259
+ } }, inputs: { Min: "Min", Max: "Max", Format: "Format", Placeholder: "Placeholder", Disabled: "Disabled" }, outputs: { ValueChange: "ValueChange" }, features: [i0.ɵɵProvidersFeature([{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MJDatepickerComponent), multi: true }]), i0.ɵɵInheritDefinitionFeature], decls: 12, vars: 18, consts: [["trigger", "", "overlayOrigin", "cdkOverlayOrigin"], ["dateInput", ""], ["cdkOverlayOrigin", "", 1, "mj-datepicker"], ["type", "text", 1, "mj-input", "mj-datepicker-input", 3, "input", "blur", "keydown", "placeholder", "disabled", "value"], ["aria-hidden", "true", 1, "mj-datepicker-sr-only"], ["type", "button", "tabindex", "-1", 1, "mj-datepicker-toggle", 3, "click", "disabled"], [1, "fa-solid", "fa-calendar"], ["cdkConnectedOverlay", "", "cdkConnectedOverlayBackdropClass", "mj-dropdown-backdrop", 3, "backdropClick", "detach", "cdkConnectedOverlayOrigin", "cdkConnectedOverlayOpen", "cdkConnectedOverlayPositions", "cdkConnectedOverlayHasBackdrop"], ["role", "grid", 1, "mj-calendar", 3, "keydown"], [1, "mj-calendar-header"], ["type", "button", "aria-label", "Previous month", 1, "mj-calendar-nav", 3, "click"], [1, "fa-solid", "fa-chevron-left"], [1, "mj-calendar-title"], ["type", "button", "aria-label", "Next month", 1, "mj-calendar-nav", 3, "click"], [1, "fa-solid", "fa-chevron-right"], ["role", "row", 1, "mj-calendar-weekdays"], ["role", "columnheader", 1, "mj-calendar-weekday"], ["role", "row", 1, "mj-calendar-row"], [1, "mj-calendar-footer"], ["type", "button", 1, "mj-calendar-today", 3, "click"], ["type", "button", "role", "gridcell", 1, "mj-calendar-day", 3, "mj-calendar-day--selected", "mj-calendar-day--today", "mj-calendar-day--other-month", "disabled"], ["type", "button", "role", "gridcell", 1, "mj-calendar-day", 3, "click", "disabled"]], template: function MJDatepickerComponent_Template(rf, ctx) { if (rf & 1) {
218
260
  i0.ɵɵelementStart(0, "div", 2, 0)(3, "input", 3, 1);
219
261
  i0.ɵɵlistener("input", function MJDatepickerComponent_Template_input_input_3_listener($event) { return ctx.OnInputChange($event); })("blur", function MJDatepickerComponent_Template_input_blur_3_listener() { return ctx.OnBlur(); })("keydown", function MJDatepickerComponent_Template_input_keydown_3_listener($event) { return ctx.OnKeyDown($event); });
220
262
  i0.ɵɵelementEnd();
221
- i0.ɵɵelementStart(5, "button", 4);
222
- i0.ɵɵlistener("click", function MJDatepickerComponent_Template_button_click_5_listener() { return ctx.Toggle(); });
223
- i0.ɵɵelement(6, "i", 5);
263
+ i0.ɵɵelementStart(5, "span", 4);
264
+ i0.ɵɵtext(6, "Open calendar for");
265
+ i0.ɵɵelementEnd();
266
+ i0.ɵɵelementStart(7, "span", 4);
267
+ i0.ɵɵtext(8, "Calendar for");
268
+ i0.ɵɵelementEnd();
269
+ i0.ɵɵelementStart(9, "button", 5);
270
+ i0.ɵɵlistener("click", function MJDatepickerComponent_Template_button_click_9_listener() { return ctx.Toggle(); });
271
+ i0.ɵɵelement(10, "i", 6);
224
272
  i0.ɵɵelementEnd()();
225
- i0.ɵɵtemplate(7, MJDatepickerComponent_ng_template_7_Template, 16, 1, "ng-template", 6);
226
- i0.ɵɵlistener("backdropClick", function MJDatepickerComponent_Template_ng_template_backdropClick_7_listener() { return ctx.Close(); })("detach", function MJDatepickerComponent_Template_ng_template_detach_7_listener() { return ctx.Close(); });
273
+ i0.ɵɵtemplate(11, MJDatepickerComponent_ng_template_11_Template, 16, 3, "ng-template", 7);
274
+ i0.ɵɵlistener("backdropClick", function MJDatepickerComponent_Template_ng_template_backdropClick_11_listener() { return ctx.Close(); })("detach", function MJDatepickerComponent_Template_ng_template_detach_11_listener() { return ctx.Close(); });
227
275
  } if (rf & 2) {
228
276
  const overlayOrigin_r7 = i0.ɵɵreference(2);
229
277
  i0.ɵɵclassProp("mj-datepicker--disabled", ctx.IsDisabled);
230
278
  i0.ɵɵadvance(3);
231
279
  i0.ɵɵproperty("placeholder", ctx.Placeholder)("disabled", ctx.IsDisabled)("value", ctx.DisplayValue);
280
+ i0.ɵɵattribute("id", ctx.InputId || null)("aria-label", ctx.AriaLabel || null)("aria-labelledby", ctx.AriaLabelledBy || null)("aria-describedby", ctx.AriaDescribedBy || null);
281
+ i0.ɵɵadvance(2);
282
+ i0.ɵɵattribute("id", ctx.SecondaryWordId("toggle-word"));
283
+ i0.ɵɵadvance(2);
284
+ i0.ɵɵattribute("id", ctx.SecondaryWordId("calendar-word"));
232
285
  i0.ɵɵadvance(2);
233
286
  i0.ɵɵproperty("disabled", ctx.IsDisabled);
287
+ i0.ɵɵattribute("aria-labelledby", ctx.ToggleLabelledBy || null)("aria-label", ctx.ToggleLabelledBy ? null : ctx.ToggleLabel);
234
288
  i0.ɵɵadvance(2);
235
289
  i0.ɵɵproperty("cdkConnectedOverlayOrigin", overlayOrigin_r7)("cdkConnectedOverlayOpen", ctx.IsOpen)("cdkConnectedOverlayPositions", ctx.Positions)("cdkConnectedOverlayHasBackdrop", true);
236
- } }, dependencies: [OverlayModule, i1.CdkConnectedOverlay, i1.CdkOverlayOrigin], encapsulation: 2 });
290
+ } }, dependencies: [OverlayModule, i1.CdkConnectedOverlay, i1.CdkOverlayOrigin], styles: ["\n\n\n\n\n\n\n\n\n .mj-datepicker-sr-only[_ngcontent-%COMP%] {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }"] });
237
291
  }
238
292
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MJDatepickerComponent, [{
239
293
  type: Component,
240
- args: [{
241
- selector: 'mj-datepicker',
242
- standalone: true,
243
- imports: [OverlayModule],
244
- template: `
294
+ args: [{ selector: 'mj-datepicker', standalone: true, imports: [OverlayModule], template: `
245
295
  <div class="mj-datepicker" #trigger cdkOverlayOrigin #overlayOrigin="cdkOverlayOrigin"
246
296
  [class.mj-datepicker--disabled]="IsDisabled">
247
297
  <input #dateInput class="mj-input mj-datepicker-input" type="text"
298
+ [attr.id]="InputId || null"
299
+ [attr.aria-label]="AriaLabel || null"
300
+ [attr.aria-labelledby]="AriaLabelledBy || null"
301
+ [attr.aria-describedby]="AriaDescribedBy || null"
248
302
  [placeholder]="Placeholder" [disabled]="IsDisabled" [value]="DisplayValue"
249
303
  (input)="OnInputChange($event)" (blur)="OnBlur()" (keydown)="OnKeyDown($event)" />
304
+ <!--
305
+ The fixed words live in hidden spans rather than in concatenated strings so the
306
+ AriaLabelledBy path can name the toggle and the calendar from the same visible label that
307
+ names the field: aria-labelledby takes an ID LIST, so the word plus the label's own text is
308
+ composed by the accessibility tree without this component ever seeing that text. The
309
+ calendar's word sits here, outside the overlay, because ids resolve document-wide.
310
+ A hidden node that is DIRECTLY referenced by aria-labelledby is still included in the name
311
+ (accname §4.1), so aria-hidden keeps the word out of the reading order without costing the
312
+ composed name.
313
+ -->
314
+ <span class="mj-datepicker-sr-only" aria-hidden="true" [attr.id]="SecondaryWordId('toggle-word')">Open calendar for</span>
315
+ <span class="mj-datepicker-sr-only" aria-hidden="true" [attr.id]="SecondaryWordId('calendar-word')">Calendar for</span>
250
316
  <button type="button" class="mj-datepicker-toggle" tabindex="-1" [disabled]="IsDisabled"
251
- (click)="Toggle()" aria-label="Open calendar">
317
+ (click)="Toggle()"
318
+ [attr.aria-labelledby]="ToggleLabelledBy || null"
319
+ [attr.aria-label]="ToggleLabelledBy ? null : ToggleLabel">
252
320
  <i class="fa-solid fa-calendar"></i>
253
321
  </button>
254
322
  </div>
@@ -256,7 +324,10 @@ export class MJDatepickerComponent {
256
324
  [cdkConnectedOverlayOpen]="IsOpen" [cdkConnectedOverlayPositions]="Positions"
257
325
  [cdkConnectedOverlayHasBackdrop]="true" cdkConnectedOverlayBackdropClass="mj-dropdown-backdrop"
258
326
  (backdropClick)="Close()" (detach)="Close()">
259
- <div class="mj-calendar" role="grid" aria-label="Calendar">
327
+ <div class="mj-calendar" role="grid"
328
+ [attr.aria-labelledby]="CalendarLabelledBy || null"
329
+ [attr.aria-label]="CalendarLabelledBy ? null : CalendarLabel"
330
+ (keydown)="OnCalendarKeyDown($event)">
260
331
  <div class="mj-calendar-header">
261
332
  <button type="button" (click)="PreviousMonth()" aria-label="Previous month" class="mj-calendar-nav">
262
333
  <i class="fa-solid fa-chevron-left"></i></button>
@@ -284,9 +355,7 @@ export class MJDatepickerComponent {
284
355
  </div>
285
356
  </div>
286
357
  </ng-template>
287
- `,
288
- providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MJDatepickerComponent), multi: true }]
289
- }]
358
+ `, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MJDatepickerComponent), multi: true }], styles: ["\n /*\n * Component-scoped ON PURPOSE, unlike the rest of this control's styling, which ships as a global\n * stylesheet the host application imports. A host that skips that import gets unstyled chrome \u2014\n * survivable \u2014 but a hidden-word span that is not hidden renders its word as literal text in the\n * middle of the field. The rule that hides it therefore has to travel with the component.\n *\n * Not display:none or visibility:hidden \u2014 both remove the element from the accessibility tree,\n * which is the one thing this element exists to be in.\n */\n .mj-datepicker-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n "] }]
290
359
  }], null, { Min: [{
291
360
  type: Input
292
361
  }], Max: [{
@@ -302,9 +371,12 @@ export class MJDatepickerComponent {
302
371
  }], triggerEl: [{
303
372
  type: ViewChild,
304
373
  args: ['trigger']
374
+ }], dateInputEl: [{
375
+ type: ViewChild,
376
+ args: ['dateInput']
305
377
  }], hostClass: [{
306
378
  type: HostBinding,
307
379
  args: ['class.mj-datepicker-host']
308
380
  }] }); })();
309
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJDatepickerComponent, { className: "MJDatepickerComponent", filePath: "lib/datepicker/datepicker.component.ts", lineNumber: 59 }); })();
381
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJDatepickerComponent, { className: "MJDatepickerComponent", filePath: "lib/datepicker/datepicker.component.ts", lineNumber: 116 }); })();
310
382
  //# sourceMappingURL=datepicker.component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"datepicker.component.js","sourceRoot":"","sources":["../../../src/lib/datepicker/datepicker.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAc,SAAS,EAAa,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC7J,OAAO,EAAE,iBAAiB,EAAwB,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAqB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAe,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;;;;sCAqC3G,oBAAkB;;IAJgB,gCAAsD;IAAA,YAAS;IAAA,iBAAO;;;IAAhB,cAAS;IAAT,4BAAS;;;;IAK/F,kCAK4B;IAA1B,gOAAS,yBAAe,KAAC;IAAC,YAAmB;IAAA,iBAAS;;;;IAFtD,AADA,AADA,yEAAsD,0CACV,wDACc;IAC1D,sDAA8B;;IACJ,cAAmB;IAAnB,sCAAmB;;;IAPnD,+BAAwC;IACtC,iHAOC;IACH,iBAAM;;;IARJ,cAOC;IAPD,sBAOC;;;;IAlBH,AADF,AADF,8BAA2D,aACzB,gBACsE;IAA9E,yLAAS,sBAAe,KAAC;IAC7C,wBAAwC;IAAA,iBAAS;IACnD,gCAAgC;IAAA,YAAoB;IAAA,iBAAO;IAC3D,kCAA4F;IAAtE,yLAAS,kBAAW,KAAC;IACzC,wBAAyC;IAC7C,AAD6C,iBAAS,EAChD;IACN,+BAA6C;IAC3C,2HAA4G;IAC9G,iBAAM;IACN,wHAWC;IAEC,AADF,gCAAgC,kBAC0C;IAAxB,0LAAS,oBAAa,KAAC;IAAC,sBAAK;IAEjF,AADE,AAD+E,iBAAS,EAClF,EACF;;;IAtB8B,eAAoB;IAApB,2CAAoB;IAKpD,eAA4G;IAA5G,8BAA4G;IAE9G,eAWC;IAXD,2BAWC;;A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B,IAAC,kFAAS,YAAQ,IAAC,8FAAY,qBAAiB,IAAC;YAFjF,iBAEoF;YACpF,iCACgD;YAA9C,kGAAS,YAAQ,IAAC;YAClB,uBAAoC;YAExC,AADE,iBAAS,EACL;YACN,uFAG+C;YAAnB,AAA1B,uHAAiB,WAAO,IAAC,4FAAW,WAAO,IAAC;;;YAZ5C,yDAA4C;YAE1C,eAA2B;YAAyB,AAAxB,AAA5B,6CAA2B,4BAAwB,2BAAuB;YAEX,eAAuB;YAAvB,yCAAuB;YAKzD,eAA2C;YAE1E,AADmC,AAAnC,AAD+B,4DAA2C,uCACxC,+CAA2C,wCACtC;4BAdjC,aAAa;;iFA+CZ,qBAAqB;cAlDjC,SAAS;eAAC;gBACT,QAAQ,EAAE,eAAe;gBACzB,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,aAAa,CAAC;gBACxB,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CT;gBACD,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,sBAAsB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;aAC/G;;kBAEE,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBAOL,KAAK;;kBAGL,MAAM;;kBACN,SAAS;mBAAC,SAAS;;kBACnB,WAAW;mBAAC,0BAA0B;;kFAhB5B,qBAAqB","sourcesContent":["import { Component, Input, Output, EventEmitter, forwardRef, HostBinding, ElementRef, ViewChild, OnDestroy, inject, ChangeDetectorRef } from '@angular/core';\nimport { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';\nimport { OverlayModule, ConnectedPosition } from '@angular/cdk/overlay';\nimport { CalendarDay, WEEK_DAYS, BuildCalendarWeeks, FormatDate, GetMonthYearLabel } from '../calendar/calendar-utils';\n\n/**\n * mj-datepicker — Date picker with calendar popup. Replaces `<kendo-datepicker>`.\n */\n@Component({\n selector: 'mj-datepicker',\n standalone: true,\n imports: [OverlayModule],\n template: `\n <div class=\"mj-datepicker\" #trigger cdkOverlayOrigin #overlayOrigin=\"cdkOverlayOrigin\"\n [class.mj-datepicker--disabled]=\"IsDisabled\">\n <input #dateInput class=\"mj-input mj-datepicker-input\" type=\"text\"\n [placeholder]=\"Placeholder\" [disabled]=\"IsDisabled\" [value]=\"DisplayValue\"\n (input)=\"OnInputChange($event)\" (blur)=\"OnBlur()\" (keydown)=\"OnKeyDown($event)\" />\n <button type=\"button\" class=\"mj-datepicker-toggle\" tabindex=\"-1\" [disabled]=\"IsDisabled\"\n (click)=\"Toggle()\" aria-label=\"Open calendar\">\n <i class=\"fa-solid fa-calendar\"></i>\n </button>\n </div>\n <ng-template cdkConnectedOverlay [cdkConnectedOverlayOrigin]=\"overlayOrigin\"\n [cdkConnectedOverlayOpen]=\"IsOpen\" [cdkConnectedOverlayPositions]=\"Positions\"\n [cdkConnectedOverlayHasBackdrop]=\"true\" cdkConnectedOverlayBackdropClass=\"mj-dropdown-backdrop\"\n (backdropClick)=\"Close()\" (detach)=\"Close()\">\n <div class=\"mj-calendar\" role=\"grid\" aria-label=\"Calendar\">\n <div class=\"mj-calendar-header\">\n <button type=\"button\" (click)=\"PreviousMonth()\" aria-label=\"Previous month\" class=\"mj-calendar-nav\">\n <i class=\"fa-solid fa-chevron-left\"></i></button>\n <span class=\"mj-calendar-title\">{{ MonthYearLabel }}</span>\n <button type=\"button\" (click)=\"NextMonth()\" aria-label=\"Next month\" class=\"mj-calendar-nav\">\n <i class=\"fa-solid fa-chevron-right\"></i></button>\n </div>\n <div class=\"mj-calendar-weekdays\" role=\"row\">\n @for (day of WeekDays; track day) { <span class=\"mj-calendar-weekday\" role=\"columnheader\">{{ day }}</span> }\n </div>\n @for (week of Weeks; track $index) {\n <div class=\"mj-calendar-row\" role=\"row\">\n @for (day of week; track day.date.getTime()) {\n <button type=\"button\" class=\"mj-calendar-day\" role=\"gridcell\"\n [class.mj-calendar-day--selected]=\"IsSelectedDay(day)\"\n [class.mj-calendar-day--today]=\"day.isToday\"\n [class.mj-calendar-day--other-month]=\"!day.isCurrentMonth\"\n [disabled]=\"IsOutOfRange(day)\" [attr.aria-selected]=\"IsSelectedDay(day)\"\n (click)=\"SelectDate(day)\">{{ day.dayNumber }}</button>\n }\n </div>\n }\n <div class=\"mj-calendar-footer\">\n <button type=\"button\" class=\"mj-calendar-today\" (click)=\"SelectToday()\">Today</button>\n </div>\n </div>\n </ng-template>\n `,\n providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MJDatepickerComponent), multi: true }]\n})\nexport class MJDatepickerComponent implements ControlValueAccessor, OnDestroy {\n @Input() Min: Date | null = null;\n @Input() Max: Date | null = null;\n @Input() Format = 'MM/dd/yyyy';\n @Input() Placeholder = '';\n /**\n * Host-driven disable. Composed with Angular Forms' `setDisabledState()` into `IsDisabled`\n * (the actual gate) — see `syncDisabled`. A setter, not a bare field, because this input is\n * routinely bound to an expression that changes over the control's lifetime, and the gate has\n * to follow it every time.\n */\n @Input()\n set Disabled(value: boolean) { this.disabledInput = value; this.syncDisabled(); }\n get Disabled(): boolean { return this.disabledInput; }\n @Output() ValueChange = new EventEmitter<Date | null>();\n @ViewChild('trigger') private triggerEl!: ElementRef<HTMLElement>;\n @HostBinding('class.mj-datepicker-host') readonly hostClass = true;\n private cdr = inject(ChangeDetectorRef);\n\n IsOpen = false; IsDisabled = false; DisplayValue = '';\n Weeks: CalendarDay[][] = []; WeekDays = WEEK_DAYS;\n Positions: ConnectedPosition[] = [\n { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' }\n ];\n private viewDate = new Date();\n private selectedDate: Date | null = null;\n private onChange: (value: Date | null) => void = () => {};\n private onTouched: () => void = () => {};\n\n get MonthYearLabel(): string { return GetMonthYearLabel(this.viewDate); }\n\n Toggle(): void { if (this.IsDisabled) return; this.IsOpen ? this.Close() : this.Open(); }\n Open(): void {\n if (this.IsDisabled || this.IsOpen) return;\n this.viewDate = this.selectedDate ? new Date(this.selectedDate) : new Date();\n this.Weeks = BuildCalendarWeeks(this.viewDate); this.IsOpen = true; this.cdr.detectChanges();\n }\n Close(): void { if (!this.IsOpen) return; this.IsOpen = false; this.cdr.detectChanges(); }\n\n /** Backing field for the `Disabled` input. */\n private disabledInput = false;\n /** The forms-driven disabled state, kept SEPARATE so neither source can stomp the other. */\n private formDisabled = false;\n\n /**\n * Recompute the gate from both of its sources. Called whenever either changes.\n *\n * `IsDisabled` is derived state, and the only thing that assigned it was `setDisabledState()`.\n * The forms-driven half was in fact fine — `setUpControl` also wires `registerOnDisabledChange`,\n * so that hook fires on every `control.disable()`/`enable()`, not just at registration. What had\n * no recompute path at all was the `Disabled` @Input: a plain field, so the gate froze at\n * whatever the first compose produced and every later change to the input was dropped.\n *\n * Closes the calendar directly rather than via `Close()`: this can run from an @Input setter,\n * i.e. DURING the parent's CD pass, where a nested `detectChanges()` trips NG0100.\n */\n private syncDisabled(): void {\n const disabled = this.disabledInput || this.formDisabled;\n if (disabled === this.IsDisabled) return;\n this.IsDisabled = disabled;\n if (disabled) this.IsOpen = false;\n this.cdr.markForCheck();\n }\n PreviousMonth(): void { this.viewDate = new Date(this.viewDate.getFullYear(), this.viewDate.getMonth() - 1, 1); this.Weeks = BuildCalendarWeeks(this.viewDate); }\n NextMonth(): void { this.viewDate = new Date(this.viewDate.getFullYear(), this.viewDate.getMonth() + 1, 1); this.Weeks = BuildCalendarWeeks(this.viewDate); }\n\n SelectDate(day: CalendarDay): void {\n if (this.IsOutOfRange(day)) return;\n this.selectedDate = day.date; this.DisplayValue = FormatDate(day.date);\n this.onChange(day.date); this.ValueChange.emit(day.date); this.Close();\n }\n SelectToday(): void {\n const today = new Date(); today.setHours(0, 0, 0, 0);\n this.selectedDate = today; this.DisplayValue = FormatDate(today);\n this.onChange(today); this.ValueChange.emit(today); this.Close();\n }\n IsSelectedDay(day: CalendarDay): boolean {\n if (!this.selectedDate) return false;\n return day.date.getFullYear() === this.selectedDate.getFullYear() && day.date.getMonth() === this.selectedDate.getMonth() && day.date.getDate() === this.selectedDate.getDate();\n }\n IsOutOfRange(day: CalendarDay): boolean {\n if (this.Min && day.date < this.Min) return true;\n if (this.Max && day.date > this.Max) return true;\n return false;\n }\n OnInputChange(event: Event): void {\n const value = (event.target as HTMLInputElement).value; this.DisplayValue = value;\n const parsed = new Date(value);\n if (!isNaN(parsed.getTime())) { this.selectedDate = parsed; this.onChange(parsed); this.ValueChange.emit(parsed); }\n }\n OnBlur(): void { this.onTouched(); }\n OnKeyDown(event: KeyboardEvent): void {\n if (event.key === 'Escape') this.Close();\n else if (event.key === 'Enter' && !this.IsOpen) this.Open();\n }\n writeValue(value: Date | string | null): void {\n if (value == null) { this.selectedDate = null; this.DisplayValue = ''; }\n else { const d = typeof value === 'string' ? new Date(value) : value; if (!isNaN(d.getTime())) { this.selectedDate = d; this.DisplayValue = FormatDate(d); } }\n }\n registerOnChange(fn: (value: Date | null) => void): void { this.onChange = fn; }\n registerOnTouched(fn: () => void): void { this.onTouched = fn; }\n setDisabledState(isDisabled: boolean): void { this.formDisabled = isDisabled; this.syncDisabled(); }\n ngOnDestroy(): void { this.Close(); }\n}\n"]}
1
+ {"version":3,"file":"datepicker.component.js","sourceRoot":"","sources":["../../../src/lib/datepicker/datepicker.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAc,SAAS,EAAa,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC5K,OAAO,EAAE,iBAAiB,EAAwB,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAqB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAe,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,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a;;iFA0FZ,qBAAqB;cA7FjC,SAAS;2BACE,eAAe,cACb,IAAI,WACP,CAAC,aAAa,CAAC,YACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgET,aAuBU,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,sBAAsB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;kBAG7G,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBAOL,KAAK;;kBAGL,MAAM;;kBACN,SAAS;mBAAC,SAAS;;kBACnB,SAAS;mBAAC,WAAW;;kBACrB,WAAW;mBAAC,0BAA0B;;kFAjB5B,qBAAqB","sourcesContent":["import { AfterViewInit, Component, Input, Output, EventEmitter, forwardRef, HostBinding, ElementRef, ViewChild, OnDestroy, inject, ChangeDetectorRef } from '@angular/core';\nimport { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';\nimport { OverlayModule, ConnectedPosition } from '@angular/cdk/overlay';\nimport { CalendarDay, WEEK_DAYS, BuildCalendarWeeks, FormatDate, GetMonthYearLabel } from '../calendar/calendar-utils';\nimport { MJNamedControlBase } from '../a11y/named-control.base';\nimport { WarnIfUnnamed } from '../a11y/unnamed-control-guard';\n\n/**\n * mj-datepicker — Date picker with calendar popup. Replaces `<kendo-datepicker>`.\n *\n * Without an accessible name the date field announces as \"edit, blank\" and its calendar popup as a\n * generic \"Calendar\" — so a form with a start date and an end date presents two identical grids\n * (WCAG 2.1 4.1.2). Use {@link MJNamedControlBase.AriaLabelledBy} when a visible label exists,\n * {@link MJNamedControlBase.AriaLabel} when none does; the toggle button and the calendar take\n * their names from the same source. The field is a real `<input>`, so\n * {@link MJNamedControlBase.InputId} IS a valid `<label for>` target.\n *\n * @example\n * ```html\n * <mj-datepicker AriaLabel=\"Due date\" [(ngModel)]=\"dueDate\" [Min]=\"minDate\" />\n * ```\n */\n@Component({\n selector: 'mj-datepicker',\n standalone: true,\n imports: [OverlayModule],\n template: `\n <div class=\"mj-datepicker\" #trigger cdkOverlayOrigin #overlayOrigin=\"cdkOverlayOrigin\"\n [class.mj-datepicker--disabled]=\"IsDisabled\">\n <input #dateInput class=\"mj-input mj-datepicker-input\" type=\"text\"\n [attr.id]=\"InputId || null\"\n [attr.aria-label]=\"AriaLabel || null\"\n [attr.aria-labelledby]=\"AriaLabelledBy || null\"\n [attr.aria-describedby]=\"AriaDescribedBy || null\"\n [placeholder]=\"Placeholder\" [disabled]=\"IsDisabled\" [value]=\"DisplayValue\"\n (input)=\"OnInputChange($event)\" (blur)=\"OnBlur()\" (keydown)=\"OnKeyDown($event)\" />\n <!--\n The fixed words live in hidden spans rather than in concatenated strings so the\n AriaLabelledBy path can name the toggle and the calendar from the same visible label that\n names the field: aria-labelledby takes an ID LIST, so the word plus the label's own text is\n composed by the accessibility tree without this component ever seeing that text. The\n calendar's word sits here, outside the overlay, because ids resolve document-wide.\n A hidden node that is DIRECTLY referenced by aria-labelledby is still included in the name\n (accname §4.1), so aria-hidden keeps the word out of the reading order without costing the\n composed name.\n -->\n <span class=\"mj-datepicker-sr-only\" aria-hidden=\"true\" [attr.id]=\"SecondaryWordId('toggle-word')\">Open calendar for</span>\n <span class=\"mj-datepicker-sr-only\" aria-hidden=\"true\" [attr.id]=\"SecondaryWordId('calendar-word')\">Calendar for</span>\n <button type=\"button\" class=\"mj-datepicker-toggle\" tabindex=\"-1\" [disabled]=\"IsDisabled\"\n (click)=\"Toggle()\"\n [attr.aria-labelledby]=\"ToggleLabelledBy || null\"\n [attr.aria-label]=\"ToggleLabelledBy ? null : ToggleLabel\">\n <i class=\"fa-solid fa-calendar\"></i>\n </button>\n </div>\n <ng-template cdkConnectedOverlay [cdkConnectedOverlayOrigin]=\"overlayOrigin\"\n [cdkConnectedOverlayOpen]=\"IsOpen\" [cdkConnectedOverlayPositions]=\"Positions\"\n [cdkConnectedOverlayHasBackdrop]=\"true\" cdkConnectedOverlayBackdropClass=\"mj-dropdown-backdrop\"\n (backdropClick)=\"Close()\" (detach)=\"Close()\">\n <div class=\"mj-calendar\" role=\"grid\"\n [attr.aria-labelledby]=\"CalendarLabelledBy || null\"\n [attr.aria-label]=\"CalendarLabelledBy ? null : CalendarLabel\"\n (keydown)=\"OnCalendarKeyDown($event)\">\n <div class=\"mj-calendar-header\">\n <button type=\"button\" (click)=\"PreviousMonth()\" aria-label=\"Previous month\" class=\"mj-calendar-nav\">\n <i class=\"fa-solid fa-chevron-left\"></i></button>\n <span class=\"mj-calendar-title\">{{ MonthYearLabel }}</span>\n <button type=\"button\" (click)=\"NextMonth()\" aria-label=\"Next month\" class=\"mj-calendar-nav\">\n <i class=\"fa-solid fa-chevron-right\"></i></button>\n </div>\n <div class=\"mj-calendar-weekdays\" role=\"row\">\n @for (day of WeekDays; track day) { <span class=\"mj-calendar-weekday\" role=\"columnheader\">{{ day }}</span> }\n </div>\n @for (week of Weeks; track $index) {\n <div class=\"mj-calendar-row\" role=\"row\">\n @for (day of week; track day.date.getTime()) {\n <button type=\"button\" class=\"mj-calendar-day\" role=\"gridcell\"\n [class.mj-calendar-day--selected]=\"IsSelectedDay(day)\"\n [class.mj-calendar-day--today]=\"day.isToday\"\n [class.mj-calendar-day--other-month]=\"!day.isCurrentMonth\"\n [disabled]=\"IsOutOfRange(day)\" [attr.aria-selected]=\"IsSelectedDay(day)\"\n (click)=\"SelectDate(day)\">{{ day.dayNumber }}</button>\n }\n </div>\n }\n <div class=\"mj-calendar-footer\">\n <button type=\"button\" class=\"mj-calendar-today\" (click)=\"SelectToday()\">Today</button>\n </div>\n </div>\n </ng-template>\n `,\n styles: [`\n /*\n * Component-scoped ON PURPOSE, unlike the rest of this control's styling, which ships as a global\n * stylesheet the host application imports. A host that skips that import gets unstyled chrome —\n * survivable — but a hidden-word span that is not hidden renders its word as literal text in the\n * middle of the field. The rule that hides it therefore has to travel with the component.\n *\n * Not display:none or visibility:hidden — both remove the element from the accessibility tree,\n * which is the one thing this element exists to be in.\n */\n .mj-datepicker-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n `],\n providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MJDatepickerComponent), multi: true }]\n})\nexport class MJDatepickerComponent extends MJNamedControlBase implements ControlValueAccessor, AfterViewInit, OnDestroy {\n @Input() Min: Date | null = null;\n @Input() Max: Date | null = null;\n @Input() Format = 'MM/dd/yyyy';\n @Input() Placeholder = '';\n /**\n * Host-driven disable. Composed with Angular Forms' `setDisabledState()` into `IsDisabled`\n * (the actual gate) — see `syncDisabled`. A setter, not a bare field, because this input is\n * routinely bound to an expression that changes over the control's lifetime, and the gate has\n * to follow it every time.\n */\n @Input()\n set Disabled(value: boolean) { this.disabledInput = value; this.syncDisabled(); }\n get Disabled(): boolean { return this.disabledInput; }\n @Output() ValueChange = new EventEmitter<Date | null>();\n @ViewChild('trigger') private triggerEl!: ElementRef<HTMLElement>;\n @ViewChild('dateInput') private dateInputEl: ElementRef<HTMLInputElement> | undefined;\n @HostBinding('class.mj-datepicker-host') readonly hostClass = true;\n private cdr = inject(ChangeDetectorRef);\n\n IsOpen = false; IsDisabled = false; DisplayValue = '';\n Weeks: CalendarDay[][] = []; WeekDays = WEEK_DAYS;\n Positions: ConnectedPosition[] = [\n { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' }\n ];\n private viewDate = new Date();\n private selectedDate: Date | null = null;\n private onChange: (value: Date | null) => void = () => {};\n private onTouched: () => void = () => {};\n\n get MonthYearLabel(): string { return GetMonthYearLabel(this.viewDate); }\n\n /** `aria-labelledby` id list for the toggle button when a VISIBLE label names the field. */\n get ToggleLabelledBy(): string { return this.SecondaryLabelledBy('toggle-word'); }\n\n /** `aria-label` for the toggle button in the no-visible-label case. */\n get ToggleLabel(): string { return this.SecondaryLabel('Open calendar for', 'Open calendar'); }\n\n /** `aria-labelledby` id list for the calendar grid when a VISIBLE label names the field. */\n get CalendarLabelledBy(): string { return this.SecondaryLabelledBy('calendar-word'); }\n\n /** `aria-label` for the calendar grid in the no-visible-label case. */\n get CalendarLabel(): string { return this.SecondaryLabel('Calendar for', 'Calendar'); }\n\n ngAfterViewInit(): void { WarnIfUnnamed(this.dateInputEl?.nativeElement, 'mj-datepicker'); }\n\n Toggle(): void { if (this.IsDisabled) return; this.IsOpen ? this.Close() : this.Open(); }\n Open(): void {\n if (this.IsDisabled || this.IsOpen) return;\n this.viewDate = this.selectedDate ? new Date(this.selectedDate) : new Date();\n this.Weeks = BuildCalendarWeeks(this.viewDate); this.IsOpen = true; this.cdr.detectChanges();\n }\n Close(): void { if (!this.IsOpen) return; this.IsOpen = false; this.cdr.detectChanges(); }\n\n /** Backing field for the `Disabled` input. */\n private disabledInput = false;\n /** The forms-driven disabled state, kept SEPARATE so neither source can stomp the other. */\n private formDisabled = false;\n\n /**\n * Recompute the gate from both of its sources. Called whenever either changes.\n *\n * `IsDisabled` is derived state, and the only thing that assigned it was `setDisabledState()`.\n * The forms-driven half was in fact fine — `setUpControl` also wires `registerOnDisabledChange`,\n * so that hook fires on every `control.disable()`/`enable()`, not just at registration. What had\n * no recompute path at all was the `Disabled` @Input: a plain field, so the gate froze at\n * whatever the first compose produced and every later change to the input was dropped.\n *\n * Closes the calendar directly rather than via `Close()`: this can run from an @Input setter,\n * i.e. DURING the parent's CD pass, where a nested `detectChanges()` trips NG0100.\n */\n private syncDisabled(): void {\n const disabled = this.disabledInput || this.formDisabled;\n if (disabled === this.IsDisabled) return;\n this.IsDisabled = disabled;\n if (disabled) this.IsOpen = false;\n this.cdr.markForCheck();\n }\n PreviousMonth(): void { this.viewDate = new Date(this.viewDate.getFullYear(), this.viewDate.getMonth() - 1, 1); this.Weeks = BuildCalendarWeeks(this.viewDate); }\n NextMonth(): void { this.viewDate = new Date(this.viewDate.getFullYear(), this.viewDate.getMonth() + 1, 1); this.Weeks = BuildCalendarWeeks(this.viewDate); }\n\n SelectDate(day: CalendarDay): void {\n if (this.IsOutOfRange(day)) return;\n this.selectedDate = day.date; this.DisplayValue = FormatDate(day.date);\n this.onChange(day.date); this.ValueChange.emit(day.date); this.Close();\n }\n SelectToday(): void {\n const today = new Date(); today.setHours(0, 0, 0, 0);\n this.selectedDate = today; this.DisplayValue = FormatDate(today);\n this.onChange(today); this.ValueChange.emit(today); this.Close();\n }\n IsSelectedDay(day: CalendarDay): boolean {\n if (!this.selectedDate) return false;\n return day.date.getFullYear() === this.selectedDate.getFullYear() && day.date.getMonth() === this.selectedDate.getMonth() && day.date.getDate() === this.selectedDate.getDate();\n }\n IsOutOfRange(day: CalendarDay): boolean {\n if (this.Min && day.date < this.Min) return true;\n if (this.Max && day.date > this.Max) return true;\n return false;\n }\n OnInputChange(event: Event): void {\n const value = (event.target as HTMLInputElement).value; this.DisplayValue = value;\n const parsed = new Date(value);\n if (!isNaN(parsed.getTime())) { this.selectedDate = parsed; this.onChange(parsed); this.ValueChange.emit(parsed); }\n }\n OnBlur(): void { this.onTouched(); }\n OnKeyDown(event: KeyboardEvent): void {\n if (event.key === 'Escape') this.Close();\n else if (event.key === 'Enter' && !this.IsOpen) this.Open();\n else if (event.key === 'Tab') this.returnTabToField();\n }\n\n /** Tab in the calendar closes it and returns to the field. The key is not cancelled, so the browser moves on from that field. */\n OnCalendarKeyDown(event: KeyboardEvent): void {\n if (event.key === 'Tab') this.returnTabToField();\n }\n\n private returnTabToField(): void {\n if (!this.IsOpen) return;\n this.dateInputEl?.nativeElement.focus();\n this.Close();\n }\n writeValue(value: Date | string | null): void {\n if (value == null) { this.selectedDate = null; this.DisplayValue = ''; }\n else { const d = typeof value === 'string' ? new Date(value) : value; if (!isNaN(d.getTime())) { this.selectedDate = d; this.DisplayValue = FormatDate(d); } }\n }\n registerOnChange(fn: (value: Date | null) => void): void { this.onChange = fn; }\n registerOnTouched(fn: () => void): void { this.onTouched = fn; }\n setDisabledState(isDisabled: boolean): void { this.formDisabled = isDisabled; this.syncDisabled(); }\n ngOnDestroy(): void { this.Close(); }\n}\n"]}