Document Select

This component can be found under the Sybrin.Identity namespace and is called DocumentSelectComponent.

Full name: Sybrin.Identity.DocumentSelectComponent.

It is a component that provides basic document selection functionality in the form of a simple UI. The Web SDK requires a document type for data extraction and it's recommended that you use this component to obtain said document type.

With default styling, the document select component appears as follows:

Upon selecting a document, the onDocumentSelected event will fire, passing the selected document type as a string parameter.

Initialization

The document select component can be initialized using the following code:

<div id='document-select'></div>

The Sybrin Web SDK provides the option to either pass down the ID of the element you wish to use for component initialization, or to pass the element directly.

Please note that 'document-select' is just an example in this context and the ID may be changed as desired as long as it matches the value passed down during component initialization in JavaScript.

During initialization, the document select component allows for a number of configuration options that may be passed down using an object literal. The parameters that may be used on the object include the following:

Required:

  • id (string): ID of the element you wish to use for component initialization. Not required if element is passed.

  • element (HTMLElement): Element you wish to use for component initialization. Not required if id is passed.

Optional:

  • countryCode (string): The Alpha-3 standard country code to filter document selection by. If a country code is passed down, only documents supported by the specified country will be shown. Please see country overrides & filtering for a list of accepted values.

  • documentTypes (Sybrin.Identity.DocumentType[]): Explicit document type filter. Please see document type overrides & filtering for details.

For altering component text or implementing localization if required:

  • headingText (string): Text to display in the heading. Default "Country select"

  • subtitleText (string): Text to display in the subtitle. Default "Select your country"

  • companyText (string): Company text to display at the foot of the component. Default "Sybrin"

Document Type Overrides & Filtering

When creating an instance of the document select component, the SDK allows for an Alpha-3 standard countryCodeparameter, which will be used to filter document types based on the country. Additionally, the SDK allows for a documentTypes parameter which can be used for more specific override options. The parameter is a collection of objects where each instance has the properties name, title, subtitle and enabled.

  • id (string): The unique identifier (document type ID) used to target a document type to override.

  • title (string): Can be used to override the display title of the targeted document type.

  • subtitle (string): Can be used to override the display subtitle of the targeted document type

  • enabled (boolean): Can be used to filter out the targeted document type (if set to false)

  • frontThreshold (number): The confidence threshold value to use when running document detection on the front image. A lower value modifies detection to be more sensitive. A higher level makes it less sensitive, up to a maximum of 100.

  • backThreshold (number): The confidence threshold value to use when running document detection on the back image if applicable. A lower value modifies detection to be more sensitive. A higher level makes it less sensitive, up to a maximum of 100.

Supported document type IDs are:

  • Ghana

    • Passport: 'ghapassport' (Document type name = 'passport')

  • Kenya

    • Passport: 'kenpassport' (Document type name = 'passport')

    • ID Card: 'kenidcard' (Document type name = 'idcard')

  • Malawi

    • Passport: 'mwipassport' (Document type name = 'passport')

  • Mozambique

    • Passport: 'mozpassport' (Document type name = 'passport')

    • ID Card: 'mozidcard' (Document type name = 'idcard')

  • South Africa

    • Passport: 'zafpassport' (Document type name = 'passport')

    • ID Card: 'zafidcard' (Document type name = 'idcard')

    • Green Book: 'zafgreenbook' (Document type name = 'greenbook')

  • Uganda

    • Passport: 'ugapassport' (Document type name = 'passport')

    • ID Card: 'ugaidcard' (Document type name = 'idcard')

  • Zimbabwe

    • Passport: 'zwepassport' (Document type name = 'passport')

  • Philippines

    • Passport: 'phlpassport' (Document type name = 'passport')

    • ID Card: 'phlidcard' (Document type name = 'idcard')

    • Divers License: 'phldriverslicense' (Document type name = 'driverslicense')

    • Seaman's Book: 'phlseamansbook' (Document type name = 'seamansbook')

    • Seaman's ID: 'phlsid' (Document type name = 'sid')

    • Postal ID: 'phlpostalid' (Document type name = 'postalid')

    • Social Security: 'phlsocialsecurity' (Document type name = 'socialsecurity')

    • Unified Multi Purpose: 'phlunifiedmultipurpose' (Document type name = 'unifiedmultipurpose')

    • Firearms License: 'phlfirearmslicense' (Document type name = 'firearmslicense')

    • Old PRC ID (Before September 2019): 'phlprofessionalregulationsblue' (Document type name = 'professionalregulations')

    • PRC ID (After September 2019): 'phlprofessionalregulations' (Document type name = 'professionalregulations')

    • Integrated Bar: 'phlintegratedbar' (Document type name = 'integratedbar')

    • Insurance Card: 'phlinsurancecard' (Document type name = 'insurancecard')

    • Health Insurance Card: 'phlhealthinsurancecard' (Document type name = 'healthinsurancecard')

