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

@lrnwebcomponents/simple-search

Package Overview
Dependencies
Maintainers
4
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lrnwebcomponents/simple-search - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

25

gulpfile.js

@@ -79,10 +79,3 @@ const gulp = require("gulp");

});
// run polymer build to generate everything fully
gulp.task("build", () => {
const spawn = require("child_process").spawn;
let child = spawn("polymer", ["build"]);
return child.on("close", function(code) {
console.log("child process exited with code " + code);
});
});
// run polymer analyze to generate documentation

@@ -104,3 +97,3 @@ gulp.task("analyze", () => {

gulp
.src("./build/es6/" + packageJson.wcfactory.elementName + ".js")
.src("./" + packageJson.wcfactory.elementName + ".js")
.pipe(

@@ -112,10 +105,3 @@ rename({

.pipe(gulp.dest("./"));
gulp
.src("./build/es5-amd/" + packageJson.wcfactory.elementName + ".js")
.pipe(
rename({
suffix: ".amd"
})
)
.pipe(gulp.dest("./"));
return gulp

@@ -151,5 +137,2 @@ .src("./" + packageJson.wcfactory.elementName + ".js")

gulp.task(
"default",
gulp.series("merge", "analyze", "build", "compile", "sourcemaps")
);
gulp.task("default", gulp.series("merge", "analyze", "compile", "sourcemaps"));

7

package.json

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

},
"version": "2.1.1",
"version": "2.1.2",
"description": "Automated conversion of simple-search",

@@ -24,3 +24,2 @@ "repository": {

"umd": "simple-search.umd.js",
"amd": "simple-search.amd.js",
"scripts": {

@@ -47,3 +46,3 @@ "test": "../../node_modules/.bin/wct --configFile ../../wct.conf.json node_modules/@lrnwebcomponents/simple-search/test/",

"@lrnwebcomponents/deduping-fix": "^2.1.1",
"@lrnwebcomponents/storybook-utilities": "^2.1.1",
"@lrnwebcomponents/storybook-utilities": "^2.1.2",
"@polymer/iron-component-page": "github:PolymerElements/iron-component-page",

@@ -67,3 +66,3 @@ "@polymer/iron-demo-helpers": "^3.1.0",

],
"gitHead": "377805ee041d6205232182b01f8e05a177ef3bf7"
"gitHead": "d857f1d834ec0bd10fee57ad11f60eb37416db07"
}
/**
* Copyright 2018 The Pennsylvania State University
* @license Apache-2.0, see License.md for full text.
*/import{html,PolymerElement}from"./node_modules/@polymer/polymer/polymer-element.js";import"./node_modules/@polymer/iron-icons/iron-icons.js";import"./node_modules/@polymer/paper-input/paper-input.js";import"./node_modules/@polymer/paper-tooltip/paper-tooltip.js";import"./lib/simple-search-content.js";export{SimpleSearch};/**
*/
import { html, PolymerElement } from "@polymer/polymer/polymer-element.js";
import "@polymer/iron-icons/iron-icons.js";
import "@polymer/paper-input/paper-input.js";
import "@polymer/paper-tooltip/paper-tooltip.js";
import "./lib/simple-search-content.js";
export { SimpleSearch };
/**
* `simple-search`

@@ -83,42 +91,152 @@ * `A button used in simple-search`

*
*/class SimpleSearch extends PolymerElement{static get is(){return"simple-search"}static get properties(){return{/**
*/
class SimpleSearch extends PolymerElement {
static get is() {
return "simple-search";
}
static get properties() {
return {
/**
* always float the label
*/alwaysFloatLabel:{type:Boolean,value:!1},/**
*/
alwaysFloatLabel: {
type: Boolean,
value: false
},
/**
* Is the search case-sensitive
*/caseSensitive:{type:Boolean,value:null},/**
*/
caseSensitive: {
type: Boolean,
value: null
},
/**
* The id of the container element that the navigation buttons control
*/controls:{type:String,value:null},/**
*/
controls: {
type: String,
value: null
},
/**
* is the previous next button disabled
*/nextButtonDisabled:{type:Boolean,computed:"_isNavButtonDisabled(resultPointer,resultCount,resultsSpan,1)"},/**
*/
nextButtonDisabled: {
type: Boolean,
computed:
"_isNavButtonDisabled(resultPointer,resultCount,resultsSpan,1)"
},
/**
* label for next result icon
*/nextButtonIcon:{type:String,value:"arrow-forward"},/**
*/
nextButtonIcon: {
type: String,
value: "arrow-forward"
},
/**
* label for next result button
*/nextButtonLabel:{type:String,value:"next result"},/**
*/
nextButtonLabel: {
type: String,
value: "next result"
},
/**
* never float the label
*/noLabelFloat:{type:Boolean,value:!1},/**
*/
noLabelFloat: {
type: Boolean,
value: false
},
/**
* are there any results to navigate?
*/noResults:{type:Boolean,computed:"_hasNoResults(resultCount)"},/**
*/
noResults: {
type: Boolean,
computed: "_hasNoResults(resultCount)"
},
/**
* is there an active search?
*/noSearch:{type:Boolean,computed:"_hasNoSearch(searchTerms)"},/**
*/
noSearch: {
type: Boolean,
computed: "_hasNoSearch(searchTerms)"
},
/**
* is the previous result button disabled
*/prevButtonDisabled:{type:Boolean,computed:"_isNavButtonDisabled(resultPointer,resultCount,resultsSpan,-1)"},/**
*/
prevButtonDisabled: {
type: Boolean,
computed:
"_isNavButtonDisabled(resultPointer,resultCount,resultsSpan,-1)"
},
/**
* label for previous result icon
*/prevButtonIcon:{type:String,value:"arrow-back"},/**
*/
prevButtonIcon: {
type: String,
value: "arrow-back"
},
/**
* label for previous result button
*/prevButtonLabel:{type:String,value:"previous result"},/**
*/
prevButtonLabel: {
type: String,
value: "previous result"
},
/**
* Number of results.
*/resultCount:{type:Number,value:0},/**
*/
resultCount: {
type: Number,
value: 0
},
/**
* Which result are we currently on?
*/resultPointer:{type:Number,value:0},/**
*/
resultPointer: {
type: Number,
value: 0
},
/**
* Number of results.
*/resultsSpan:{type:String,computed:"_getResultsSpan(noSearch,resultPointer,resultCount)"},/**
*/
resultsSpan: {
type: String,
computed: "_getResultsSpan(noSearch,resultPointer,resultCount)"
},
/**
* label for search icon
*/searchInputIcon:{type:String,value:"search"},/**
*/
searchInputIcon: {
type: String,
value: "search"
},
/**
* label for search input
*/searchInputLabel:{type:String,value:"search"},/**
*/
searchInputLabel: {
type: String,
value: "search"
},
/**
* an array of search terms
*/searchTerms:{type:Array,value:[]},/**
*/
searchTerms: {
type: Array,
value: []
},
/**
* The container element that the navigation buttons control
*/target:{type:Object,value:null}}}// render function
static get template(){return html`
*/
target: {
type: Object,
value: null
}
};
}
// render function
static get template() {
return html`
<style>

@@ -221,5 +339,26 @@ :host {

</div>
`}ready(){super.ready();let root=this,search=root.$.input;root._getSearchText(search.value)}/**
`;
}
ready() {
super.ready();
let root = this,
search = root.$.input;
root._getSearchText(search.value);
}
/**
* are there any results to navigate?
*/_handleChange(e){let root=this;root._getSearchText(root.$.input.value);root.resultCount=0;root.resultPointer=0;root.dispatchEvent(new CustomEvent("simple-search",{detail:{search:root,content:e}}))}/**
*/
_handleChange(e) {
let root = this;
root._getSearchText(root.$.input.value);
root.resultCount = 0;
root.resultPointer = 0;
root.dispatchEvent(
new CustomEvent("simple-search", { detail: { search: root, content: e } })
);
}
/**
* are there any results to navigate?

@@ -229,3 +368,8 @@ *

* @returns {boolean} whether or not there are results
*/_hasNoResults(resultCount){return 1>resultCount}/**
*/
_hasNoResults(resultCount) {
return resultCount < 1;
}
/**
* are there any results to navigate?

@@ -235,3 +379,8 @@ *

* @returns {boolean} whether or not there are search terms
*/_hasNoSearch(searchTerms){return 1>searchTerms.length}/**
*/
_hasNoSearch(searchTerms) {
return searchTerms.length < 1;
}
/**
* get results span text

@@ -243,11 +392,57 @@ *

* @returns {string} "y results" or "x/y" text
*/_getResultsSpan(noSearch,resultPointer,resultCount){let html="";if(0<resultCount&&0<resultPointer){html=resultPointer+"/"+resultCount}else{html=" "+resultCount}this.$.xofy.innerHTML=html;return this.$.xofy.innerHTML}/**
*/
_getResultsSpan(noSearch, resultPointer, resultCount) {
let html = "";
if (resultCount > 0 && resultPointer > 0) {
html = resultPointer + "/" + resultCount;
} else {
html = " " + resultCount;
}
this.$.xofy.innerHTML = html;
return this.$.xofy.innerHTML;
}
/**
* navigate results
*/_navigateResults(e){let root=this,increment="next"===e.currentTarget.id?1:-1;if(0<this.resultPointer+increment&&this.resultPointer+increment<=this.resultCount){this.resultPointer+=increment;this.dispatchEvent(new CustomEvent("goto-result",{detail:this.resultPointer}))}}/**
*/
_navigateResults(e) {
let root = this,
increment = e.currentTarget.id === "next" ? 1 : -1;
if (
this.resultPointer + increment > 0 &&
this.resultPointer + increment <= this.resultCount
) {
this.resultPointer += increment;
this.dispatchEvent(
new CustomEvent("goto-result", { detail: this.resultPointer })
);
}
}
/**
* navigate results
*/_isNavButtonDisabled(pointer,count,span,inc){return""==span||0>=pointer+inc||pointer+inc>count}/**
*/
_isNavButtonDisabled(pointer, count, span, inc) {
return span == "" || pointer + inc <= 0 || pointer + inc > count;
}
/**
* gets the tab-index of cues based on whether or not interactive cues are disabled
*
* @param {string} a string of search text
*/_getSearchText(find){let temp=[];if(find!==void 0&&null!==find){temp=find.split(/[\"\']/gm);for(let i=0;i<temp.length;i++){temp[i]=temp[i].trim();if(""===temp[i])temp.splice(i,1)}}this.set("searchTerms",[]);this.set("searchTerms",temp.slice(0))}/**
*/
_getSearchText(find) {
let temp = new Array();
if (find !== undefined && find !== null) {
temp = find.split(/[\"\']/gm);
for (let i = 0; i < temp.length; i++) {
temp[i] = temp[i].trim();
if (temp[i] === "") temp.splice(i, 1);
}
}
this.set("searchTerms", []);
this.set("searchTerms", temp.slice(0));
}
/**
* search a string of content for any terms and return an array of results.

@@ -300,2 +495,51 @@ * For example if I searched for the with

* @returns {array} an array of search results
*/findMatches(content){let root=this,terms=root.searchTerms,modifier=this.caseSensitive?"gm":"gim",results=content.slice(0),updateResults=function(find){for(let i=0;i<results.length;i++){if(!1===results[i].matched){let regex=new RegExp("\\b"+find+"\\b",modifier),text=results[i].text,start=text.search(regex),end=start+find.length;if(-1<start){root.resultCount+=1;let pre=text.slice(0,start),match=text.slice(start,end),post=text.slice(end,text.length),update=results.splice(i,1,{matched:!1,text:pre,searchObject:root},{matched:!0,matchNumber:root.resultCount,text:match,searchObject:root},{matched:!1,text:post,searchObject:root})}}}};for(let i=0;i<terms.length;i++){updateResults(terms[i])}root.resultPointer=0;return results}}customElements.define(SimpleSearch.is,SimpleSearch);
*/
findMatches(content) {
let root = this,
terms = root.searchTerms,
modifier = this.caseSensitive ? "gm" : "gim",
results = content.slice(0),
updateResults = function(find) {
for (let i = 0; i < results.length; i++) {
if (results[i].matched === false) {
let regex = new RegExp("\\b" + find + "\\b", modifier),
text = results[i].text,
start = text.search(regex),
end = start + find.length;
if (start > -1) {
root.resultCount += 1;
let pre = text.slice(0, start),
match = text.slice(start, end),
post = text.slice(end, text.length),
update = results.splice(
i,
1,
{
matched: false,
text: pre,
searchObject: root
},
{
matched: true,
matchNumber: root.resultCount,
text: match,
searchObject: root
},
{
matched: false,
text: post,
searchObject: root
}
);
}
}
}
};
for (let i = 0; i < terms.length; i++) {
updateResults(terms[i]);
}
root.resultPointer = 0;
return results;
}
}
customElements.define(SimpleSearch.is, SimpleSearch);
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