@nanahoshi/mona-ui 0.47.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/tabs.md CHANGED
@@ -4,11 +4,13 @@
4
4
 
5
5
  Entry point: `@nanahoshi/mona-ui/tabs`
6
6
 
7
- **Selector:** `mona-tabs`
7
+ **Selector:** `mona-tabs`, `mona-tab-strip`
8
8
 
9
9
  `TabsComponent` renders a set of `mona-tab` panels and lets the consumer switch between them by clicking a tab or navigating with the keyboard. Tabs are the right choice when each option labels an associated content panel — for example `Account | Security | Notifications`.
10
10
 
11
- The tab strip is line-based: a horizontal rule separates the tab list from the content below it, and the active tab is marked by a short indicator line. The strip can be placed on any edge via the `position` input.
11
+ The tab strip is line-based by default: a horizontal rule separates the tab list from the content below it, and the active tab is marked by a short indicator line. The strip can be placed on any edge via the `position` input. With `look="pill"`, the active tab is raised on a rounded background instead.
12
+
13
+ `TabStripComponent` renders only the tab list, for tabs whose panels are elsewhere on the page, such as browser-style tabs in a window's titlebar.
12
14
 
13
15
  For compact value selection that does not switch content panels — for example `List | Grid` or `Day | Week | Month` — use `SegmentedComponent` instead.
14
16
 
@@ -23,12 +25,16 @@ Tabs organizes related content into named panels and shows one panel at a time.
23
25
 
24
26
  Tabs is not a routing mechanism. Switching tabs does not change the URL. To deep-link to a tab, read the route yourself and bind `selectedIndex`, or `selected` on the tab.
25
27
 