The generic document type IDs that would apply globally correspond to the document type names. They are:

  • Passport: 'passport'

  • ID Card: 'idcard'

  • Green Book: 'greenbook'

  • Driver's License: 'driverslicense'

  • Seaman's Book: 'seamansbook'

  • Seaman's ID: 'sid'

  • Postal ID: 'postalid'

  • Social Security: 'socialsecurity'

  • Unified Multi Purpose ID: 'unifiedmultipurpose'

  • Firearms License: 'firearmslicense'

  • Professional Regulations Commission ID: 'professionalregulations'

  • Integrated Bar of the Philippines ID: 'integratedbar'

  • Insurance Card: 'insurancecard'

  • Health Insurance Card: 'healthinsurancecard'

Advanced filtering and override example:

var component = new Sybrin.Identity.DocumentSelectComponent({
    id: 'viewport',
    countryCode: 'ZAF',
    documentTypes: [
        new Sybrin.Identity.DocumentType({
            id: 'zafidcard',
            title: 'ID Card',
            subtitle: 'Your identity card'
        }),
        new Sybrin.Identity.DocumentType({ id: 'zafgreenbook', enabled: false })
    ]
});

By specifying countryCode as 'ZAF', it will only show document types that are supported by South Africa. The document type instance in the documentTypes collection overrides 'zafidcard' (South African ID Card) to display the title as 'ID Card' and subtitle as 'Your identity card' instead. The second instance filters 'zafgreenbook' (South African Green Book) out so that it doesn't appear as part of the list even though it is a supported South African document.

Destruction

The document select component may be removed from the UI by calling the destroy() function on it.

Example:

component.destroy();

Events

The document select component offers one event for reacting to document selection. To hook onto the event, simply assign a function to it.

The following option is available:

  • onDocumentSelected(documentTypeName: string, documentTypeId: string)

On Document Selected

This function is called when a document is selected and provides the selected document's type name and, if applicable, document type ID as arguments. The ID will only be passed as an argument if the country code is known to the component at the time of selection. To hook onto the event, you may use the following code:

component.onDocumentSelected = function(documentTypeName, documentTypeId) {
    console.log('The selected document type name and ID are: ', documentTypeName, documentTypeId);
}

The documentTypeName parameter is of type string.

The documentTypeId parameter is of type string.

Styling

The document select component is structured a follows:

<div class="sybrin-identity-document-select">
    <h2 class="sybrin-identity-document-select-heading"></h2>
    <p class="sybrin-identity-document-select-subtitle"></p>
    <div class="sybrin-identity-document-select-documents">
        <div class="sybrin-identity-document-select-card-passport sybrin-identity-card">
            <div class="sybrin-identity-card-image">
                <svg></svg>
            </div>
            <div class="sybrin-identity-card-text">
                <p class="sybrin-identity-card-title"></p>
                <p class="sybrin-identity-card-subtitle"></p>
            </div>
        </div>
    </div>
    <p class="sybrin-identity-document-select-company"></p>
</div>

The classes and elements specified above may be used to freely style the country select component as desired. To do so, simply create a stylesheet and include it in the project, then style according to the above classes and elements.

The element with the sybrin-identity-card class repeats for every document option and has a specific class to identify it by:sybrin-identity-document-select-card-dtn where dtn is the document type name of the document option.

Styling implementation example:

index.html
<html>
<head>
    <link rel="stylesheet" type="text/css" href="styles.css" media="screen"/>
</head>
<body>
    <div id='component'></div>
</body>
</html>

Before styling

After styling

Last updated