0.0.9 • Published 2 years ago

sm-ui-library v0.0.9

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

SM-UI-LIBRARY

This documentation allows to easily install and use sm-ui-library components.

Installing

npm install sm-ui-library

To use all the library components

import {SmUiLibraryModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmUiLibraryModule
    ...
  ]
})
export class AppModule {
}

To use single component at a time import them separately

Autocomplete

import {SmAutocompleteModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmAutocompleteModule
    ...
  ]
})

Button

import {SmButtonModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmButtonModule
    ...
  ]
});

<sm-button
    [fieldMeta]="buttonField">
</sm-button>

this.buttonField = new ButtonField({
      fieldName: 'buttonField',
      btnText: 'Button',
      class: 'btn btn-primary pull-left m-l-sm',
      type: 'Button',
      disable: false
});
html attributes
AttributesData-TypeDefaultsRequiredUses
formGroupFormGroup''yesreference to existing formGroup
fieldMetaTextField-yesMetadata of text field
fieldMeta attributes
AttributesData-typeDefaultsRequiredUses
btnTextstring''notext of the button
fieldNamestring''yesit used as a key in formGroup
disablebooleanfalsenothis allows to enable disable the button
classstring'btn-default'noto apply class on the button
iconCssClassstring''noto apply class on icon of button
showCompletedbooleanfalsenothis shows complete tick mark on button
showLoadingbooleanfalsenothis shows loading mask on button
events
EventsUses
btnClickedcalled on blur of field

Checkboxes

import {SmCheckboxModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmCheckboxModule
    ...
  ]
});

<sm-checkbox
    [formGroup]="formGroup"
    [fieldMeta]="checkboxField">
</sm-checkbox>

this.checkboxField = new CheckboxField({
      fieldName: 'email_isTracking',
      displayName: 'Checkboxes',
      options: [{label: 'one', value: 'one'}, {label: 'two', value: 'two'}]
});
html attributes
AttributesData-TypeDefaultsRequiredUses
formGroupFormGroup''yesreference to existing formGroup
fieldMetaTextField-yesMetadata of text field
valuestring''nodefault value for text field,
showLabelbooleantruenoto show or hide the label,
fieldMeta attributes
AttributesData-typeDefaultsRequiredUses
readOnlybooleanfalsenoto disable and enable field
classstring''noclass for the field
optionsArray[]nooptions to show in checkboxes
newLinebooleanfalsenoto show the checkboxes in new line
events
EventsUses
blurcalled on blur of field

Date range Picker

import {SmDaterangePickerModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmDaterangePickerModule
    ...
  ]
})

<sm-daterange-picker 
    [formGroup]="formGroup"
    [fieldMeta]="dateRangePickerField">
</sm-daterange-picker>

this.rangeOptions = {
        'Today': [moment(), moment()],
        'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
        'This Week': [moment().startOf('week'), moment().endOf('week')],
        'Last Week': [moment().subtract(1, 'week').startOf('week'), moment().subtract(1, 'week').endOf('week')],
        'This Month': [moment().startOf('month'), moment().endOf('month')],
        'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
        'This Quarter': [moment().startOf('quarter'), moment().endOf('quarter')],
        'Last Quarter': [moment().subtract(1, 'quarter').startOf('quarter'), moment().subtract(1, 'quarter').endOf('quarter')],
        'This Year': [moment().startOf('year'), moment().endOf('year')],
        'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')]
}

this.dateRangePickerField = new DateRangePickerField({
      minDate: moment().startOf('d'),
      dateFormat: 'DD-MM-YYYY',
      fieldName: 'dateRange',
      opens: 'right',
      locale: {
        format: 'DD-MM-YYYY'
      },
      startDate: moment().startOf('d'),
      endDate: moment().add(30, 'days').startOf('d'),
      ranges: rangeOptions
});
html attributes
AttributesData-TypeDefaultsRequiredUses
formGroupFormGroup''yesreference to existing formGroup
fieldMetaTextField-yesMetadata of text field
valuestring''nodefault value for text field,
showLabelbooleantruenoto show or hide the label (displayName must be there in fieldMeta)
fieldMeta attributes
AttributesData-typeDefaultsRequiredUses
dateFormatstring'DD-MM-YYYY hh:mm:ss'nodate format of the field
readOnlybooleanfalsenoto disable and enable field
classstring''noclass for the field
singleDatePickerbooleanfalsenoto show single date picker popup
timePickerbooleanfalsenoto show only time picker
startDatestring''nodefault start date
endDatestring''nodefault end date
minDatestring''nominimum date of the field
maxDatestring''nomaximum date of the field
rangesany{}yesrange options to show
opensstring'left'noto open popup position
timePicker24Hourbooleanfalsenoto show time in 24 hour format
applyButtonClassesstring''noclasses for apply button
events
EventsUses
blurcalled on blur of field
functions available in DateRangePickerField
FunctionDescription
DateRangePickerField.getDateRangeValue(rangeType)It return value of given range type (rangeType can be among these 'LAST_7_DAYS', 'LAST_30_DAYS', 'TODAY', 'YESTERDAY', 'THIS_WEEK', 'LAST_WEEK', 'NEXT_WEEK', 'THIS_MONTH', 'LAST_MONTH', 'NEXT_MONTH', 'THIS_QUARTER', 'LAST_QUARTER', 'NEXT_QUARTER', 'THIS_YEAR', 'LAST_YEAR', 'NEXT_YEAR', 'MORE_THAN_X_DAYS_AGO', 'LESS_THAN_X_DAYS_AGO', 'MORE_THAN_X_UPCOMING_DAYS', 'LESS_THAN_X_UPCOMING_DAYS')
DateRangePickerField.getPreviousDateRangeValue(rangeType)It return previous value of given range type (rangeType can be among these 'LAST_7_DAYS', 'LAST_30_DAYS', 'TODAY', 'YESTERDAY', 'THIS_WEEK', 'LAST_WEEK', 'NEXT_WEEK', 'THIS_MONTH', 'LAST_MONTH', 'NEXT_MONTH', 'THIS_QUARTER', 'LAST_QUARTER', 'NEXT_QUARTER', 'THIS_YEAR', 'LAST_YEAR', 'NEXT_YEAR', 'MORE_THAN_X_DAYS_AGO', 'LESS_THAN_X_DAYS_AGO', 'MORE_THAN_X_UPCOMING_DAYS', 'LESS_THAN_X_UPCOMING_DAYS')

Date time Picker

import {SmDatetimePickerModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmDatetimePickerModule
    ...
  ]
});

<sm-datetime-picker [formGroup]="formGroup"
                    [fieldMeta]="dateTimeField">
</sm-datetime-picker>

this.dateTimeField = new DateTimePickerField({
              dateFormat: 'DD-MM-YYYY',
              fieldName: 'startDate',
              displayName: 'Date time field',
              sideBySide: false
        });
html attributes
AttributesData-TypeDefaultsRequiredUses
formGroupFormGroup''yesreference to existing formGroup
fieldMetaTextField-yesMetadata of text field
valuestring''nodefault value for text field,
showLabelbooleantruenoto show or hide the label
fieldMeta attributes
AttributesData-typeDefaultsRequiredUses
classstring''falseclass to be applied on field
readOnlybooleanfalsenoto enable disable the fields
dateFormatstring'DD-MM-YYYY hh:mm:ss'nodefault date format
toolbarPlacementstring'top'noposition of the toolbar
minDatestring''nominimum date for field
maxDatestring''nomaximum date for field
inlinebooleanfalsenothis shows the datetime picker inline (not as popup)
events
EventsUses
blurcalled on blur of field
functions available in DateTimePickerField
FunctionDescription
DateTimePickerField.isIsoDate(dateString:any)It returns whether the date is in ISO format or not

Duration

import {SmDurationModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmDurationModule
    ...
  ]
})

Input Field

import {SmInputTxtModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmInputTxtModule
    ...
  ]
});

<sm-input-txt 
              [formGroup]="formGroup"
              [fieldMeta]="textField">
</sm-input-txt>

this.textField = new TextField({
  fieldName: 'textField',
  displayName: 'Input box'
});
html attributes
AttributesData-TypeDefaultsRequiredUses
formGroupFormGroup''yesreference to existing formGroup
fieldMetaTextField-yesMetadata of text field
valuestring''nodefault value for text field
showLabelbooleantruenoto show or hide the label
fieldMeta attributes
AttributesData-typeDefaultsRequiredUses
classstring''noclass to be applied on component
showLinkbooleanfalsenoto show as link above text field (should be used with type='url' or with fieldName=linkedInHandle/facebookHandle/twitterHandle/googlePlusHandle/instagramHandle)
typestring-notype of the field
inputTypestring'text'notype of input field
titlestring''notitle of the field
customLinkedInUrlstring'https://linkedin.com/in/'noto show linked in link (used with fieldName = linkedInHandle)
events
EventsUses
blurcalled on blur of field
focuscalled on focus of the field
keyupcalled on keyup of the field
functions available in TextField
FunctionDescription
getLink(value: any)It is used to return link value

Radio Field

import {SmRadioModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmRadioModule
    ...
  ]
});

<sm-radio
  [fieldMeta]="radioField"
  [formGroup]="formGroup">
</sm-radio>

this.radioField = new RadioField({
      fieldName: 'radio',
      options: [
                  {label: 'DAYS', value: 'DAYS'},
                  {label: 'RANGE', value: 'RANGE'},
                  {label: 'NONE', value: 'NONE'}
                ]
});
html attributes
AttributesData-TypeDefaultsRequiredUses
formGroupFormGroup''yesreference to existing formGroup
fieldMetaTextField-yesMetadata of text field
valuestring''nodefault value for text field,
showLabelbooleantruenoto show or hide the label
fieldMeta attributes
AttributesData-typeDefaultsRequiredUses
fieldNamestring''trueto set the value of field in formGroup
displayNamestring''falseto show label and title of the field
optionsArray[]nooptions to show in radios
optionClassstring''noif you want to apply class in options
readOnlybooleanfalsenoto enable disable the fields
events
EventsUses
blurcalled on blur of field

Select Box

import {SmSelectBoxModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmSelectBoxModule
    ...
  ]
});

<sm-select-box
      [formGroup]="formGroup"
      [fieldMeta]="selectField">
</sm-select-box>

this.selectField = new SelectField({
      fieldName: 'fromUser',
      displayName: 'Select Field',
      defaultSelectFirst: true,
      options: this.selectOptions,
      container: '.test-container'
});
html attributes
AttributesData-TypeDefaultsRequiredUses
formGroupFormGroup''yesreference to existing formGroup
fieldMetaTextField-yesMetadata of text field
valuestring''nodefault value for text field,
showLabelbooleantruenoto show or hide the label
dropdownItemTemplatestring''notemplate for the open dropdown
selectionTemplatestring''notemplate for the selected values
fieldMeta attributes
AttributesData-typeDefaultsRequiredUses
fieldNamestring''trueto set the value of field in formGroup
displayNamestring''falseto show label and title of the field
optionsArray[]nooptions to show in radios
readOnlybooleanfalsenoto enable disable the fields
placeholderstring''noto show the placeholder of the dropdown
isMultiplebooleanfalsenoto enable multiple selection in select box
countSelectedTextstring''nodefault count selection
hasAddButtonbooleanfalsenoto show add button in select box
addButtonTitlestring'Add New'nobutton title for add button
addButtonHtmlstring<div class="btn">${this.addButtonTitle}</div>nohtml for add button
onAddNewfunction_.noopnodefined function when add button get clicked
events
EventsUses
blurcalled on blur of field

Switch Field

import {SmSwitchModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmSwitchModule
    ...
  ]
});

<sm-switch [formGroup]="formGroup"
           [fieldMeta]="switchField">
</sm-switch>

this.switchField = new SwitchField({
      fieldName: 'switch',
      displayName: 'Switch field'
});
html attributes
AttributesData-TypeDefaultsRequiredUses
formGroupFormGroup''yesreference to existing formGroup
fieldMetaTextField-yesMetadata of text field
valuestring''nodefault value for text field,
showLabelbooleantruenoto show or hide the label
fieldMeta attributes
AttributesData-typeDefaultsRequiredUses
classstring''falseclass to be applied on field
optionsArray[]nooptions to show in field
readOnlybooleanfalsenoto enable disable the fields
newLinebooleanfalsenoto show new line in switch
events
EventsUses
blurcalled on blur of field

Textarea Field

import {SmTextareaModule} from "sm-ui-library";

@NgModule({
  ...
  imports: [
    ...
    SmTextareaModule
    ...
  ]
});

<sm-textarea-txt
    [formGroup]="formGroup"
    [fieldMeta]="textAreaField">
</sm-textarea-txt>

this.textAreaField = new TextareaField({
      fieldName: 'reason',
      displayName: 'Text Area'
});
html attributes
AttributesData-TypeDefaultsRequiredUses
formGroupFormGroup''yesreference to existing formGroup
fieldMetaTextField-yesMetadata of text field
valuestring''nodefault value for text field,
showLabelbooleantruenoto show or hide the label,
doTrimbooleantruenotrims the value of the text area
fieldMeta attributes
AttributesData-typeDefaultsRequiredUses
fieldNamestring''trueto set the value of field in formGroup
displayNamestring''falseto show label and title of the field
placeholderstring''noplaceholder of the field
events
EventsUses
blurcalled on blur of field
0.0.9

2 years ago

0.0.8

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.7

2 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.2

2 years ago

0.0.1

2 years ago