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

react-taxonomypicker-pnp

v0.2.4

Published

PnP JS version of Office 365 - SharePoint React Taxonomy Picker

Downloads

46

Readme

React-TaxonomyPicker-PnP

A Taxonomy Picker control built with TypeScript for React based on React-Select and PnP JS SP-Taxonomy. This version was built because a dependency on JSOM was considered undesirable and an SPFx webpart context was unavailable.

Always consider using the SPFx React TaxonomyPicker before using this one. But if you can't or won't use SPFx, this is a nice alternative.

There is one drawback to the original: async searching for terms can currently not be done on a termset, only on a termstore.

React-Taxonomy-Picker-gif

npm version NSP Status Code Climate GitHub license PRs Welcome Greenkeeper badge codecov

NPM

DEMO

https://jquintozamora.github.io/react-taxonomypicker

Features

  • Retrieve Terms from a Term Set by Term Set GUID.
  • Support for large Term Set using Async mode
    • Configurable via termSetCountMaxSwapToAsync property
  • Use PnP JS SP-Taxonomy
  • Use Promise (polyfill it if needed IE)

Features not supported

  • Add new Terms (Open TermSets)

Scenarios supported

Scenarios not supported

  • SharePoint Provider-hosted app
  • Other environment in which we are not allowed to use JSOM
  • Add new terms to the Taxonomy Store (specific for get terms by now)

Installation

Steps to use react-taxonomypicker-pnp in your React project

1.Install from NPM

npm install --save react-taxonomypicker-pnp

Note: You need to install the PnP packages or JS file separately!

2. Import and use in your application

import TaxonomyPicker from "react-taxonomypicker-pnp";
// Optionally include its styles in you build process as well
import "react-taxonomypicker-pnp/dist/React.TaxonomyPicker.css";

Though you can also use theming for this.

3. Usage

Mock / Local mode

Don't configure termSetGuid and load the options from defaultOptions object.

<TaxonomyPicker
  name="Language"
  displayName="Language"
  defaultOptions={[
    { label: "English", value: "f50249b6-310d-43b6-aaa6-f0cb46d851bf" },
    { label: "Spanish", value: "237ca323-1ed8-4199-a49b-a9f7ce4256bf" },
    { label: "German", value: "44024c7e-f738-4755-90e1-15866327c806" },
    { label: "Italian", value: "65f67491-bdca-491a-84fa-f6fd913f40fa" },
  ]}
  multi
  showPath
/>

SharePoint environment mode

Configure termSetGuid with the desired term set

<TaxonomyPicker
  name="Language"
  displayName="Language"
  termSetGuid="26ebf149-101a-4996-9df2-8179a537350d"
  termSetName="Language"
  termSetCountMaxSwapToAsync={100}
  multi
  showPath
/>

Setup PnP Context

Don't forget to setup the PnP context in your component constructor.

sp.setup({

  sp: {
    headers: {
      Accept: "application/json;odata=verbose",
    },
    baseUrl: url
    // For example: _spPageContextInfo.webAbsoluteUrl (In classic SP)
  },
});

Theming

The picker uses react-select and supports it's theming. Simply add a theme property and implement it like so:

<TaxonomyPicker
  ...
  theme={theme => ({
      ...theme,
      borderRadius: 0,
      colors: {
        ...theme.colors,
        primary: 'green',
        primary25: 'blue',
        primary50: 'red'
      },
    })}
  />

Docker

For use with docker a docker file has been included. Take the following steps to use it if you are a docker user:

1.Update webpack/webpack.config.dev.js

the following line should be uncommented on the devServer property.

host:"0.0.0.0",

2.Build the docker file

docker build . -t=react-taxonomypicker

3.Run the docker command

docker run -it --rm -p 3000:3000 -v ${PWD}:/usr/app/react-taxonomypicker react-taxonomypicker

This command can also be executed by running the dock.ps1

Done

  • Expose as a Module / Global / UMD library
  • Upload to npm
  • Create ES6 sample application for usage
  • Create TypeScript sample application for usage
  • Create SPFx webpart sample for usage
  • Create types and include them with the npm package
  • onPickerChange event handler exposed
  • react-select properties exposed (extends them)
  • termSetCountMaxSwapToAsync property exposed to choose between Sync / Async modes
  • defaultOptions array exposed to enable input mock data when no termSetGuid configured
  • Create and Expose properties for custom styles

TODOs

  • Create types to allow people include with @types

Want to contribute?

Anyone can help make this project better

License

MIT License

Copyright (c) 2017 - 2018 José Quinto

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.