@spartan-ng/brain 1.0.5 → 1.1.0-alpha.1

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.
@@ -4,10 +4,10 @@ import { injectDateAdapter } from '@spartan-ng/brain/date-time';
4
4
  import { outputToObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
5
  import { BrnSelect } from '@spartan-ng/brain/select';
6
6
 
7
- let uniqueId = 0;
7
+ let uniqueId$1 = 0;
8
8
  class BrnCalendarHeader {
9
9
  /** The unique id for the header */
10
- id = input(`brn-calendar-header-${++uniqueId}`, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
10
+ id = input(`brn-calendar-header-${++uniqueId$1}`, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
11
11
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
12
12
  /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnCalendarHeader, isStandalone: true, selector: "[brnCalendarHeader]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "aria-live": "polite", "role": "presentation" }, properties: { "id": "id()" } }, ngImport: i0 });
13
13
  }
@@ -1207,6 +1207,461 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
1207
1207
  }]
1208
1208
  }], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }], startDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "startDate", required: false }] }, { type: i0.Output, args: ["startDateChange"] }], endDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "endDate", required: false }] }, { type: i0.Output, args: ["endDateChange"] }] } });
1209
1209
 
1210
+ const BrnMonthYearCalendarToken = new InjectionToken('BrnMonthYearCalendarToken');
1211
+ function provideBrnMonthYearCalendar(instance) {
1212
+ return { provide: BrnMonthYearCalendarToken, useExisting: instance };
1213
+ }
1214
+ /**
1215
+ * Inject the month/year selector.
1216
+ */
1217
+ function injectBrnMonthYearCalendar() {
1218
+ return inject(BrnMonthYearCalendarToken);
1219
+ }
1220
+
1221
+ let uniqueId = 0;
1222
+ class BrnMonthYearCalendarHeader {
1223
+ /** The unique id for the header */
1224
+ id = input(`brn-month-year-header-${++uniqueId}`, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
1225
+ _monthYear = injectBrnMonthYearCalendar();
1226
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1227
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnMonthYearCalendarHeader, isStandalone: true, selector: "button[brnMonthYearCalendarHeader]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "_monthYear.view.set(\"year\")" }, properties: { "id": "id()", "disabled": "_monthYear.disabled() || _monthYear.view() === \"year\"" } }, ngImport: i0 });
1228
+ }
1229
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarHeader, decorators: [{
1230
+ type: Directive,
1231
+ args: [{
1232
+ selector: 'button[brnMonthYearCalendarHeader]',
1233
+ host: {
1234
+ '[id]': 'id()',
1235
+ '[disabled]': '_monthYear.disabled() || _monthYear.view() === "year"',
1236
+ '(click)': '_monthYear.view.set("year")',
1237
+ },
1238
+ }]
1239
+ }], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }] } });
1240
+
1241
+ /** The number of years shown per page (4 columns x 3 rows). */
1242
+ const YEARS_PER_PAGE = 12;
1243
+ /** Positive modulo. */
1244
+ function floorMod(value, modulo) {
1245
+ return ((value % modulo) + modulo) % modulo;
1246
+ }
1247
+ class BrnMonthYearCalendar {
1248
+ /** Access the date adapter */
1249
+ _dateAdapter = injectDateAdapter();
1250
+ /** Access the change detector */
1251
+ _changeDetector = inject(ChangeDetectorRef);
1252
+ /** Access the injector */
1253
+ _injector = inject(Injector);
1254
+ /** The minimum date that can be selected. */
1255
+ min = input(...(ngDevMode ? [undefined, { debugName: "min" }] : /* istanbul ignore next */ []));
1256
+ /** The maximum date that can be selected. */
1257
+ max = input(...(ngDevMode ? [undefined, { debugName: "max" }] : /* istanbul ignore next */ []));
1258
+ /** Whether the month/year selector is disabled. */
1259
+ disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1260
+ /** The selected month. Represented by the first day of the month. */
1261
+ date = model(...(ngDevMode ? [undefined, { debugName: "date" }] : /* istanbul ignore next */ []));
1262
+ /** The default focused date. */
1263
+ defaultFocusedDate = input(...(ngDevMode ? [undefined, { debugName: "defaultFocusedDate" }] : /* istanbul ignore next */ []));
1264
+ /** The current view. The year view is shown first. */
1265
+ viewInput = input('year', { ...(ngDevMode ? { debugName: "viewInput" } : /* istanbul ignore next */ {}), alias: 'view' });
1266
+ /** The current view mutable. The year view is shown first. */
1267
+ view = linkedSignal(this.viewInput, ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
1268
+ /** @internal Access the header */
1269
+ header = contentChild(BrnMonthYearCalendarHeader, ...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
1270
+ /** The focused date. */
1271
+ focusedDate = linkedSignal(() => this.constrainDate(this.defaultFocusedDate() ?? this.date() ?? this._dateAdapter.now()), ...(ngDevMode ? [{ debugName: "focusedDate" }] : /* istanbul ignore next */ []));
1272
+ _cells = [];
1273
+ /** The 12 months of the currently focused year. */
1274
+ months = computed(() => {
1275
+ const focused = this.focusedDate();
1276
+ return Array.from({ length: 12 }, (_, month) => this._dateAdapter.startOfMonth(this._dateAdapter.set(focused, { month, day: 1 })));
1277
+ }, ...(ngDevMode ? [{ debugName: "months" }] : /* istanbul ignore next */ []));
1278
+ /** The first and last year of the current page. */
1279
+ yearRange = computed(() => {
1280
+ const year = this._dateAdapter.getYear(this.focusedDate());
1281
+ const start = year - floorMod(year, YEARS_PER_PAGE);
1282
+ return { start, end: start + YEARS_PER_PAGE - 1 };
1283
+ }, ...(ngDevMode ? [{ debugName: "yearRange" }] : /* istanbul ignore next */ []));
1284
+ /** The years of the current page. */
1285
+ years = computed(() => {
1286
+ const focused = this.focusedDate();
1287
+ const { start } = this.yearRange();
1288
+ return Array.from({ length: YEARS_PER_PAGE }, (_, i) => this._dateAdapter.startOfMonth(this._dateAdapter.set(focused, { year: start + i, month: 0, day: 1 })));
1289
+ }, ...(ngDevMode ? [{ debugName: "years" }] : /* istanbul ignore next */ []));
1290
+ /** @internal Constrain a date to the min and max boundaries. */
1291
+ constrainDate(date) {
1292
+ const min = this.min();
1293
+ const max = this.max();
1294
+ if (min && this._dateAdapter.isBefore(date, this._dateAdapter.startOfDay(min))) {
1295
+ return min;
1296
+ }
1297
+ if (max && this._dateAdapter.isAfter(date, this._dateAdapter.endOfDay(max))) {
1298
+ return max;
1299
+ }
1300
+ return date;
1301
+ }
1302
+ selectMonth(date) {
1303
+ if (this.isMonthDisabled(date)) {
1304
+ return;
1305
+ }
1306
+ const month = this._dateAdapter.startOfDay(this._dateAdapter.startOfMonth(date));
1307
+ if (this.isMonthSelected(date)) {
1308
+ this.date.set(undefined);
1309
+ }
1310
+ else {
1311
+ this.date.set(month);
1312
+ }
1313
+ this.focusedDate.set(month);
1314
+ }
1315
+ selectYear(date) {
1316
+ if (this.isYearDisabled(date)) {
1317
+ return;
1318
+ }
1319
+ const year = this._dateAdapter.getYear(date);
1320
+ let target = this._dateAdapter.set(this.focusedDate(), { year });
1321
+ if (this.isMonthDisabled(target)) {
1322
+ target = this._dateAdapter.set(target, { month: 0, day: 1 });
1323
+ }
1324
+ this.focusedDate.set(target);
1325
+ this.view.set('month');
1326
+ // focus the first available month once the month view is rendered.
1327
+ this._focusCell((cell) => !this.isMonthDisabled(cell));
1328
+ }
1329
+ isMonthSelected(date) {
1330
+ const selected = this.date();
1331
+ return !!selected && this._dateAdapter.isSameMonth(date, selected) && this._dateAdapter.isSameYear(date, selected);
1332
+ }
1333
+ isYearSelected(date) {
1334
+ const selected = this.date();
1335
+ return !!selected && this._dateAdapter.isSameYear(date, selected);
1336
+ }
1337
+ isMonthToday(date) {
1338
+ const now = this._dateAdapter.now();
1339
+ return this._dateAdapter.isSameMonth(date, now) && this._dateAdapter.isSameYear(date, now);
1340
+ }
1341
+ isYearToday(date) {
1342
+ return this._dateAdapter.isSameYear(date, this._dateAdapter.now());
1343
+ }
1344
+ isMonthDisabled(date) {
1345
+ if (this.disabled()) {
1346
+ return true;
1347
+ }
1348
+ const min = this.min();
1349
+ const max = this.max();
1350
+ if (min && this._dateAdapter.isBefore(this._dateAdapter.endOfMonth(date), this._dateAdapter.startOfDay(min))) {
1351
+ return true;
1352
+ }
1353
+ if (max && this._dateAdapter.isAfter(this._dateAdapter.startOfMonth(date), this._dateAdapter.endOfDay(max))) {
1354
+ return true;
1355
+ }
1356
+ return false;
1357
+ }
1358
+ isYearDisabled(date) {
1359
+ if (this.disabled()) {
1360
+ return true;
1361
+ }
1362
+ const year = this._dateAdapter.getYear(date);
1363
+ const min = this.min();
1364
+ const max = this.max();
1365
+ if (min && year < this._dateAdapter.getYear(min)) {
1366
+ return true;
1367
+ }
1368
+ if (max && year > this._dateAdapter.getYear(max)) {
1369
+ return true;
1370
+ }
1371
+ return false;
1372
+ }
1373
+ setFocusedMonth(date) {
1374
+ if (this.isMonthDisabled(date)) {
1375
+ return;
1376
+ }
1377
+ this.focusedDate.set(this._dateAdapter.startOfMonth(date));
1378
+ this._focusCell((cell) => this._dateAdapter.isSameMonth(cell, date) && this._dateAdapter.isSameYear(cell, date));
1379
+ }
1380
+ setFocusedYear(date) {
1381
+ if (this.isYearDisabled(date)) {
1382
+ return;
1383
+ }
1384
+ const year = this._dateAdapter.getYear(date);
1385
+ this.focusedDate.set(this._dateAdapter.set(this.focusedDate(), { year }));
1386
+ this._focusCell((cell) => this._dateAdapter.isSameYear(cell, date));
1387
+ }
1388
+ goToPrevious() {
1389
+ if (this.isPreviousDisabled()) {
1390
+ return;
1391
+ }
1392
+ const amount = this.view() === 'month' ? 1 : YEARS_PER_PAGE;
1393
+ this.focusedDate.set(this._dateAdapter.subtract(this.focusedDate(), { years: amount }));
1394
+ }
1395
+ goToNext() {
1396
+ if (this.isNextDisabled()) {
1397
+ return;
1398
+ }
1399
+ const amount = this.view() === 'month' ? 1 : YEARS_PER_PAGE;
1400
+ this.focusedDate.set(this._dateAdapter.add(this.focusedDate(), { years: amount }));
1401
+ }
1402
+ isPreviousDisabled() {
1403
+ if (this.disabled()) {
1404
+ return true;
1405
+ }
1406
+ const min = this.min();
1407
+ if (!min) {
1408
+ return false;
1409
+ }
1410
+ const minYear = this._dateAdapter.getYear(min);
1411
+ if (this.view() === 'month') {
1412
+ return this._dateAdapter.getYear(this.focusedDate()) - 1 < minYear;
1413
+ }
1414
+ return this.yearRange().start - 1 < minYear;
1415
+ }
1416
+ isNextDisabled() {
1417
+ if (this.disabled()) {
1418
+ return true;
1419
+ }
1420
+ const max = this.max();
1421
+ if (!max) {
1422
+ return false;
1423
+ }
1424
+ const maxYear = this._dateAdapter.getYear(max);
1425
+ if (this.view() === 'month') {
1426
+ return this._dateAdapter.getYear(this.focusedDate()) + 1 > maxYear;
1427
+ }
1428
+ return this.yearRange().end + 1 > maxYear;
1429
+ }
1430
+ _focusCell(predicate) {
1431
+ afterNextRender({
1432
+ write: () => {
1433
+ const cell = this._cells.find((c) => predicate(c.value()));
1434
+ if (cell) {
1435
+ cell.focus();
1436
+ }
1437
+ },
1438
+ }, { injector: this._injector });
1439
+ this._changeDetector.detectChanges();
1440
+ }
1441
+ registerCell(cell) {
1442
+ this._cells.push(cell);
1443
+ }
1444
+ unregisterCell(cell) {
1445
+ const index = this._cells.indexOf(cell);
1446
+ if (index !== -1) {
1447
+ this._cells.splice(index, 1);
1448
+ }
1449
+ }
1450
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendar, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1451
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnMonthYearCalendar, isStandalone: true, selector: "[brnMonthYearCalendar]", inputs: { min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null }, viewInput: { classPropertyName: "viewInput", publicName: "view", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange" }, providers: [provideBrnMonthYearCalendar(BrnMonthYearCalendar)], queries: [{ propertyName: "header", first: true, predicate: BrnMonthYearCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
1452
+ }
1453
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendar, decorators: [{
1454
+ type: Directive,
1455
+ args: [{
1456
+ selector: '[brnMonthYearCalendar]',
1457
+ providers: [provideBrnMonthYearCalendar(BrnMonthYearCalendar)],
1458
+ }]
1459
+ }], propDecorators: { min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], viewInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "view", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnMonthYearCalendarHeader), { isSignal: true }] }] } });
1460
+
1461
+ class BrnMonthYearCalendarGrid {
1462
+ /** Access the month/year selector */
1463
+ _monthYear = injectBrnMonthYearCalendar();
1464
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarGrid, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1465
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnMonthYearCalendarGrid, isStandalone: true, selector: "[brnMonthYearCalendarGrid]", host: { attributes: { "role": "grid" }, properties: { "attr.aria-labelledby": "_monthYear.header()?.id()" } }, ngImport: i0 });
1466
+ }
1467
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarGrid, decorators: [{
1468
+ type: Directive,
1469
+ args: [{
1470
+ selector: '[brnMonthYearCalendarGrid]',
1471
+ host: {
1472
+ role: 'grid',
1473
+ '[attr.aria-labelledby]': '_monthYear.header()?.id()',
1474
+ },
1475
+ }]
1476
+ }] });
1477
+
1478
+ class BrnMonthYearCalendarMonthButton {
1479
+ /** Access the date adapter */
1480
+ _dateAdapter = injectDateAdapter();
1481
+ /** Access the month/year selector */
1482
+ _monthYear = injectBrnMonthYearCalendar();
1483
+ /** Access the element ref */
1484
+ _elementRef = inject(ElementRef);
1485
+ _destroyRef = inject(DestroyRef);
1486
+ /** The month this cell represents. */
1487
+ date = input.required(...(ngDevMode ? [{ debugName: "date" }] : /* istanbul ignore next */ []));
1488
+ /** Expose the value for the month/year selector's focus tracking. */
1489
+ value = this.date;
1490
+ selected = computed(() => this._monthYear.isMonthSelected(this.date()), ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
1491
+ today = computed(() => this._monthYear.isMonthToday(this.date()), ...(ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []));
1492
+ disabled = computed(() => this._monthYear.isMonthDisabled(this.date()), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
1493
+ focusable = computed(() => this._dateAdapter.isSameMonth(this._monthYear.focusedDate(), this.date()) &&
1494
+ this._dateAdapter.isSameYear(this._monthYear.focusedDate(), this.date()), ...(ngDevMode ? [{ debugName: "focusable" }] : /* istanbul ignore next */ []));
1495
+ constructor() {
1496
+ this._monthYear.registerCell(this);
1497
+ this._destroyRef.onDestroy(() => this._monthYear.unregisterCell(this));
1498
+ }
1499
+ focusOffset(event, offset) {
1500
+ event.preventDefault();
1501
+ event.stopPropagation();
1502
+ this._monthYear.setFocusedMonth(this._dateAdapter.add(this._monthYear.focusedDate(), { months: offset }));
1503
+ }
1504
+ focusMonth(event, month) {
1505
+ event.preventDefault();
1506
+ event.stopPropagation();
1507
+ this._monthYear.setFocusedMonth(this._dateAdapter.set(this._monthYear.focusedDate(), { month, day: 1 }));
1508
+ }
1509
+ focusYearOffset(event, offset) {
1510
+ event.preventDefault();
1511
+ event.stopPropagation();
1512
+ this._monthYear.setFocusedMonth(this._dateAdapter.add(this._monthYear.focusedDate(), { years: offset }));
1513
+ }
1514
+ getDirection() {
1515
+ return getComputedStyle(this._elementRef.nativeElement).direction === 'rtl' ? 'rtl' : 'ltr';
1516
+ }
1517
+ focus() {
1518
+ this._elementRef.nativeElement.focus();
1519
+ }
1520
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarMonthButton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1521
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnMonthYearCalendarMonthButton, isStandalone: true, selector: "button[brnMonthYearCalendarMonthButton]", inputs: { date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "gridcell", "type": "button" }, listeners: { "click": "_monthYear.selectMonth(date())", "keydown.arrowLeft": "focusOffset($event, getDirection() === \"rtl\" ? 1 : -1)", "keydown.arrowRight": "focusOffset($event, getDirection() === \"rtl\" ? -1 : 1)", "keydown.arrowUp": "focusOffset($event, -4)", "keydown.arrowDown": "focusOffset($event, 4)", "keydown.home": "focusMonth($event, 0)", "keydown.end": "focusMonth($event, 11)", "keydown.pageUp": "focusYearOffset($event, -1)", "keydown.pageDown": "focusYearOffset($event, 1)" }, properties: { "tabindex": "focusable() ? 0 : -1", "attr.data-selected": "selected() ? true : null", "attr.data-today": "today() && !selected() ? true : null", "attr.data-focused": "focusable() ? true : null", "attr.data-disabled": "disabled() ? true : null", "attr.aria-selected": "selected() ? true : null", "attr.aria-disabled": "disabled() ? true : null", "disabled": "disabled()" } }, ngImport: i0 });
1522
+ }
1523
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarMonthButton, decorators: [{
1524
+ type: Directive,
1525
+ args: [{
1526
+ selector: 'button[brnMonthYearCalendarMonthButton]',
1527
+ host: {
1528
+ role: 'gridcell',
1529
+ type: 'button',
1530
+ '[tabindex]': 'focusable() ? 0 : -1',
1531
+ '[attr.data-selected]': 'selected() ? true : null',
1532
+ '[attr.data-today]': 'today() && !selected() ? true : null',
1533
+ '[attr.data-focused]': 'focusable() ? true : null',
1534
+ '[attr.data-disabled]': 'disabled() ? true : null',
1535
+ '[attr.aria-selected]': 'selected() ? true : null',
1536
+ '[attr.aria-disabled]': 'disabled() ? true : null',
1537
+ '[disabled]': 'disabled()',
1538
+ '(click)': '_monthYear.selectMonth(date())',
1539
+ '(keydown.arrowLeft)': 'focusOffset($event, getDirection() === "rtl" ? 1 : -1)',
1540
+ '(keydown.arrowRight)': 'focusOffset($event, getDirection() === "rtl" ? -1 : 1)',
1541
+ '(keydown.arrowUp)': 'focusOffset($event, -4)',
1542
+ '(keydown.arrowDown)': 'focusOffset($event, 4)',
1543
+ '(keydown.home)': 'focusMonth($event, 0)',
1544
+ '(keydown.end)': 'focusMonth($event, 11)',
1545
+ '(keydown.pageUp)': 'focusYearOffset($event, -1)',
1546
+ '(keydown.pageDown)': 'focusYearOffset($event, 1)',
1547
+ },
1548
+ }]
1549
+ }], ctorParameters: () => [], propDecorators: { date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: true }] }] } });
1550
+
1551
+ class BrnMonthYearCalendarNextButton {
1552
+ /** Access the month/year selector */
1553
+ _monthYear = injectBrnMonthYearCalendar();
1554
+ _disabled = computed(() => this._monthYear.isNextDisabled(), ...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
1555
+ _label = computed(() => this._monthYear.view() === 'month' ? 'Go to the next year' : 'Go to the next years', ...(ngDevMode ? [{ debugName: "_label" }] : /* istanbul ignore next */ []));
1556
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarNextButton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1557
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnMonthYearCalendarNextButton, isStandalone: true, selector: "button[brnMonthYearCalendarNextButton]", host: { attributes: { "type": "button", "data-slot": "month-year-next-button" }, listeners: { "click": "_monthYear.goToNext()" }, properties: { "attr.aria-label": "_label()", "attr.aria-disabled": "_disabled() ? true : null", "disabled": "_disabled()" } }, ngImport: i0 });
1558
+ }
1559
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarNextButton, decorators: [{
1560
+ type: Directive,
1561
+ args: [{
1562
+ selector: 'button[brnMonthYearCalendarNextButton]',
1563
+ host: {
1564
+ type: 'button',
1565
+ 'data-slot': 'month-year-next-button',
1566
+ '[attr.aria-label]': '_label()',
1567
+ '[attr.aria-disabled]': '_disabled() ? true : null',
1568
+ '[disabled]': '_disabled()',
1569
+ '(click)': '_monthYear.goToNext()',
1570
+ },
1571
+ }]
1572
+ }] });
1573
+
1574
+ class BrnMonthYearCalendarPreviousButton {
1575
+ /** Access the month/year selector */
1576
+ _monthYear = injectBrnMonthYearCalendar();
1577
+ _disabled = computed(() => this._monthYear.isPreviousDisabled(), ...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
1578
+ _label = computed(() => this._monthYear.view() === 'month' ? 'Go to the previous year' : 'Go to the previous years', ...(ngDevMode ? [{ debugName: "_label" }] : /* istanbul ignore next */ []));
1579
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarPreviousButton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1580
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnMonthYearCalendarPreviousButton, isStandalone: true, selector: "button[brnMonthYearCalendarPreviousButton]", host: { attributes: { "type": "button", "data-slot": "month-year-previous-button" }, listeners: { "click": "_monthYear.goToPrevious()" }, properties: { "attr.aria-label": "_label()", "attr.aria-disabled": "_disabled() ? true : null", "disabled": "_disabled()" } }, ngImport: i0 });
1581
+ }
1582
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarPreviousButton, decorators: [{
1583
+ type: Directive,
1584
+ args: [{
1585
+ selector: 'button[brnMonthYearCalendarPreviousButton]',
1586
+ host: {
1587
+ type: 'button',
1588
+ 'data-slot': 'month-year-previous-button',
1589
+ '[attr.aria-label]': '_label()',
1590
+ '[attr.aria-disabled]': '_disabled() ? true : null',
1591
+ '[disabled]': '_disabled()',
1592
+ '(click)': '_monthYear.goToPrevious()',
1593
+ },
1594
+ }]
1595
+ }] });
1596
+
1597
+ class BrnMonthYearCalendarYearButton {
1598
+ /** Access the date adapter */
1599
+ _dateAdapter = injectDateAdapter();
1600
+ /** Access the month/year selector */
1601
+ _monthYear = injectBrnMonthYearCalendar();
1602
+ /** Access the element ref */
1603
+ _elementRef = inject(ElementRef);
1604
+ _destroyRef = inject(DestroyRef);
1605
+ /** The year this cell represents. */
1606
+ date = input.required(...(ngDevMode ? [{ debugName: "date" }] : /* istanbul ignore next */ []));
1607
+ /** Expose the value for the month/year selector's focus tracking. */
1608
+ value = this.date;
1609
+ selected = computed(() => this._monthYear.isYearSelected(this.date()), ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
1610
+ today = computed(() => this._monthYear.isYearToday(this.date()), ...(ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []));
1611
+ disabled = computed(() => this._monthYear.isYearDisabled(this.date()), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
1612
+ focusable = computed(() => this._dateAdapter.isSameYear(this._monthYear.focusedDate(), this.date()), ...(ngDevMode ? [{ debugName: "focusable" }] : /* istanbul ignore next */ []));
1613
+ _yearsPerPage = YEARS_PER_PAGE;
1614
+ constructor() {
1615
+ this._monthYear.registerCell(this);
1616
+ this._destroyRef.onDestroy(() => this._monthYear.unregisterCell(this));
1617
+ }
1618
+ focusOffset(event, offset) {
1619
+ event.preventDefault();
1620
+ event.stopPropagation();
1621
+ this._monthYear.setFocusedYear(this._dateAdapter.add(this._monthYear.focusedDate(), { years: offset }));
1622
+ }
1623
+ focusYear(event, year) {
1624
+ event.preventDefault();
1625
+ event.stopPropagation();
1626
+ this._monthYear.setFocusedYear(this._dateAdapter.set(this._monthYear.focusedDate(), { year }));
1627
+ }
1628
+ getDirection() {
1629
+ return getComputedStyle(this._elementRef.nativeElement).direction === 'rtl' ? 'rtl' : 'ltr';
1630
+ }
1631
+ focus() {
1632
+ this._elementRef.nativeElement.focus();
1633
+ }
1634
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarYearButton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1635
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnMonthYearCalendarYearButton, isStandalone: true, selector: "button[brnMonthYearCalendarYearButton]", inputs: { date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "gridcell", "type": "button" }, listeners: { "click": "_monthYear.selectYear(date())", "keydown.arrowLeft": "focusOffset($event, getDirection() === \"rtl\" ? 1 : -1)", "keydown.arrowRight": "focusOffset($event, getDirection() === \"rtl\" ? -1 : 1)", "keydown.arrowUp": "focusOffset($event, -4)", "keydown.arrowDown": "focusOffset($event, 4)", "keydown.home": "focusYear($event, _monthYear.yearRange().start)", "keydown.end": "focusYear($event, _monthYear.yearRange().end)", "keydown.pageUp": "focusOffset($event, -_yearsPerPage)", "keydown.pageDown": "focusOffset($event, _yearsPerPage)" }, properties: { "tabindex": "focusable() ? 0 : -1", "attr.data-selected": "selected() ? true : null", "attr.data-today": "today() && !selected() ? true : null", "attr.data-focused": "focusable() ? true : null", "attr.data-disabled": "disabled() ? true : null", "attr.aria-selected": "selected() ? true : null", "attr.aria-disabled": "disabled() ? true : null", "disabled": "disabled()" } }, ngImport: i0 });
1636
+ }
1637
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendarYearButton, decorators: [{
1638
+ type: Directive,
1639
+ args: [{
1640
+ selector: 'button[brnMonthYearCalendarYearButton]',
1641
+ host: {
1642
+ role: 'gridcell',
1643
+ type: 'button',
1644
+ '[tabindex]': 'focusable() ? 0 : -1',
1645
+ '[attr.data-selected]': 'selected() ? true : null',
1646
+ '[attr.data-today]': 'today() && !selected() ? true : null',
1647
+ '[attr.data-focused]': 'focusable() ? true : null',
1648
+ '[attr.data-disabled]': 'disabled() ? true : null',
1649
+ '[attr.aria-selected]': 'selected() ? true : null',
1650
+ '[attr.aria-disabled]': 'disabled() ? true : null',
1651
+ '[disabled]': 'disabled()',
1652
+ '(click)': '_monthYear.selectYear(date())',
1653
+ '(keydown.arrowLeft)': 'focusOffset($event, getDirection() === "rtl" ? 1 : -1)',
1654
+ '(keydown.arrowRight)': 'focusOffset($event, getDirection() === "rtl" ? -1 : 1)',
1655
+ '(keydown.arrowUp)': 'focusOffset($event, -4)',
1656
+ '(keydown.arrowDown)': 'focusOffset($event, 4)',
1657
+ '(keydown.home)': 'focusYear($event, _monthYear.yearRange().start)',
1658
+ '(keydown.end)': 'focusYear($event, _monthYear.yearRange().end)',
1659
+ '(keydown.pageUp)': 'focusOffset($event, -_yearsPerPage)',
1660
+ '(keydown.pageDown)': 'focusOffset($event, _yearsPerPage)',
1661
+ },
1662
+ }]
1663
+ }], ctorParameters: () => [], propDecorators: { date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: true }] }] } });
1664
+
1210
1665
  const BrnCalendarImports = [
1211
1666
  BrnCalendarCellButton,
1212
1667
  BrnCalendarGrid,
@@ -1221,11 +1676,18 @@ const BrnCalendarImports = [
1221
1676
  BrnCalendarRange,
1222
1677
  BrnCalendarMonthSelect,
1223
1678
  BrnCalendarYearSelect,
1679
+ BrnMonthYearCalendar,
1680
+ BrnMonthYearCalendarGrid,
1681
+ BrnMonthYearCalendarHeader,
1682
+ BrnMonthYearCalendarMonthButton,
1683
+ BrnMonthYearCalendarNextButton,
1684
+ BrnMonthYearCalendarPreviousButton,
1685
+ BrnMonthYearCalendarYearButton,
1224
1686
  ];
1225
1687
 
1226
1688
  /**
1227
1689
  * Generated bundle index. Do not edit.
1228
1690
  */
1229
1691
 
1230
- export { BrnCalendar, BrnCalendarCell, BrnCalendarCellButton, BrnCalendarGrid, BrnCalendarHeader, BrnCalendarI18nService, BrnCalendarI18nToken, BrnCalendarImports, BrnCalendarMonthSelect, BrnCalendarMulti, BrnCalendarNextButton, BrnCalendarPreviousButton, BrnCalendarRange, BrnCalendarToken, BrnCalendarWeek, BrnCalendarWeekday, BrnCalendarYearSelect, injectBrnCalendar, injectBrnCalendarI18n, provideBrnCalendar, provideBrnCalendarI18n };
1692
+ export { BrnCalendar, BrnCalendarCell, BrnCalendarCellButton, BrnCalendarGrid, BrnCalendarHeader, BrnCalendarI18nService, BrnCalendarI18nToken, BrnCalendarImports, BrnCalendarMonthSelect, BrnCalendarMulti, BrnCalendarNextButton, BrnCalendarPreviousButton, BrnCalendarRange, BrnCalendarToken, BrnCalendarWeek, BrnCalendarWeekday, BrnCalendarYearSelect, BrnMonthYearCalendar, BrnMonthYearCalendarGrid, BrnMonthYearCalendarHeader, BrnMonthYearCalendarMonthButton, BrnMonthYearCalendarNextButton, BrnMonthYearCalendarPreviousButton, BrnMonthYearCalendarYearButton, injectBrnCalendar, injectBrnCalendarI18n, provideBrnCalendar, provideBrnCalendarI18n };
1231
1693
  //# sourceMappingURL=spartan-ng-brain-calendar.mjs.map