Electronic records (21 CFR Part 11)

E-Signature <smart-esignature>

ESignature provides the electronic signature dialog described in 21 CFR Part 11.

Angular ESignature - Setup

The Smart.Industrial Angular modules are compiled for Angular 13 and later. An NgModule application needs Angular 13 or later. A standalone component that imports ESignatureModule needs Angular 14 or later.

Each component has its own Angular module. ESignatureModule declares and exports ESignatureComponent, which is not a standalone component. A standalone component lists the module in its imports, and an NgModule application lists it in the imports of its module. Steps 1 to 5 build a standalone application. Step 6 covers an NgModule application.

The complete demo in Angular is on the demo page, file by file.

1 NPM Install

The Angular modules are in the smart-industrial package:

npm install smart-industrial

2 Register styles

The stylesheets go into the styles of the build options in angular.json, next to the existing entries:

"styles": [
	"node_modules/smart-industrial/source/styles/smart.default.css",
	"node_modules/smart-industrial/source/styles/smart.industrial-elements.css",
	"node_modules/smart-industrial/source/styles/smart.industrial.css"
]

smart.default.css is the base theme and smart.industrial-elements.css styles the Industrial components. smart.industrial.css is the Industrial theme, which applies to components with theme="industrial". For theme="industrial-dark", the package also has smart.industrial-dark.css.

3 Import the Angular module

The application imports ESignatureModule from the component's entry point. ESignatureComponent reaches a template through this module. A standalone component that lists ESignatureComponent itself in its imports does not compile (NG2011).

import { ESignatureModule } from 'smart-industrial/angular/esignature';

Each component has an entry point of its own, and an application imports from those. The entry point with all the components, smart-industrial/angular, puts every component into the bundle. In a production build of the Faceplate sample, the main bundle is 274 kB with FaceplateModule and 8.9 MB with SmartIndustrialModule.

4 Root component (standalone)

The sample has three files: the component, its template in step 5, and src/main.ts. They replace the files of the same name that the CLI generated.

src/app/app.ts

import { Component } from '@angular/core';
import { ESignatureModule } from 'smart-industrial/angular/esignature';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [ESignatureModule],
  templateUrl: './app.html'
})
export class App {
  // Raised when the signer submits.
  onSignRequest(event: CustomEvent): void {
    const { userId, password, meaning } = event.detail;
    // The component waits. The application carries out the request here.
    console.log('signRequest', userId, password, meaning);
  }
}

src/main.ts

import { bootstrapApplication } from '@angular/platform-browser';
import { App } from './app/app';

bootstrapApplication(App).catch((err) => console.error(err));

A project from Angular CLI 20 or later already has these files. Its src/main.ts also passes an appConfig, which can stay. An older project names its root component AppComponent, in app.component.ts, and the sample does not use it.

5 Template (standalone)

src/app/app.html holds the markup. Strings are plain attributes. Numbers and booleans are property bindings, such as [requireReason]="true", so that they reach the component with their type and strictTemplates checks them. Each event of the component is an output named after it, such as (onSignRequest), and $event is the CustomEvent.

<smart-esignature
  theme="industrial"
  [requireReason]="true"
  [autoClose]="0"
  (onSignRequest)="onSignRequest($event)"
></smart-esignature>

6 NgModule application

An NgModule application uses the same package and styles. Its module lists ESignatureModule in imports and declares the component that uses the template from step 5. src/main.ts starts the module with bootstrapModule. This works on Angular 13 and later. From Angular 19, a component declared in a module needs standalone: false.

Run

ng serve or npm start starts the development server at http://localhost:4200/.

Production build

A project created with ng new has an error budget of 1 MB for the initial bundle. The stylesheets alone come to 1.69 MB in a production build, because smart.default.css carries the base styles of the suite components that the Industrial components are built on. The initial bundle of the Faceplate sample is 2.00 MB, and ng build stops with a budget error. A higher initial budget in the production configuration of angular.json lets it pass:

"budgets": [
  { "type": "initial", "maximumWarning": "3MB", "maximumError": "4MB" },
  { "type": "anyComponentStyle", "maximumWarning": "4kB", "maximumError": "8kB" }
]

Each further component adds its module to the main bundle, so the budget grows with the number of components on the screen.

Smart UI for Angular - full documentation

Accessibility

The keyboard interaction, roles and announcements of the component are on its accessibility page; they are the same in Angular.