# sp-lookup

> A SharePoint Lookup Picker

Latest version **2.0.1** (published 2020-05-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install sp-lookup
pnpm add sp-lookup
yarn add sp-lookup
bun add sp-lookup
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2020-05-21 |
| First published | 2020-05-11 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 8 |
| Unpacked size | 46.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Tesfaye Gari |
| Maintainers | tesfayegari |
| Keywords | SharePoint, SPLookup, SP-Lookup |

## Links

- npm: https://www.npmjs.com/package/sp-lookup
- Repository: https://github.com/tesfayegari/sp-lookup
- Homepage: https://github.com/tesfayegari/sp-lookup#readme
- Issues: https://github.com/tesfayegari/sp-lookup/issues
- npm.io page: https://npm.io/package/sp-lookup

## Dependencies (8)

- [@pnp/sp](https://npm.io/package/@pnp/sp.md) ^2.0.5
- [sp-pnp-js](https://npm.io/package/sp-pnp-js.md) ^3.0.10
- [@pnp/graph](https://npm.io/package/@pnp/graph.md) ^2.0.5
- [react-select](https://npm.io/package/react-select.md) ^3.1.0
- [@microsoft/sp-http](https://npm.io/package/@microsoft/sp-http.md) ^1.10.0
- [react-dual-listbox](https://npm.io/package/react-dual-listbox.md) ^2.0.0
- [@types/react-select](https://npm.io/package/@types/react-select.md) ^3.0.13
- [@microsoft/sp-webpart-base](https://npm.io/package/@microsoft/sp-webpart-base.md) ^1.10.0

## Recent versions

- 2.0.1 (latest) — 2020-05-21
- 2.0.0 — 2020-05-18
- 1.2.0 — 2020-05-18
- 1.1.0 — 2020-05-15
- 1.0.9 — 2020-05-15
- 1.0.8 — 2020-05-15
- 1.0.7 — 2020-05-15
- 1.0.6 — 2020-05-15
- 1.0.5 — 2020-05-15
- 1.0.4 — 2020-05-15
- 1.0.2 — 2020-05-13
- 1.0.1 — 2020-05-13
- 1.0.0 — 2020-05-11

## README

# SharePoint Lookup Selector

A control that can be used with any form or without a form to Select List Items. Best used with SharePoint Custom Forms (New or Edit)

## Dependencies
sp-pnp-js, react-select, react, react-dom, @microsoft/sp-webpart-base, @microsoft/sp-http

## How to use

This is a react Component that needs to be installed first and used with any SPFx react projects as follows

To Install the component
- `npm i sp-lookup`

Usage
```react
import SPLookup, { FormType } from 'sp-lookup';

..............

<SPLookup 
    itemId={2} //item ID is necessary when Form Type is not New Form
    lookupListName="AccordionList" //Lookup List Name, For this feature column is Title internal name
    parentListName="Sandwiches" //Parent List Name
    internalLookupName="MultiLookup" //Internal name of lookup column in Parent List
    onChange={value => console.log(value)} 
    context={this.props.context} 
    multi={true}
    formType={FormType.EditForm}/>
```
The Complete Props are 
```
interface ISPLookupProps {
  lookupListName: string; //List name of the lookup
  parentListName: string; //List name of the list which uses Lookup field
  internalLookupName?: string; //field internal name used for lookup column
  itemId?: number; //if edit or display form item id to be edited or displayed
  onChange: (value: any[]) => void; //selected value will be returned here
  styles?: any; // custom css to be used
  context: WebPartContext; // Webpart context needs to be passed 
  formType?: FormType; //Display Edit and New form types 
  multi?: boolean; // single or multi item selector 
  label?: string; // Label used for the field 
  async?: boolean; // This new feature allows for a large list, search for item to select 
}

//Form Types are as follows 
enum FormType {
  NewForm = 1,
  EditForm,
  DisplayForm
}
```

Screen Shots 
- Display Form
![Display Form Snipet](/assets/1.png)
![Display Form Screen](/assets/2.png)
- Edit Form 
![Edit Form Snipet](/assets/3.png)
![Edit Form Screen](/assets/4.png)

- Edit form with async true and custom label for the field on the form 

You can freely download the code and extend on your own
![Edit Form Snipet](/assets/6.png)
![Edit Form Screen](/assets/7.png)
![Edit Form Screen](/assets/8.png)
![Edit Form Screen](/assets/9.png)

- [`Github Repo for the package is `](https://github.com/tesfayegari/sp-lookup)
- [`Email: Tesfaye Gari `](mailto:tesfaye.gari@gmail.com)

### Happy Coding ♡
### By Tesfaye Gari, Sharing is Caring ♡

---
_Source: https://npm.io/package/sp-lookup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
