Skip to main content
cngx-src documentation

createTabDismissals

Functioncommon/tabsv0.1.0

projects/common/tabs/dismissals/tab-dismissals.ts

Description#

Helper resolving the dismissable/addable affordances for <cngx-tab-group>.
Keeps the close/add cascade + interaction off the organism class (LOC guard).
Each cascade is one computed(). The actual tab removal is the consumer's - handleClose only routes through the presenter's requestClose, which moves the active index, and restores focus once the consumer's removal has rendered.

// The organism builds it once from field-init; the template reads it.
protected readonly dismiss = createTabDismissals({
  host: this.host,            // CNGX_TAB_GROUP_HOST
  config: this.config,        // injectTabsConfig()
  i18n: this.i18n,            // injectTabsI18n()
  closable: this.closable,    // input<boolean | undefined>('closable')
  addable: this.addable,      // input<boolean | undefined>('addable')
  hostElement: this.hostElement,
  injector: this.injector,
});

// Per-tab close affordance, read from the header template:
dismiss.isTabClosable(tab);              // per-tab override > group resolution
dismiss.closeButtonLabel(tab);           // i18n accessible name for the close button
dismiss.handleClose(tab, clickEvent);    // routes through presenter.requestClose, restores focus
dismiss.handleTabKeydown(tab, keyEvent); // Delete on a focused closable tab closes it (APG)

// Group-level add affordance:
dismiss.resolvedAddable();               // input ?? config ?? false
dismiss.handleAdd();                     // routes through presenter.requestAdd

Signature#

createTabDismissals(opts: CngxTabDismissalsOptions)

Parameters#

Returns#

CngxTabDismissals