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

ngx-uploadcare-widget

v4.0.0

Published

Angular 2+ wrapper for Uploadcare Widget

Downloads

1,043

Readme

ngx-uploadcare-widget

Angular 2+ wrapper for Uploadcare Widget.

NPM version Build Status Uploadcare stack on StackShare

Uploadcare Widget is an HTML5 file uploader, a part of the Uploadcare ecosystem.

Install

For Angular v14+ — install ngx-uploadcare-widget v4.x

npm install [email protected] uploadcare-widget

For Angular v12+ — install ngx-uploadcare-widget v3.x

npm install [email protected] uploadcare-widget

For Angular from v9 to v11 — install ngx-uploadcare-widget v2.x

npm install [email protected] uploadcare-widget

For Angular v8 and lower — install ngx-uploadcare-widget v1.x

npm install [email protected] uploadcare-widget

Usage

The basic wrapper usage scenario can be described in four steps.

Step 1. Import the module

import { UcWidgetModule } from 'ngx-uploadcare-widget';

Step 2. Import the module to yours

@NgModule({
  imports: [
    ...,
    UcWidgetModule,
  ],
  ...
})
...

Step 3. Use the component in your template

<!-- with default markup -->
<ngx-uploadcare-widget
  images-only="true"
  public-key="YOUR_PUBLIC_KEY">
</ngx-uploadcare-widget>

<!-- without any markup -->
<ngx-uploadcare-widget-custom
  images-only="true"
  public-key="YOUR_PUBLIC_KEY">
</ngx-uploadcare-widget-custom>

Step 4. Have fun with the widget events

The component currently supports three widget events:

  • on-change
  • on-upload-complete
  • on-progress

Here is how you can handle those three,

<ngx-uploadcare-widget
  images-only="true"
  public-key="demopublickey"
  (on-upload-complete)="yourOnUploadHandler($event)"
  (on-change)="yourOnChangeHandler($event)"
  (on-progress)="yourOnProgressHandler($event)">
</ngx-uploadcare-widget>

You can learn more about this widget events in our docs.

Configuration

Supported input attributes

All the following attributes correspond to the ones listed in the widget docs, but without the data- prefix.

Events

Events usage example:

  onUpload(info) {
    console.log('fired Event "onUpload"');
    console.log(info);
  }

  onProgress(progress) {
    console.log('fired Event "onProgress with data:"');
    console.log(progress);
  }

  onChange(file) {
    if(!file) {
      return;
    }
    console.log('fired Event "onChange"');
  // input file parameter depends on "multiple-files" widget attribute
    if(this.multipleFiles) {
  //  file contains 2 methods:
  //  .promise() - returns the general promise for all uploaded files which resolves into an uploaded file group info
  //  .files() - returns an array of promises: one per each uploaded file. Each promise resolves into an uploaded file info
      console.log(file);
      if(file.promise) {
        file.promise().then((groupInfo) => {
          console.log('resolved general promise from "onChange" with data:');
          console.log(groupInfo);
        });
      }
      if(file.files) {
        file.files().forEach((promise) => {
          promise.then((fileInfo) => {
            console.log('resolves file promise with file info:');
            console.log(fileInfo);
          });
        });
      } else {
  // file contains uploaded file info
        console.log(file);
      }
    }
  }

Methods

The components provides following public methods:

  • clearUploads() - Removes all current uploads from the widget. You can use the method to reset a form even if a user has already uploaded some files.
  • reset(clearUploads = false) - Resets the widget, You can also remove all the current uploads if clearUploads is set to true
  • openDialog() - Opens Uploadcare widget dialog with current configuration.
  • reject() - Closes the dialog opened with openDialog() method only and discards any file selection.

All methods are accessible from a parent component via the @ViewChild() approach.

Localization

It is possible that your locale is not available in the widget yet. If that’s the case, contributing your locale might be a good idea. This can be done by forking the main repository and adding a localization file here.

The quick way of implementing your locale would be overriding any of the existing ones via the UPLOADCARE_LOCALE_TRANSLATIONS property.

Security issues

If you think you ran into something in Uploadcare libraries which might have security implications, please hit us up at [email protected] or Hackerone.

We'll contact you personally in a short time to fix an issue through co-op and prior to any public disclosure.

Feedback

Issues and PRs are welcome. You can provide your feedback or drop us a support request at [email protected].