Utilities
Table of Contents
- Installation
- CVA provider factory & Reactive form base
- TsUILibraryError
- Merge
- Strip control characters
- Types
Installation
Use the ng add
command to quickly install all the needed dependencies:
ng add @terminus/ui-utilities
CVA provider factory & Reactive form base
Used together, these help implement custom form controls by implementing a custom ControlValueAccessor.
import {
ControlValueAccessorProviderFactory,
TsReactiveFormBaseComponent,
} from '@terminus/ui-utilities';
@Component({
selector: 'my-component',
providers: [ControlValueAccessorProviderFactory<MyComponent>(MyComponent)],
})
export class MyComponent extends TsReactiveFormBaseComponent {}
TsUILibraryError
A custom error for the UI library.
import { TsUILibraryError } from '@terminus/ui-utilities';
throw new TsUILibraryError('MyComponent: Something went wrong!');
Merge
Simple utility to merge 2 objects.
import { merge } from '@terminus/ui-utilities';
const mergedObj = merge(obj1, obj2);
Strip control characters
Utility to strip control characters (eg backspace or carriage return) from a string.
import { stripControlCharacters } from '@terminus/ui-utilities';
const cleanValue = stripControlCharacters(originalValue);
Types
Shared types.
Type | Description |
---|---|
TsStyleThemeTypes |
The supported themes for UI components. |