Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

netlify-cms-widget-async-select

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netlify-cms-widget-async-select - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

1

dev/index.js

@@ -38,2 +38,3 @@ import './bootstrap.js';

displayField: 'name',
searchField: 'name',
},

@@ -40,0 +41,0 @@ ],

3

package.json

@@ -14,3 +14,3 @@ {

],
"version": "1.0.1",
"version": "1.1.0",
"homepage": "https://github.com/chrisboustead/netlify-cms-widget-async-select",

@@ -35,2 +35,3 @@ "license": "MIT",

"eslint-plugin-react": "^7.12.4",
"fuzzy": "^0.1.3",
"html-webpack-plugin": "^3.2.0",

@@ -37,0 +38,0 @@ "immutable": "^3.7.6",

@@ -8,2 +8,3 @@ import React from 'react';

import { reactSelectStyles } from 'netlify-cms-ui-default';
import fuzzy from 'fuzzy';

@@ -55,6 +56,7 @@ function optionToString(option) {

async getOptions() {
async getOptions(term) {
const { field } = this.props;
const valueField = field.get('valueField');
const displayField = field.get('displayField') || valueField;
const searchField = field.get('searchField') || displayField;
const url = field.get('url');

@@ -79,17 +81,20 @@ const method = field.get('method') || 'GET';

return mappedData
.map(entry => ({
value: entry.getIn(valueField.split('.')),
label: entry.getIn(displayField.split('.')),
data: entry,
}))
.toArray();
}
let mappedOptions = mappedData.map(entry => ({
value: entry.getIn(valueField.split('.')),
label: entry.getIn(displayField.split('.')),
data: entry,
}));
shouldComponentUpdate(nextProps) {
return (
this.props.value !== nextProps.value ||
this.props.hasActiveStyle !== nextProps.hasActiveStyle ||
this.props.queryHits !== nextProps.queryHits
);
if (term) {
mappedOptions = fuzzy
.filter(term, mappedOptions, {
extract: el => el.data.getIn(searchField.split('.')),
})
.sort((entryA, entryB) => entryB.score - entryA.score)
.map(entry => entry.original);
} else {
mappedOptions = mappedOptions.toArray();
}
return mappedOptions;
}

@@ -165,3 +170,3 @@

loadOptions = debounce((term, callback) => {
this.getOptions().then(options => {
this.getOptions(term).then(options => {
if (!this.allOptions && !term) {

@@ -176,2 +181,4 @@ this.allOptions = options;

callback(options);
// Refresh state to trigger a re-render.
this.setState({ ...this.state });
});

@@ -178,0 +185,0 @@ }, 500);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc