npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mbd-common-libs/angular-common-components

v2.60.2

Published

Includes components for portal and market (form builder, form components, file upload, app cards, login, signup, inputs, etc)

Downloads

1

Readme

angular-common-components

About the library

Includes components for portal and market (form builder, form components, file upload, app cards, login, signup, inputs, etc)

  • Form components:
    • form builder.
    • input, selects.
    • file upload
    • color picker
    • video url
    • date time picker
    • tags
    • etc
  • Common components:
    • select.
    • button
    • iframe video
    • etc.
  • Portal components:
    • charts
    • app tables
  • Market components:
    • app cards
    • app tables
  • Auth components

Built With

Dependencies

"@ng-bootstrap/ng-bootstrap": "6.0.2",
"@tinymce/tinymce-angular": "4.2.0",
"angular-svg-icon": "11.0.0",
"bootstrap": "4.6.0",
"chart.js": "3.3.2",
"ngx-color-picker": "10.1.0",
"ngx-embed-video": "1.0.4",
"ngx-image-cropper": "3.1.9",
"ngx-infinite-scroll": "10.0.0",
"ngx-owl-carousel-o": "4.0.0",
"ngx-spinner": "9.0.2",
"tinymce": "5.6.2",

Installation

Before installation please check required libs README.md

  1. Install dependencies
npm i --save @ng-bootstrap/[email protected] @tinymce/[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]  
  1. Install library npm i @mbd-common-libs/angular-common-components

  2. Connect library styles by import in styles @import "~@mbd-common-libs/angular-common-components/assets/styles/styles.scss"; or add it to angular json

  "build": {
    ...
    "styles": [
      ...
      "node_modules/@mbd-common-libs/angular-common-components/assets/styles/styles.scss"
    ],
  }
  1. Connect library assets
  "assets": [
    {
      "glob": "**/*", "input": "node_modules/@mbd-common-libs/angular-common-components/assets/img",
      "output": "/assets/angular-common-components",
    },
  ]
  1. Including TinyMCE within the Application, open angular.json and add TinyMCE to the assets property.
  "assets": [
     { "glob": "**/*", "input": "node_modules/tinymce", "output": "/tinymce/" }
  ]
  1. To load TinyMCE when the page or application is loaded, open angular.json and add TinyMCE to the global scripts tag.
  "scripts": [
    "node_modules/tinymce/tinymce.min.js"
  ]
  1. For the File Uploader component should be created a service which extends FileUploaderService. Service must consist two function fileUploadRequest and fileDetailsRequest which should return your requests to CAP Example of service:
@Injectable()
export class FileService extends FileUploaderService {
    constructor(private fileUploaderService: FileUploadDownloadService) {
        super();
    }

    fileUploadRequest(
        file: FormData,
        isPrivate: boolean,
        hash?: string[],
    ): Observable<HttpResponse<FileDetails> | HttpUploadProgressEvent> {
        return this.fileUploaderService.uploadToOpenChannel(file, isPrivate, hash);
    }

    fileDetailsRequest(fileId: string): Observable<FileDetails> {
        return this.fileUploaderService.downloadFileDetails(fileId);
    }
}

FileUploaderService should be provided in AppModule:

@NgModule({
    imports: [
        ...
        OcFormComponentsModule,
    ],
    providers: [
        { provide: FileUploaderService, useClass: FileService },
    ]
})
export class AppModule {}
  1. Error messages for all forms. Have default implementation DefaultErrorMessageConfiguration.
@NgModule({
    providers: [
        { provide: AbstractErrorMessageConfiguration, useValue: new DefaultErrorMessageConfiguration() },
    ],
    bootstrap: [AppComponent],
    entryComponents: [],
})
export class AppModule {}

If you want to update error messages follow this example:

import {
    AbstractErrorMessageConfiguration,
    DefaultErrorMessageConfiguration,
} from '@mbd-common-libs/angular-common-components/src/lib/common-components';

class CustomErrorMessageConfiguration extends DefaultErrorMessageConfiguration {
    constructor() {
        super(
            {
                # default field errors
                required: () => '(default) Please fill out this field.',
            },
            {
                # default server errors              
                defaultMessageHandler: () => '(custom) Server error.',
                email_is_incorrect: () => '(custom) Email is incorrect.',
            },
            {
                # your custom form     
                MY_FIRST_FORM: {
                    specificFields: [
                        {
                            # field from current form
                            fieldPath: 'text-id',
                            fieldValidators: {
                                # override previous error message 
                                required: () => '(custom) (MY_FIRST_FORM) Please fill out this field',
                            },
                        },
                    ],
                },
                # your custom form
                MY_SECOND_FORM: {
                    specificFields: [
                        {
                            fieldPath: 'text-id',
                            fieldValidators: {
                                required: () => '(custom) (MY_SECOND_FORM) Please fill out this field',
                            },
                        },
                    ],
                },
                # this form from library
                login: {
                    specificFields: [
                        {
                            fieldPath: 'email',
                            fieldValidators: {
                                required: () => '(custom) Email is required field.',
                            },
                        },
                    ],
                },
            },
        );
    }
}

@NgModule({
    providers: [
        { provide: AbstractErrorMessageConfiguration, useClass: CustomErrorMessageConfiguration },
    ],
    bootstrap: [AppComponent],
    entryComponents: [],
})
export class AppModule {}


# Your component (ts)
@Component({
  ...
})
export class YourComponent  {
    formJsonData: Partial<AppFormField> = {
        fields: [
            {
                id: 'text-id',
                type: 'text',
                label: 'My text label',
                attributes: {
                    required: true,
                },
            },
        ],
    };
}

# Your component (html)
<div class="my-forms">
  <!-- default login form, already have ID 'login' -->
  <oc-login></oc-login>

  <!--  your custom form, with ID 'MY_FIRST_FORM' -->
  <oc-form formId="MY_FIRST_FORM" [formJsonData]="formJsonData"></oc-form>

  <!--  your custom form with ID 'MY_SECOND_FORM'-->
  <oc-form formId="MY_SECOND_FORM" [formJsonData]="formJsonData"> </oc-form>
</div>

Connect library to project

Note: Run commands from the root directory.

  1. 'npm i'

  2. ng build angular-common-components or ng build angular-common-components --watch (Note: Flag '--watch' rebuild project after any changes.)

  3. cd ./dist/angular-common-components

  4. sudo npm link Then copy result link.

  5. In your angular project run: npm install file:{absolute path to angular-common-components}/dist/angular-common-components

  6. Import example (ts file): import { ComponentOrModel } from '@mbd-common-libs/angular-common-components/src/lib/common-components';

Running tests

Run npm run test

Package Project

Run npm run angular-common-components-pack

Publish package version

Run cd ./dist/angular-common-components && npm publish

Storybook

  • Install npm dependencies

    npm i

  • Build Project

    ng build angular-common-components --watch

  • Create doc for storybook

    npm run docs:json

  • Run Storybook

    npm run storybook

Note:

  • If you can't start the Storybook. Try to Update its version: npx sb@latest upgrade

  • If updating the storybook version did not help. Try this: npm run storybook-update-and-run