CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-ng-zorro-antd

An enterprise-class Angular UI component library based on Ant Design with 70+ high-quality components for building modern Angular applications

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

core.mddocs/

Core Services & Configuration

Core services for global configuration, internationalization, theming, and application-wide functionality.

Capabilities

Configuration Service

Global configuration service for managing component default settings and theme configuration.

/**
 * Global configuration service
 */
interface NzConfigService {
  /** Get all configuration */
  getConfig(): NzConfig;
  /** Get configuration for specific component */
  getConfigForComponent<T extends NzConfigKey>(componentName: T): NzConfig[T];
  /** Set configuration for specific component */
  set<T extends NzConfigKey>(componentName: T, value: NzConfig[T]): void;
}

/**
 * Configuration decorator for components
 */
function WithConfig<T>(): PropertyDecorator;

// Types
type NzConfigKey = 
  | 'affix'
  | 'alert'
  | 'anchor'
  | 'avatar'
  | 'backTop'
  | 'badge'
  | 'button'
  | 'card'
  | 'carousel'
  | 'cascader'
  | 'codeEditor'
  | 'collapse'
  | 'descriptions'
  | 'drawer'
  | 'empty'
  | 'form'
  | 'icon'
  | 'message'
  | 'modal'
  | 'notification'
  | 'pageHeader'
  | 'pagination'
  | 'progress'
  | 'rate'
  | 'space'
  | 'spin'
  | 'switch'
  | 'table'
  | 'tabs'
  | 'timePicker'
  | 'tree'
  | 'treeSelect'
  | 'typography';

interface NzConfig {
  affix?: NzAffixConfig;
  button?: NzButtonConfig;
  message?: NzMessageConfig;
  notification?: NzNotificationConfig;
  // ... other component configs
}

// Configuration interfaces for major components
interface NzButtonConfig {
  nzSize?: 'large' | 'default' | 'small';
}

interface NzMessageConfig {
  nzDuration?: number;
  nzMaxStack?: number;
  nzAnimate?: boolean;
  nzTop?: number | string;
}

interface NzNotificationConfig {
  nzTop?: string | number;
  nzBottom?: string | number;
  nzPlacement?: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
}

// Module
class NzConfigModule {
  static forRoot(): ModuleWithProviders<NzConfigModule>;
}

Usage Examples:

import { NzConfigService } from 'ng-zorro-antd/core/config';

@Component({
  template: `
    <!-- Button will use global size configuration -->
    <button nz-button nzType="primary">Global Configured Button</button>
  `
})
export class ConfigExampleComponent {
  constructor(private nzConfigService: NzConfigService) {
    // Set global button configuration
    this.nzConfigService.set('button', { nzSize: 'large' });
  }
}

Internationalization Service

Comprehensive internationalization service with 70+ language support.

/**
 * Internationalization service
 */
interface NzI18nService {
  /** Set locale */
  setLocale(locale: NzI18nInterface): void;
  /** Get current locale */
  getLocale(): NzI18nInterface;
  /** Get current locale ID */
  getLocaleId(): string;
  /** Set date locale */
  setDateLocale(dateLocale: any): void;
  /** Get date locale */
  getDateLocale(): any;
  /** Get localized text */
  translate(path: string, data?: any): string;
  /** Get locale data by path */
  getLocaleData(path: string, defaultValue?: any): any;
  /** Locale change observable */
  readonly localeChange: Observable<NzI18nInterface>;
}

/**
 * Internationalization pipe
 * Usage: {{ 'path.to.text' | nzI18n }}
 */
interface NzI18nPipe {
  transform(path: string, keyValue?: object): string;
}

/**
 * Date helper service for localized date operations
 */
interface NzDateHelperService {
  /** Get first day of week */
  getFirstDayOfWeek(): WeekDayIndex;
  /** Get locale data */
  getDateLocale(): any;
  /** Format date */
  format(date: Date, formatStr: string): string;
  /** Parse date */
  parseDate(text: string, formatStr?: string): Date;
  /** Parse time */
  parseTime(text: string, formatStr?: string): Date | undefined;
}

// Types
interface NzI18nInterface {
  locale: string;
  Pagination?: any;
  DatePicker?: any;
  TimePicker?: any;
  Calendar?: any;
  Table?: any;
  Modal?: any;
  Popconfirm?: any;
  Transfer?: any;
  Upload?: any;
  Empty?: any;
  global?: any;
  PageHeader?: any;
  // ... other component translations
}

type WeekDayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;

// Tokens
const NZ_I18N: InjectionToken<NzI18nInterface>;
const NZ_DATE_CONFIG: InjectionToken<NzDateConfig>;

interface NzDateConfig {
  /** First day of week */
  firstDayOfWeek?: WeekDayIndex;
}