28
+ When the tabs sit apart from what they show, such as browser-style tabs in a window's titlebar over the page below, use `<mona-tab-strip>`. It draws only the tab list, and you render each tab's panel wherever it goes. See [Tabs whose panels are elsewhere](#tabs-whose-panels-are-elsewhere).
29
+
26
30
  ## Import & Quick Start
27
31
 
28
32
  ```typescript
29
33
  import { TabComponent, TabContentTemplateDirective, TabsComponent } from "@nanahoshi/mona-ui/tabs";
30
34
  ```
31
35
 
36
+ For a strip whose panels you render yourself, import `TabStripComponent` instead of `TabsComponent`.
37
+
32
38
  ```html
33
39
  <mona-tabs aria-label="Account">
34
40
  <mona-tab title="Profile">
@@ -69,6 +75,8 @@ Each structural directive below is an `ng-template` placed as projected content
69
75
 
70
76
  A title template renders inside the tab, whose content is presentational to assistive technology, so it can hold text and icons but not links or other controls.
71
77
 
78
+ `<mona-tab-strip>` takes the same `<mona-tab>` children and the same title template. It renders no panels, so it ignores a `monaTabContentTemplate`.
79
+
72
80
  ## Examples
73
81
 
74
82
  ### Setting the selected tab
@@ -180,6 +188,8 @@ export class TabsClosableExampleComponent {
180
188
  </div>
181
189
  ```
182
190
 
191
+ A middle-click on a tab that can close asks to close it too, as it does on a browser's tabs. It doesn't select the tab, and it stops the middle button from starting to autoscroll the page. `tabClose` carries the click as its `originalEvent`.
192
+
183
193
  Closing a tab is entirely the consumer's responsibility — see [Tabs are removed by the consumer](#tabs-are-removed-by-the-consumer).
184
194
 
185
195
  ### Reordering tabs
@@ -316,16 +326,160 @@ A left or right strip requires a constrained available height so its tabs can sc
316
326
  </mona-tabs>
317
327
  ```
318
328
 
329
+ ### The pill look
330
+
331
+ `look="pill"` rounds every tab and raises the selected one on a background with a shadow, in place of the indicator line, and drops the rule between the strip and the content. It suits a strip that stands on its own, such as one in a titlebar. `look` takes the same values on `mona-tabs` and `mona-tab-strip`, and defaults to `"line"`.
332
+
333
+ ```html
334
+ <mona-tab-strip aria-label="Open folders" look="pill">...</mona-tab-strip>
335
+ ```
336
+
337
+ The selected pill's background is `--mona-tab-pill-background` when it's set, and the theme's raised surface, `--color-surface-raised`, when it isn't. The shadow is the theme's `--shadow-raised`. A theme whose raised surface sits too close to the color behind the strip can point the property at a token of its own, on the strip or anywhere above it:
338
+
339
+ ```css
340
+ .app-titlebar {
341
+ --mona-tab-pill-background: var(--color-surface-active);
342
+ }
343
+ ```
344
+
345
+ Pills keep one font weight, so selecting a tab doesn't change its width. In forced colors, where backgrounds and shadows don't paint, the selected pill gets a ring in the system highlight color instead. When the user asks for more contrast, it gets a ring in the text color as well as its background.
346
+
347
+ ### Tabs whose panels are elsewhere
348
+
349
+ `<mona-tab-strip>` renders only the tab list. Each tab's panel is yours to render, anywhere on the page, which suits browser-style tabs in a window's titlebar over the content below. It takes the same `<mona-tab>` children as `mona-tabs`, and keeps the same `selectedIndex`, `closable`, `sortable`, keyboard and scrolling behavior.
350
+
351
+ `strip-example.component.ts`
352
+
353
+ ```typescript
354
+ import { Component, computed, signal } from "@angular/core";
355
+ import { LucideFolder, LucidePlus } from "@lucide/angular";
356
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
357
+ import { moveItem } from "@nanahoshi/mona-ui/sortable";
358
+ import {
359
+ type TabCloseEvent,
360
+ type TabReorderEvent,
361
+ TabComponent,
362
+ TabStripComponent,
363
+ TabTitleTemplateDirective
364
+ } from "@nanahoshi/mona-ui/tabs";
365
+
366
+ interface Folder {
367
+ readonly id: number;
368
+ readonly items: number;
369
+ readonly name: string;
370
+ }
371
+
372
+ @Component({
373
+ selector: "app-tabs-strip-example",
374
+ imports: [ButtonDirective, LucideFolder, LucidePlus, TabComponent, TabStripComponent, TabTitleTemplateDirective],
375
+ templateUrl: "./strip-example.component.html"
376
+ })
377
+ export class TabsStripExampleComponent {
378
+ #nextId = 4;
379
+ protected readonly folders = signal<readonly Folder[]>([
380
+ { id: 1, items: 12, name: "Documents" },
381
+ { id: 2, items: 48, name: "Pictures" },
382
+ { id: 3, items: 7, name: "Projects" }
383
+ ]);
384
+ /** The panel shows the selected folder, and the strip moves the selection when that folder's tab closes. */
385
+ protected readonly selected = computed(() => this.folders()[this.selectedIndex()] ?? null);
386
+ protected readonly selectedIndex = signal(0);
387
+
388
+ protected add(): void {
389
+ const id = this.#nextId++;
390
+ this.folders.update(folders => [...folders, { id, items: 0, name: `New folder ${id}` }]);
391
+ this.selectedIndex.set(this.folders().length - 1);
392
+ }
393
+
394
+ /** The strip only asks; removing the folder is what closes its tab. */
395
+ protected close(event: TabCloseEvent): void {
396
+ this.folders.update(folders => folders.filter((_, index) => index !== event.index));
397
+ }
398
+
399
+ protected reorder(event: TabReorderEvent): void {
400
+ this.folders.update(folders => moveItem(folders, event.previousIndex, event.currentIndex));
401
+ }
402
+ }
403
+ ```
404
+
405
+ `strip-example.component.html`
406
+
407
+ ```html
408
+ <div class="flex w-[32rem] max-w-full flex-col overflow-hidden rounded-lg border border-border">
409
+ <div class="flex h-12 items-center gap-1 bg-canvas px-2">
410
+ <mona-tab-strip
411
+ aria-label="Open folders"
412
+ look="pill"
413
+ size="small"
414
+ closable
415
+ sortable
416
+ [(selectedIndex)]="selectedIndex"
417
+ (tabClose)="close($event)"
418
+ (tabReorder)="reorder($event)">
419
+ @for (folder of folders(); track folder.id) {
420
+ <mona-tab [tabId]="'folder-tab-' + folder.id" panelId="folder-view" [title]="folder.name">
421
+ <ng-template monaTabTitleTemplate>
422
+ <span class="flex items-center gap-1.5">
423
+ <svg lucideFolder aria-hidden="true" [size]="14"></svg>
424
+ <span>{{ folder.name }}</span>
425
+ </span>
426
+ </ng-template>
427
+ </mona-tab>
428
+ }
429
+ </mona-tab-strip>
430
+ <button monaButton look="ghost" size="small" [iconOnly]="true" aria-label="New tab" (click)="add()">
431
+ <svg lucidePlus [size]="15"></svg>
432
+ </button>
433
+ <div class="h-full min-w-6 flex-1"></div>
434
+ </div>
435
+ <div
436
+ id="folder-view"
437
+ role="tabpanel"
438
+ tabindex="0"
439
+ class="h-32 p-4 text-sm focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-indicator"
440
+ [attr.aria-labelledby]="selected() ? 'folder-tab-' + selected()?.id : null">
441
+ @if (selected(); as folder) {
442
+ <p>{{ folder.name }} holds {{ folder.items }} items.</p>
443
+ } @else {
444
+ <p>No folders are open.</p>
445
+ }
446
+ </div>
447
+ </div>
448
+ ```
449
+
450
+ The tab and its panel still name each other, so assistive technology can go from one to the other:
451
+
452
+ - `panelId` on each `mona-tab` is the id of the panel you render. The tab names it in `aria-controls`. Tabs can share one panel when the page shows one place at a time, as above. A tab without a `panelId` has no `aria-controls`.
453
+ - `tabId` on each `mona-tab` is the id of the tab element. Set it to know it, or read it back from the tab when it's generated. Point the panel's `aria-labelledby` at the selected tab's `tabId`.
454
+ - Give the panel `role="tabpanel"` and, unless the first thing in it takes focus, `tabindex="0"`.
455
+
456
+ ```html
457
+ <mona-tab-strip aria-label="Open folders" look="pill" [(selectedIndex)]="selectedIndex">
458
+ @for (folder of folders(); track folder.id) {
459
+ <mona-tab [tabId]="'folder-tab-' + folder.id" panelId="folder-view" [title]="folder.name"></mona-tab>
460
+ }
461
+ </mona-tab-strip>
462
+
463
+ <div id="folder-view" role="tabpanel" tabindex="0" [attr.aria-labelledby]="'folder-tab-' + selected().id">...</div>
464
+ ```
465
+
466
+ In `mona-tabs`, `tabId` and `panelId` set the ids of the tab and of the panel the component renders, and both are generated when they're empty.
467
+
468
+ `Tab` on a strip goes to the next control after it, such as a new-tab button, rather than into the panel, since the panel may be anywhere on the page. See [A strip in a row of controls](#a-strip-in-a-row-of-controls) for the layout.
469
+
319
470
  ### Migrating from the removed `rounded` input
320
471
 
321
- The `rounded` input has been removed. Tabs are line-based: the tab strip is separated from the content by a rule and the active tab is marked by an indicator line, so no radius is applied to the strip or the content.
472
+ The `rounded` input has been removed. The tab strip is separated from the content by a rule and the active tab is marked by an indicator line, so no radius is applied to the strip or the content. For rounded tabs, use the [pill look](#the-pill-look).
322
473
 
323
474
  ```text
324
475
  Before:
325
476
  <mona-tabs rounded="large">
326
477
 
327
- After:
478
+ After, with the line look:
328
479
  <mona-tabs>
480
+
481
+ After, with rounded tabs:
482
+ <mona-tabs look="pill">
329
483
  ```
330
484
 
331
485
  Tab content no longer receives a default card-like surface. Consumers that need that appearance should wrap their tab content in `mona-card` or apply their own surface styles.
@@ -386,7 +540,7 @@ export class TabsCancelSelectExampleComponent {
386
540
 
387
541
  ### Tabs are removed by the consumer
388
542
 
389
- `TabsComponent` does not remove a `<mona-tab>` from the DOM when it is closed. `tabClose` only notifies the consumer that a close was requested (by clicking the close button or pressing Delete/Backspace on a tab); the consumer is responsible for removing the corresponding tab from whatever collection drives the projected `<mona-tab>` elements (typically an `@for` loop).
543
+ `TabsComponent` and `TabStripComponent` do not remove a `<mona-tab>` from the DOM when it is closed. `tabClose` only notifies the consumer that a close was requested (by clicking the close button, pressing Delete/Backspace on a tab, or middle-clicking it); the consumer is responsible for removing the corresponding tab from whatever collection drives the projected `<mona-tab>` elements (typically an `@for` loop).
390
544
 
391
545
  ### What happens when the selected tab goes away
392
546
 
@@ -412,6 +566,20 @@ Changing a tab's `title`, `disabled` or `closable` leaves its panel and everythi
412
566
 
413
567
  When the tab strip overflows its container, scroll buttons appear automatically — this is not controlled by a public input. Top and bottom strips overflow horizontally (left/right scroll buttons); left and right strips overflow vertically (up/down scroll buttons). The scroll buttons are hidden from assistive technology and are not a Tab stop. Keyboard users can still reach tabs outside the visible area because moving focus with the arrow keys scrolls the newly focused tab into view. A tab selected by code is scrolled into view within the strip, without scrolling the page. Scroll buttons don't animate when the user asks for reduced motion.
414
568
 
569
+ ### A strip in a row of controls
570
+
571
+ A `mona-tab-strip` is as wide as its tabs and shrinks with the row it's in, down to nothing, scrolling its tabs once they don't fit. In a titlebar, put it in a flex row and let the space after it grow, so the strip gives way before the controls around it:
572
+
573
+ ```html
574
+ <header class="flex h-12 items-center gap-1">
575
+ <mona-tab-strip aria-label="Open folders" look="pill" size="small">...</mona-tab-strip>
576
+ <button monaButton look="ghost" [iconOnly]="true" aria-label="New tab" (click)="add()">+</button>
577
+ <div class="h-full min-w-6 flex-1"></div>
578
+ </header>
579
+ ```
580
+
581
+ The strip is only as tall as its tabs, so center it in a taller row. With the pill look it draws no rule along its edge. A strip is always horizontal.
582
+
415
583
  ### Vertical layout constraints
416
584
 
417
585
  A left or right tab strip needs a constrained available height. If the strip is as tall as its content, the tabs have no room to scroll and overflow tabs become unreachable. Give the `mona-tabs` host a bounded height (for example `class="h-96"`) when using `position="left"` or `position="right"`.
@@ -433,14 +601,14 @@ Not applicable. `TabsComponent` and `TabComponent` are not form controls and do
433
601
  | `Home` / `End` | Select the first/last enabled tab. |
434
602
  | `Delete` / `Backspace` | Close the tab that has focus, if it is closable and not disabled. |
435
603
  | `Control+Shift` with the strip's arrow keys, `Home` or `End` (`Command+Shift` on macOS) | With `sortable`: move the focused tab one place, or to the start or end of the strip. |
436
- | `Tab` | Moves focus from the tab strip into the selected tab's panel. |
604
+ | `Tab` | Moves focus from the tab strip into the selected tab's panel. In `mona-tab-strip`, moves on to the next control after the strip. |
437
605
  | `Shift+Tab` (while the panel itself has focus) | Moves focus back to the selected tab. |
438
606
 
439
607
  In a right-to-left layout, `ArrowLeft` and `ArrowRight` swap, so they still follow the strip.
440
608
 
441
609
  These keys are left to the browser when `Alt`, `Ctrl` or `Meta` is held, so `Alt+ArrowLeft` still goes back, and when `Shift` is held on the arrows, except for the moves of a `sortable` strip.
442
610
 
443
- The close button on each tab is not a Tab stop; keyboard users close a tab with `Delete`/`Backspace` instead of activating the close button directly.
611
+ The close button on each tab is not a Tab stop; keyboard users close a tab with `Delete`/`Backspace` instead of activating the close button directly. With a pointer, a middle-click on a tab that can close does the same as its close button.
444
612
 
445
613
  A vetoed tab can have focus without being selected. `Tab` still goes to the selected tab's panel, and coming back lands on the selected tab.
446
614
 
@@ -457,14 +625,17 @@ The selected tab is the only tab in the Tab order (`tabindex="0"`); all other ta
457
625
  | Tab list | `aria-labelledby` | When the `aria-labelledby` input is set | The input's value |
458
626
  | Tab list | `aria-orientation` | Always | `"horizontal"` for top/bottom positions, `"vertical"` for left/right |
459
627
  | Tab | `role` | Always | `"tab"` |
628
+ | Tab | `id` | Always | The tab's `tabId`, generated when it isn't set |
460
629
  | Tab | `aria-selected` | Always | Reflects whether the tab is the active tab |
461
630
  | Tab | `aria-disabled` | Always | Reflects the tab's effective disabled state (own `disabled`, or the parent's `disabled`) |
462
- | Tab | `aria-controls` | Always | The corresponding panel's element id |
631
+ | Tab | `aria-controls` | Always in `mona-tabs`; in `mona-tab-strip`, when the tab has a `panelId` | The corresponding panel's element id: the tab's `panelId`, or the generated id of the panel `mona-tabs` renders |
463
632
  | Tab | `aria-keyshortcuts` | The tab can close, or the strip is `sortable`, and the tab isn't disabled | `"Delete Backspace"` when it can close, then the moves, such as `"Control+Shift+ArrowLeft Control+Shift+ArrowRight Control+Shift+Home Control+Shift+End"` |
464
633
  | Panel | `role` | Always | `"tabpanel"` |
465
634
  | Panel | `aria-hidden` | Always | `"true"` on a kept panel that isn't the active one, otherwise `"false"` |
466
635
  | Panel | `aria-labelledby` | Always | The corresponding tab's element id |
467
636
 
637
+ The panel rows are for `mona-tabs`. With `mona-tab-strip`, the panel is yours: give it `role="tabpanel"` and an `aria-labelledby` naming the selected tab's `tabId`, as in [Tabs whose panels are elsewhere](#tabs-whose-panels-are-elsewhere).
638
+
468
639
  Give the tab list a name with `aria-label` or `aria-labelledby` on `mona-tabs` when the page has more than one set of tabs, or when nothing nearby says what they're for. The inputs go to the tab list, not the host.
469
640
 
470
641
  A tab list may only contain tabs, and a tab's content is presentational, so a close button can't be exposed in either place. Axe rejects one anywhere inside the tab list, even beside the tab. That's why the visible close button, which is there for the pointer, is hidden from assistive technology with `aria-hidden` and `tabindex="-1"`. Each closable tab also gets a visually hidden button after the tab list, named "Close tab" plus the tab's title, which screen readers can reach and activate, including on touch devices. It's out of the Tab order too, since the keyboard's route is `Delete` or `Backspace`. Its text comes from `closeTab` in the `tabs` messages.
@@ -476,6 +647,7 @@ Everything below is imported from `@nanahoshi/mona-ui/tabs`. Each name links to
476
647
  | Name | Kind | Description |
477
648
  | --- | --- | --- |
478
649
  | [`TabsComponent`](api/tabs.md#tabscomponent) | Component | |
650
+ | [`TabStripComponent`](api/tabs.md#tabstripcomponent) | Component | Only the tab list of a set of tabs, for when each tab's panel is somewhere else on the page, as with the tabs in a window's titlebar. |
479
651
  | [`TabComponent`](api/tabs.md#tabcomponent) | Component | |
480
652
  | [`TabContentTemplateDirective`](api/tabs.md#tabcontenttemplatedirective) | Directive | |
481
653
  | [`TabTitleTemplateDirective`](api/tabs.md#tabtitletemplatedirective) | Directive | |
@@ -485,9 +657,10 @@ Everything below is imported from `@nanahoshi/mona-ui/tabs`. Each name links to
485
657
 
486
658
  ### Types
487
659
 
488
- | Type | Kind |
489
- | --- | --- |
490
- | [`TABS_DEFAULT_MESSAGES`](api/tabs.md#tabs-default-messages) | Constant |
491
- | [`TabsPosition`](api/tabs.md#tabsposition) | Type alias |
660
+ | Type | Kind | Description |
661
+ | --- | --- | --- |
662
+ | [`TABS_DEFAULT_MESSAGES`](api/tabs.md#tabs-default-messages) | Constant | |
663
+ | [`TabsLook`](api/tabs.md#tabslook) | Type alias | How a tab strip marks the selected tab. |
664
+ | [`TabsPosition`](api/tabs.md#tabsposition) | Type alias | |
492
665
 
493
666
  **Related types:** [`MonaTabsMessages`](api/i18n.md#monatabsmessages), [`PreventableEvent`](api/common.md#preventableevent)
@@ -1,4 +1,4 @@
1
- import { q as GridService } from "./grid.styles-BJHVTT_v.mjs";
1
+ import { q as GridService } from "./grid.styles-D6jP3vwD.mjs";
2
2
  import * as i0 from "@angular/core";
3
3
  import { Component, inject } from "@angular/core";
4
4
  import { take } from "rxjs";
@@ -74,4 +74,4 @@ i0.ɵɵngDeclareClassMetadata({
74
74
  });
75
75
  export { removeGridRow as n, GridColgroupComponent as t };
76
76
 
77
- //# sourceMappingURL=grid-colgroup.component-B4jx10Yi.mjs.map
77
+ //# sourceMappingURL=grid-colgroup.component-BFbiAvkG.mjs.map
@@ -1,4 +1,4 @@
1
- import { H as GridLogicalCellDirective, K as GridLockedCellDirective, h as gridFooterTableRowThemeVariants, m as gridFooterTableCellThemeVariants, q as GridService } from "./grid.styles-BJHVTT_v.mjs";
1
+ import { H as GridLogicalCellDirective, K as GridLockedCellDirective, h as gridFooterTableRowThemeVariants, m as gridFooterTableCellThemeVariants, q as GridService } from "./grid.styles-D6jP3vwD.mjs";
2
2
  import { NgTemplateOutlet } from "@angular/common";
3
3
  import * as i0 from "@angular/core";
4
4
  import { Component, Directive, computed, inject, input } from "@angular/core";
@@ -405,6 +405,7 @@ var GridFooterRowComponent = class GridFooterRowComponent {
405
405
  "treeCell"
406
406
  ],
407
407
  outputs: [
408
+ "activate",
408
409
  "edit",
409
410
  "menuOpen",
410
411
  "toggleExpand"
@@ -483,4 +484,4 @@ i0.ɵɵngDeclareClassMetadata({
483
484
  });
484
485
  export { GridFooterRowComponent };
485
486
 
486
- //# sourceMappingURL=grid-footer-row.component-CVUltI39.mjs.map
487
+ //# sourceMappingURL=grid-footer-row.component-DpSu7jvG.mjs.map
@@ -1,7 +1,7 @@
1
- import { I as gridRowDragPreviewThemeVariants, K as GridLockedCellDirective, P as gridListTableThemeVariants, j as gridListBaseThemeVariants, q as GridService } from "./grid.styles-BJHVTT_v.mjs";
2
- import { i as GridCellDirective, n as GridGroupRowComponent, r as GridAddRowComponent, t as GridRowComponent } from "./grid-row.component-BauMmps5.mjs";
3
- import { t as GridColgroupComponent } from "./grid-colgroup.component-B4jx10Yi.mjs";
4
- import { GridFooterRowComponent } from "./grid-footer-row.component-CVUltI39.mjs";
1
+ import { I as gridRowDragPreviewThemeVariants, K as GridLockedCellDirective, P as gridListTableThemeVariants, j as gridListBaseThemeVariants, q as GridService } from "./grid.styles-D6jP3vwD.mjs";
2
+ import { i as GridCellDirective, n as GridGroupRowComponent, r as GridAddRowComponent, t as GridRowComponent } from "./grid-row.component-CuCQ_Z5F.mjs";
3
+ import { t as GridColgroupComponent } from "./grid-colgroup.component-BFbiAvkG.mjs";
4
+ import { GridFooterRowComponent } from "./grid-footer-row.component-DpSu7jvG.mjs";
5
5
  import { NgTemplateOutlet } from "@angular/common";
6
6
  import * as i0 from "@angular/core";
7
7
  import { Component, DestroyRef, ElementRef, afterNextRender, afterRenderEffect, computed, effect, inject, input, untracked, viewChild } from "@angular/core";
@@ -471,4 +471,4 @@ i0.ɵɵngDeclareClassMetadata({
471
471
  });
472
472
  export { GridListComponent };
473
473
 
474
- //# sourceMappingURL=grid-list.component-Cv1KB5VQ.mjs.map
474
+ //# sourceMappingURL=grid-list.component-B-F4bvFL.mjs.map
@@ -1,5 +1,5 @@
1
- import { B as gridTreeLeafSpacerThemeVariants, H as GridLogicalCellDirective, K as GridLockedCellDirective, L as gridRowReorderHandleThemeVariants, M as gridListTableCellThemeVariants, N as gridListTableRowThemeVariants, Q as formatGridCellValue, U as GRID_CELL_FOCUSABLE_SELECTOR, V as gridTreeToggleThemeVariants, a as gridCellEditorBaseThemeVariants, b as gridGroupRowThemeVariants, i as gridCellDirtyIndicatorThemeVariants, n as gridCellBaseThemeVariants, o as gridCellEditorInputThemeVariants, q as GridService, r as gridCellContainerThemeVariants, s as gridCellTextThemeVariants, tt as GridNavigationService, z as gridSelectionCellThemeVariants } from "./grid.styles-BJHVTT_v.mjs";
2
- import { n as removeGridRow } from "./grid-colgroup.component-B4jx10Yi.mjs";
1
+ import { B as gridTreeLeafSpacerThemeVariants, H as GridLogicalCellDirective, K as GridLockedCellDirective, L as gridRowReorderHandleThemeVariants, M as gridListTableCellThemeVariants, N as gridListTableRowThemeVariants, Q as formatGridCellValue, U as GRID_CELL_FOCUSABLE_SELECTOR, V as gridTreeToggleThemeVariants, a as gridCellEditorBaseThemeVariants, b as gridGroupRowThemeVariants, i as gridCellDirtyIndicatorThemeVariants, n as gridCellBaseThemeVariants, o as gridCellEditorInputThemeVariants, q as GridService, r as gridCellContainerThemeVariants, s as gridCellTextThemeVariants, tt as GridNavigationService, z as gridSelectionCellThemeVariants } from "./grid.styles-D6jP3vwD.mjs";
2
+ import { n as removeGridRow } from "./grid-colgroup.component-BFbiAvkG.mjs";
3
3
  import { NgTemplateOutlet } from "@angular/common";
4
4
  import * as i0 from "@angular/core";
5
5
  import { Component, Directive, ElementRef, Injector, LOCALE_ID, afterNextRender, computed, effect, inject, input, isDevMode, model, output, signal, untracked, viewChild } from "@angular/core";
@@ -1028,6 +1028,7 @@ var GridAddRowComponent = class GridAddRowComponent {
1028
1028
  "treeCell"
1029
1029
  ],
1030
1030
  outputs: [
1031
+ "activate",
1031
1032
  "edit",
1032
1033
  "menuOpen",
1033
1034
  "toggleExpand"
@@ -1301,6 +1302,7 @@ var GridGroupRowComponent = class GridGroupRowComponent {
1301
1302
  "treeCell"
1302
1303
  ],
1303
1304
  outputs: [
1305
+ "activate",
1304
1306
  "edit",
1305
1307
  "menuOpen",
1306
1308
  "toggleExpand"
@@ -1459,7 +1461,10 @@ var GridCellComponent = class GridCellComponent {
1459
1461
  this.gridService.startRowEdit(this.row(), originalEvent, column.editable ? column.id : null);
1460
1462
  }
1461
1463
  onCellDoubleClick(event) {
1462
- if (this.gridService.editableOptions().mode === "cell") this.startEdit(event);
1464
+ if (this.gridService.editableOptions().mode === "cell" && this.canEdit()) {
1465
+ event.preventDefault();
1466
+ this.startEdit(event);
1467
+ }
1463
1468
  }
1464
1469
  onEditCancel() {
1465
1470
  if (this.gridService.editContext() != null && this.gridService.cancelEdit(void 0, "escape")) this.focusHostCell();
@@ -1486,6 +1491,10 @@ var GridCellComponent = class GridCellComponent {
1486
1491
  event.stopPropagation();
1487
1492
  this.gridService.toggleTreeRow(this.row());
1488
1493
  }
1494
+ canEdit() {
1495
+ const column = this.column();
1496
+ return !!this.gridService.editableOptions().enabled && column.editable && column.kind === "data";
1497
+ }
1489
1498
  focusHostCell() {
1490
1499
  this.#elementRef.nativeElement.closest("td")?.focus();
1491
1500
  }
@@ -1493,7 +1502,7 @@ var GridCellComponent = class GridCellComponent {
1493
1502
  this.#elementRef.nativeElement.querySelector(GRID_CELL_FOCUSABLE_SELECTOR)?.focus();
1494
1503
  }
1495
1504
  startEdit(originalEvent) {
1496
- if (!this.gridService.editableOptions().enabled || !this.column().editable || this.column().kind !== "data") return;
1505
+ if (!this.canEdit()) return;
1497
1506
  this.gridService.startCellEdit(this.cellUid(), this.row(), this.column(), originalEvent);
1498
1507
  }
1499
1508
  static {
@@ -1896,6 +1905,13 @@ i0.ɵɵngDeclareClassMetadata({
1896
1905
  }]
1897
1906
  }
1898
1907
  });
1908
+ const CELL_CONTROL_SELECTOR = `${GRID_CELL_FOCUSABLE_SELECTOR}, label, summary, [contenteditable]:not([contenteditable="false"])`;
1909
+ function isInCellControl(target) {
1910
+ if (!(target instanceof Element)) return false;
1911
+ const cell = target.closest("td");
1912
+ const control = target.closest(CELL_CONTROL_SELECTOR);
1913
+ return cell != null && control != null && control !== cell && cell.contains(control);
1914
+ }
1899
1915
  var GridRowComponent = class GridRowComponent {
1900
1916
  constructor() {
1901
1917
  this.ariaLevel = computed(() => {
@@ -1932,9 +1948,16 @@ var GridRowComponent = class GridRowComponent {
1932
1948
  this.row = input.required(...ngDevMode ? [{ debugName: "row" }] : /* istanbul ignore next */ []);
1933
1949
  this.selected = computed(() => this.gridService.isRowSelected(this.row()), ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
1934
1950
  }
1951
+ onActivate(event) {
1952
+ this.gridService.activateRow(this.row(), event);
1953
+ }
1935
1954
  onClick(event) {
1936
1955
  this.gridService.handleRowClick(event, this.row());
1937
1956
  }
1957
+ onDoubleClick(event) {
1958
+ if (event.defaultPrevented || isInCellControl(event.target)) return;
1959
+ this.gridService.activateRow(this.row(), event);
1960
+ }
1938
1961
  toggleDetail() {
1939
1962
  this.gridService.setRowExpanded(this.row(), !this.expanded());
1940
1963
  }
@@ -1983,7 +2006,10 @@ var GridRowComponent = class GridRowComponent {
1983
2006
  },
1984
2007
  host: {
1985
2008
  attributes: { "role": "row" },
1986
- listeners: { "click": "onClick($event)" },
2009
+ listeners: {
2010
+ "click": "onClick($event)",
2011
+ "dblclick": "onDoubleClick($event)"
2012
+ },
1987
2013
  properties: {
1988
2014
  "class": "baseClass()",
1989
2015
  "attr.data-ruid": "row().uid",
@@ -1998,7 +2024,7 @@ var GridRowComponent = class GridRowComponent {
1998
2024
  },
1999
2025
  exportAs: ["monaGridRow"],
2000
2026
  ngImport: i0,
2001
- template: "@for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"layoutColumn.column.kind\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [columnId]=\"layoutColumn.column.id\"\n [editable]=\"cellEditMode() && layoutColumn.column.kind === 'data' && layoutColumn.column.editable === true\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n [readOnly]=\"editingEnabled() && layoutColumn.column.kind === 'data' ? !layoutColumn.column.editable : null\"\n [treeCell]=\"layoutColumn.column.id === gridService.treeColumnId()\"\n [expanded]=\"\n layoutColumn.column.id === gridService.treeColumnId() && treeInfo()?.hasChildren\n ? treeInfo()!.expanded\n : null\n \"\n (edit)=\"gridCell.handleLogicalCellEnter()\"\n (toggleExpand)=\"toggleTree()\">\n <mona-grid-cell #gridCell [column]=\"layoutColumn.column\" [row]=\"row()\" />\n </td>\n } @else if (layoutColumn.kind === \"group\") {\n <td monaGridCell [monaGridLockedCell]=\"layoutColumn.key\" [lockedCellHeader]=\"true\" [groupIndent]=\"true\"></td>\n } @else if (layoutColumn.kind === \"reorder\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$rowReorder'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n <mona-grid-row-reorder-handle [row]=\"row()\" [pageIndex]=\"index()\" />\n </td>\n } @else if (layoutColumn.kind === \"detail\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'detail'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (toggleExpand)=\"toggleDetail()\">\n <span [class]=\"detailToggleClass()\">\n <mona-grid-toggle\n [expanded]=\"expanded()\"\n [label]=\"detailToggleLabel()\"\n [type]=\"'detail'\"\n [width]=\"gridService.detailColumnWidth\"\n (expandedChange)=\"toggleDetail()\" />\n </span>\n </td>\n } @else if (layoutColumn.kind === \"selection\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$selection'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n <mona-grid-selection-checkbox [row]=\"row()\" [rowIndex]=\"index()\" />\n </td>\n }\n}\n",
2027
+ template: "@for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"layoutColumn.column.kind\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [columnId]=\"layoutColumn.column.id\"\n [editable]=\"cellEditMode() && layoutColumn.column.kind === 'data' && layoutColumn.column.editable === true\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n [readOnly]=\"editingEnabled() && layoutColumn.column.kind === 'data' ? !layoutColumn.column.editable : null\"\n [treeCell]=\"layoutColumn.column.id === gridService.treeColumnId()\"\n [expanded]=\"\n layoutColumn.column.id === gridService.treeColumnId() && treeInfo()?.hasChildren\n ? treeInfo()!.expanded\n : null\n \"\n (activate)=\"onActivate($event)\"\n (edit)=\"gridCell.handleLogicalCellEnter()\"\n (toggleExpand)=\"toggleTree()\">\n <mona-grid-cell #gridCell [column]=\"layoutColumn.column\" [row]=\"row()\" />\n </td>\n } @else if (layoutColumn.kind === \"group\") {\n <td monaGridCell [monaGridLockedCell]=\"layoutColumn.key\" [lockedCellHeader]=\"true\" [groupIndent]=\"true\"></td>\n } @else if (layoutColumn.kind === \"reorder\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$rowReorder'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (activate)=\"onActivate($event)\">\n <mona-grid-row-reorder-handle [row]=\"row()\" [pageIndex]=\"index()\" />\n </td>\n } @else if (layoutColumn.kind === \"detail\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'detail'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (toggleExpand)=\"toggleDetail()\">\n <span [class]=\"detailToggleClass()\">\n <mona-grid-toggle\n [expanded]=\"expanded()\"\n [label]=\"detailToggleLabel()\"\n [type]=\"'detail'\"\n [width]=\"gridService.detailColumnWidth\"\n (expandedChange)=\"toggleDetail()\" />\n </span>\n </td>\n } @else if (layoutColumn.kind === \"selection\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$selection'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (activate)=\"onActivate($event)\">\n <mona-grid-selection-checkbox [row]=\"row()\" [rowIndex]=\"index()\" />\n </td>\n }\n}\n",
2002
2028
  dependencies: [
2003
2029
  {
2004
2030
  kind: "component",
@@ -2049,6 +2075,7 @@ var GridRowComponent = class GridRowComponent {
2049
2075
  "treeCell"
2050
2076
  ],
2051
2077
  outputs: [
2078
+ "activate",
2052
2079
  "edit",
2053
2080
  "menuOpen",
2054
2081
  "toggleExpand"
@@ -2112,9 +2139,10 @@ i0.ɵɵngDeclareClassMetadata({
2112
2139
  "[attr.aria-expanded]": "treeInfo()?.hasChildren ? treeInfo()!.expanded : null",
2113
2140
  "[attr.aria-posinset]": "treeInfo()?.posInSet ?? null",
2114
2141
  "[attr.aria-setsize]": "treeInfo()?.setSize ?? null",
2115
- "(click)": "onClick($event)"
2142
+ "(click)": "onClick($event)",
2143
+ "(dblclick)": "onDoubleClick($event)"
2116
2144
  },
2117
- template: "@for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"layoutColumn.column.kind\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [columnId]=\"layoutColumn.column.id\"\n [editable]=\"cellEditMode() && layoutColumn.column.kind === 'data' && layoutColumn.column.editable === true\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n [readOnly]=\"editingEnabled() && layoutColumn.column.kind === 'data' ? !layoutColumn.column.editable : null\"\n [treeCell]=\"layoutColumn.column.id === gridService.treeColumnId()\"\n [expanded]=\"\n layoutColumn.column.id === gridService.treeColumnId() && treeInfo()?.hasChildren\n ? treeInfo()!.expanded\n : null\n \"\n (edit)=\"gridCell.handleLogicalCellEnter()\"\n (toggleExpand)=\"toggleTree()\">\n <mona-grid-cell #gridCell [column]=\"layoutColumn.column\" [row]=\"row()\" />\n </td>\n } @else if (layoutColumn.kind === \"group\") {\n <td monaGridCell [monaGridLockedCell]=\"layoutColumn.key\" [lockedCellHeader]=\"true\" [groupIndent]=\"true\"></td>\n } @else if (layoutColumn.kind === \"reorder\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$rowReorder'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n <mona-grid-row-reorder-handle [row]=\"row()\" [pageIndex]=\"index()\" />\n </td>\n } @else if (layoutColumn.kind === \"detail\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'detail'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (toggleExpand)=\"toggleDetail()\">\n <span [class]=\"detailToggleClass()\">\n <mona-grid-toggle\n [expanded]=\"expanded()\"\n [label]=\"detailToggleLabel()\"\n [type]=\"'detail'\"\n [width]=\"gridService.detailColumnWidth\"\n (expandedChange)=\"toggleDetail()\" />\n </span>\n </td>\n } @else if (layoutColumn.kind === \"selection\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$selection'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n <mona-grid-selection-checkbox [row]=\"row()\" [rowIndex]=\"index()\" />\n </td>\n }\n}\n"
2145
+ template: "@for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"layoutColumn.column.kind\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [columnId]=\"layoutColumn.column.id\"\n [editable]=\"cellEditMode() && layoutColumn.column.kind === 'data' && layoutColumn.column.editable === true\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n [readOnly]=\"editingEnabled() && layoutColumn.column.kind === 'data' ? !layoutColumn.column.editable : null\"\n [treeCell]=\"layoutColumn.column.id === gridService.treeColumnId()\"\n [expanded]=\"\n layoutColumn.column.id === gridService.treeColumnId() && treeInfo()?.hasChildren\n ? treeInfo()!.expanded\n : null\n \"\n (activate)=\"onActivate($event)\"\n (edit)=\"gridCell.handleLogicalCellEnter()\"\n (toggleExpand)=\"toggleTree()\">\n <mona-grid-cell #gridCell [column]=\"layoutColumn.column\" [row]=\"row()\" />\n </td>\n } @else if (layoutColumn.kind === \"group\") {\n <td monaGridCell [monaGridLockedCell]=\"layoutColumn.key\" [lockedCellHeader]=\"true\" [groupIndent]=\"true\"></td>\n } @else if (layoutColumn.kind === \"reorder\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$rowReorder'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (activate)=\"onActivate($event)\">\n <mona-grid-row-reorder-handle [row]=\"row()\" [pageIndex]=\"index()\" />\n </td>\n } @else if (layoutColumn.kind === \"detail\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'detail'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (toggleExpand)=\"toggleDetail()\">\n <span [class]=\"detailToggleClass()\">\n <mona-grid-toggle\n [expanded]=\"expanded()\"\n [label]=\"detailToggleLabel()\"\n [type]=\"'detail'\"\n [width]=\"gridService.detailColumnWidth\"\n (expandedChange)=\"toggleDetail()\" />\n </span>\n </td>\n } @else if (layoutColumn.kind === \"selection\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$selection'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (activate)=\"onActivate($event)\">\n <mona-grid-selection-checkbox [row]=\"row()\" [rowIndex]=\"index()\" />\n </td>\n }\n}\n"
2118
2146
  }]
2119
2147
  }],
2120
2148
  propDecorators: {
@@ -2146,4 +2174,4 @@ i0.ɵɵngDeclareClassMetadata({
2146
2174
  });
2147
2175
  export { GridCellDirective as i, GridGroupRowComponent as n, GridAddRowComponent as r, GridRowComponent as t };
2148
2176
 
2149
- //# sourceMappingURL=grid-row.component-BauMmps5.mjs.map
2177
+ //# sourceMappingURL=grid-row.component-CuCQ_Z5F.mjs.map