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

spfxhelper

v4.1.0

Published

Bundle of core functions which can be used in every project

Downloads

111

Readme

SharePoint Framework Helper

GitHub release npm npm bundle size npm npm

SharePoint Framework Helper

In the need to develop the solution faster and easier I have created a npm package, which will give you the flexibility to enjoy the much used logic handy and easy when writing code for SharePoint framework client side webparts or SharePoint framework extensions.

This npm package contains the most commonly used functions or I should say the operations that are used almost in every SPFx client side webpart or SPFx extensions. Using this npm package you can create your webparts much more easily and faster. This is very simple and handy.

This npm package code is also available on GitHub so if you are interested you can have a look at the implementation as well, or even you can request for the addition of new methods that you feel might help others as well.

Why to use ?

  • This library contains handy functions that will save lot of man hours in implementing
  • Well designed results so it will help in writing the code efficiently
  • Well broken into the type of operation, so include only the class that is most useful to you

How to use ?

To install the package execute the below command

> npm i spfxhelper

And then import the following in the code file

import { "CLASS_NAME" } from 'spfxhelper';

Inside the library

  • This library contains a number of classes

SPListOperations

This class contains all the methods that are responsible for the interaction of the SharePoint List.

| Methods | Description | |-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------| | createFolderInDocLib | creates the folder in document library | | createFolderInList | creates the folder in list | | createList | creates the list | | createListItem | creates the list item | | getContentTypesByList | Returns the content types associated with the list | | getInstance | returns the instance of the class | | getListBytitle | returns the list details by title | | getListItemByID | get the list items based on the item ID | | getListItems | returns all the list items based on the row count. If row count is not provided will return max i.e.. 100 | | getListItemsByNextLink | returns the items based on the next link provided | | getListItemsByQuery | get the list items based on the query parameter | | getListMetadata | returns the list metadata required to create the list | | getListsDetailsByBaseTemplateID | Returns the lists based on the template ID | | getViewsByList | Returns the lists views | | getDefaultView | Returns the default view of the list | | updateListItem | updates the list item | | getLibraryItemByFileID | returns the file for that specified file ID | | getLibraryItems | returns all the files from the document library |


SPFieldOperations

This is the class responsible for the operations related to SharePoint Fields.

| Methods | Description | |-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------| | addColumnToList | add the column to the list | | addFieldToView | adds the field to the view in the list | | addSiteColumnToList | adds the site column to the list | | createListColumn | creates the list column | | createSiteColumn | creates the site column | | getColumnMetadata | returns the column metadata required for the creation of the column | | getFieldByList | returns the field details from the list | | getFieldBySite | returns the fields details of the site column | | getFieldByView | returns the field details by view | | getFieldsByList | returns all the fields associated with the list | | getFieldsByView | returns all the fields associated with view in a list |


SPCommonOperations

This class is the extension of the base class where one can query the API's which are not available as methods in other classes

| Methods | Description | |---------------------------------------------------------------------------------------------------------|----------------------------------------------------| | getDocIconByFiles | returns the OOB icons for the file types | | getInstance | returns the instance of the class | | queryGETResquest | method to query any custom query with 'GET' verb | | queryMERGERequest | method to query any custom query with 'MERGE' verb | | queryPATCHRequest | method to query any custom query with 'PATCH' verb | | queryPOSTRequest | method to query any custom query with 'POST' verb |


SPCore (renamed from SPHelperCommon)

This class contains only static methods and contains the helper methods

| Methods | Description | |-------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------| | calculateAge | returns the age from the specified date | | getFieldInternalName | returns the internal name of the field (removes the x0020) | | getLocalStorage | returns the local storage object | | getParameterValue | returns the parameter value from URL | | isEmptyString | checks for the string emptiness | | isNull | check for the object null |


SPLogger

This class has been removed from the library. Instead use the OOB class Log in sp-core-library.

import { Log } from '@microsoft/sp-core-library';

Use the following methods

static error(source: string, error: Error, scope?: ServiceScope): void;
static info(source: string, message: string, scope?: ServiceScope): void;
static verbose(source: string, message: string, scope?: ServiceScope): void;
static warn(source: string, message: string, scope?: ServiceScope): void;

Do share how I can improve this library, so it can help all the SharePoint community

Happy Coding

#SharePointWidgets #MicrosoftSharePoint

Sumit Kanchan