// Language packs (partial list)
const ar_EG: NzI18nInterface;  // Arabic (Egypt)
const en_US: NzI18nInterface;  // English (US)
const en_GB: NzI18nInterface;  // English (UK)
const zh_CN: NzI18nInterface;  // Chinese (Simplified)
const zh_TW: NzI18nInterface;  // Chinese (Traditional)
const fr_FR: NzI18nInterface;  // French
const de_DE: NzI18nInterface;  // German
const ja_JP: NzI18nInterface;  // Japanese
const ko_KR: NzI18nInterface;  // Korean
const es_ES: NzI18nInterface;  // Spanish
const pt_BR: NzI18nInterface;  // Portuguese (Brazil)
const ru_RU: NzI18nInterface;  // Russian
const it_IT: NzI18nInterface;  // Italian
// ... 70+ total language packs

// Module
class NzI18nModule {
  static forRoot(): ModuleWithProviders<NzI18nModule>;
}

Usage Examples:

import { NzI18nService, en_US, zh_CN } from 'ng-zorro-antd/i18n';

@Component({
  template: `
    <nz-date-picker></nz-date-picker>
    <nz-pagination [nzTotal]="100"></nz-pagination>
    
    <!-- Custom translations -->
    <p>{{ 'common.confirm' | nzI18n }}</p>
    
    <button (click)="switchLanguage()">Switch Language</button>
  `
})
export class I18nExampleComponent {
  constructor(private i18n: NzI18nService) {}

  switchLanguage(): void {
    const currentLocale = this.i18n.getLocaleId();
    const newLocale = currentLocale === 'en' ? zh_CN : en_US;
    this.i18n.setLocale(newLocale);
  }
}

// App module configuration
@NgModule({
  imports: [
    NzI18nModule.forRoot()
  ],
  providers: [
    { provide: NZ_I18N, useValue: en_US }
  ]
})
export class AppModule {}

Icon Service

Icon service for managing and registering custom icons.

/**
 * Icon service for icon management
 */
interface NzIconService {
  /** Add icon */
  addIcon(...icons: IconDefinition[]): void;
  /** Add icon literal */
  addIconLiteral(type: string, literal: string): void;
  /** Clear icons */
  clear(): void;
  /** Get icon */
  getRenderedContent(icon: IconDefinition | string, twoToneColor?: string): Observable<SVGElement>;
  /** Create icon from font */
  createIconfontIcon(scriptUrl: string): void;
  /** Set two tone color */
  twoToneColor: { primaryColor: string; secondaryColor?: string };
}

/**
 * Icon directive
 * Selector: [nz-icon]
 */
interface NzIconDirective {
  /** Icon type */
  nzType: string;
  /** Icon theme */
  nzTheme: 'outline' | 'twotone' | 'fill';
  /** Icon spin */
  nzSpin: boolean;
  /** Two tone color */
  nzTwoToneColor: string;
  /** Icon font */
  nzIconfont: string;
  /** Icon rotate */
  nzRotate: number;
}

// Types from @ant-design/icons-angular
interface IconDefinition {
  name: string;
  theme: 'outline' | 'twotone' | 'fill';
  icon: string | ((primaryColor: string, secondaryColor: string) => string);
}

// Module
class NzIconModule {
  static forRoot(icons: IconDefinition[]): ModuleWithProviders<NzIconModule>;
}

Breakpoint Service

Service for responsive design breakpoint management.

/**
 * Breakpoint service for responsive design
 */
interface NzBreakpointService {
  /** Subscribe to breakpoint changes */
  subscribe(breakpointMap: NzBreakpointMap): Observable<NzBreakpointState>;
  /** Subscribe to specific breakpoint */
  subscribe(bp: NzBreakpointKey): Observable<boolean>;
}

// Types
type NzBreakpointKey = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';

interface NzBreakpointMap {
  xs?: string;
  sm?: string;
  md?: string;
  lg?: string;
  xl?: string;
  xxl?: string;
}

interface NzBreakpointState {
  xs: boolean;
  sm: boolean;
  md: boolean;
  lg: boolean;
  xl: boolean;
  xxl: boolean;
}

Animation Utilities

Animation utilities and directives for component transitions.

/**
 * No animation directive
 * Selector: [nzNoAnimation]
 */
interface NzNoAnimationDirective {
  /** Disable animation */
  nzNoAnimation: boolean;
}

// Animation functions
function slideMotion(): AnimationTriggerMetadata;
function fadeMotion(): AnimationTriggerMetadata;
function collapseMotion(): AnimationTriggerMetadata;
function zoomMotion(): AnimationTriggerMetadata;
function moveUpMotion(): AnimationTriggerMetadata;

// Module
class NzNoAnimationModule {
  static forRoot(): ModuleWithProviders<NzNoAnimationModule>;
}

Wave Effect

Wave effect directive for click feedback.

/**
 * Wave directive for click effect
 * Selector: [nz-wave]
 */
interface NzWaveDirective {
  /** Wave config */
  nzWaveExtraNode: boolean;
}

// Module
class NzWaveModule {
  static forRoot(): ModuleWithProviders<NzWaveModule>;
}

Utility Services

Core utility services for common functionality.

/**
 * Scroll service for scroll utilities
 */
interface NzScrollService {
  /** Get scroll position */
  getScroll(target?: Element | Window, top?: boolean): number;
  /** Scroll to position */
  scrollTo(containerEl: Element | Window, targetTopValue?: number, easing?: string, callback?: () => void): void;
}

/**
 * Dom event service for DOM utilities
 */
interface NzDomEventService {
  /** Register resize listener */
  registerResizeListener(callback: () => void): () => void;
}

/**
 * Drag service for drag & drop
 */
interface NzDragService {
  /** Request dragging sequence */
  requestDraggingSequence(event: MouseEvent | TouchEvent): Observable<{ x: number; y: number; deltaX: number; deltaY: number }>;
}

/**
 * Singleton service for creating singletons
 */
interface NzSingletonService {
  /** Get singleton instance */
  getSingleton<T>(key: string, factory?: () => T): T;
  /** Register singleton */
  registerSingleton<T>(key: string, factory: () => T): void;
}

/**
 * Resize observer service
 */
interface NzResizeObserverService {
  /** Observe element resize */
  observe(element: Element): Observable<ResizeObserverEntry[]>;
}

Form Utilities

Form-related utilities and services.

/**
 * Form status service
 */
interface NzFormStatusService {
  /** Form control status update */
  formStatusChanges: Subject<{ status: NzValidateStatus; hasFeedback: boolean }>;
}

/**
 * Form item feedback icon component
 */
interface NzFormItemFeedbackIconComponent {
  /** Status */
  status: NzValidateStatus;
}

// Types
type NzValidateStatus = 'success' | 'warning' | 'error' | 'validating' | '';

Logger Service

Development and debugging logger service.

/**
 * Logger service for debugging
 */
interface NzLoggerService {
  /** Log debug message */
  debug(...args: any[]): void;
  /** Log info message */
  info(...args: any[]): void;
  /** Log warning message */
  warn(...args: any[]): void;
  /** Log error message */
  error(...args: any[]): void;
}

// Logger module
class NzLoggerModule {
  static forRoot(): ModuleWithProviders<NzLoggerModule>;
}

Highlight Service

Text highlighting utilities.

/**
 * Highlight service for text highlighting
 */
interface NzHighlightService {
  /** Highlight text matches */
  highlight(inputStr: string, searchValue: string, startTag?: string, endTag?: string): string;
}

// Highlight pipe
interface NzHighlightPipe {
  transform(text: string, search: string, startTag?: string, endTag?: string): string;
}

// Module
class NzHighlightModule {
  static forRoot(): ModuleWithProviders<NzHighlightModule>;
}

Global Configuration

Application-wide configuration and setup.

/**
 * Global NG-ZORRO configuration
 */
interface NzGlobalConfig {
  /** Animation configuration */
  animation?: {
    disabled?: boolean;
  };
  /** Message configuration */
  message?: NzMessageConfig;
  /** Notification configuration */
  notification?: NzNotificationConfig;
  /** Modal configuration */
  modal?: {
    autoFocusButtonOk?: boolean;
  };
}

// Setup function for global configuration
function provideNzConfig(config: NzGlobalConfig): Provider[];

// Usage in app.config.ts or module
const appConfig: ApplicationConfig = {
  providers: [
    provideNzConfig({
      message: { nzTop: 120 },
      notification: { nzTop: 240 }
    })
  ]
};

Usage Examples:

// Standalone component with global config
import { Component } from '@angular/core';
import { provideNzConfig } from 'ng-zorro-antd/core/config';

bootstrapApplication(AppComponent, {
  providers: [
    provideNzConfig({
      message: { nzDuration: 3000 },
      notification: { nzPlacement: 'topRight' }
    })
  ]
});

// Module-based setup
@NgModule({
  imports: [
    NzConfigModule.forRoot(),
    NzI18nModule.forRoot()
  ],
  providers: [
    { provide: NZ_I18N, useValue: en_US },
    provideNzConfig({
      animation: { disabled: false },
      message: { nzTop: 100 }
    })
  ]
})
export class AppModule {}

docs

core.md

data-display.md

data-entry.md

feedback.md

index.md

layout.md

navigation.md

tile.json