Commit 9a5a9295 authored by Gaetan's avatar Gaetan

build(gulp): Replace rollup by webpack

parent e5dd23b9
File added
{
"sourceMaps": false,
"ignore": ["node_modules/**"],
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": [ ">0.25%", "ie 11"]
}
}]
],
"env": {
"test": {
"presets": [["env"]]
}
},
"plugins": [
"transform-object-rest-spread"
]
}
language: node_js
cache:
directories:
- ~/.npm
notifications:
email: false
node_js:
- '9'
- '8'
- '6'
- '4'
after_success:
- npm run travis-deploy-once "npm run semantic-release"
branches:
except:
- /^v\d+\.\d+\.\d+$/
......@@ -2,7 +2,7 @@
"name": "bulma-tagsinput",
"description": "Bulma.io extension to add interaction on input tags",
"main": "tagsinput.sass",
"version": "1.0.11",
"version": "1.1.0",
"authors": [
"Wikiki <wikiki@protonmail.com> (https://wikiki.github.io)"
],
......
This diff is collapsed.
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b():'function'==typeof define&&define.amd?define('bulmaTagsinput',b):a.bulmaTagsinput=b()})(this,function(){'use strict';const a=['click','touchstart'],b=188;class c{constructor(a,b={}){if(this.element='string'==typeof a?document.querySelector(a):a,!this.element)throw new Error('An invalid selector or non-DOM node has been provided.');this.options=Object.assign({},{disabled:!1,delimiter:',',allowDelete:!0,lowercase:!1,uppercase:!1,duplicates:!0},b),this.element.dataset.hasOwnProperty('lowercase')&&(this.options.lowercase=this.element.dataset('lowercase')),this.element.dataset.hasOwnProperty('uppercase')&&(this.options.lowercase=this.element.dataset('uppercase')),this.element.dataset.hasOwnProperty('duplicates')&&(this.options.lowercase=this.element.dataset('duplicates')),this.init()}static attach(a='input[type="tags"]',b={}){let d=[];const e=document.querySelectorAll(a);return[].forEach.call(e,(a)=>{setTimeout(()=>{d.push(new c(a,b))},100)}),d}init(){if(!this.options.disabled){this.tags=[],this.container=document.createElement('div'),this.container.className='tagsinput',this.container.classList.add('field'),this.container.classList.add('is-grouped'),this.container.classList.add('is-grouped-multiline'),this.container.classList.add('input');let a=this.element.getAttribute('type');a&&'tags'!==a||(a='text'),this.input=document.createElement('input'),this.input.setAttribute('type',a),this.element.getAttribute('placeholder')?this.input.setAttribute('placeholder',this.element.getAttribute('placeholder')):this.input.setAttribute('placeholder','Add a Tag'),this.container.appendChild(this.input);let b=this.element.nextSibling;this.element.parentNode[b?'insertBefore':'appendChild'](this.container,b),this.element.style.cssText='position:absolute;left:0;top:0;width:1px;height:1px;opacity:0.01;',this.element.tabIndex=-1,this.enable()}}enable(){this.enabled||this.options.disabled||(this.element.addEventListener('focus',()=>{this.container.classList.add('is-focused'),this.select(Array.prototype.slice.call(this.container.querySelectorAll('.tag:not(.is-delete)')).pop())}),this.input.addEventListener('focus',()=>{this.container.classList.add('is-focused'),this.select(Array.prototype.slice.call(this.container.querySelectorAll('.tag:not(.is-delete)')).pop())}),this.input.addEventListener('blur',()=>{this.container.classList.remove('is-focused'),this.select(Array.prototype.slice.call(this.container.querySelectorAll('.tag:not(.is-delete)')).pop()),this.savePartial()}),this.input.addEventListener('keydown',(a)=>{let c,d=a.charCode||a.keyCode||a.which,e=this.container.querySelector('.tag.is-active'),f=Array.prototype.slice.call(this.container.querySelectorAll('.tag:not(.is-delete)')).pop(),g=this.caretAtStart(this.input);if(e&&(c=this.container.querySelector('[data-tag="'+e.innerHTML.trim()+'"]')),this.setInputWidth(),d===13||d===this.options.delimiter.charCodeAt(0)||d===b||d===9){if(!this.input.value&&(d!==this.options.delimiter.charCodeAt(0)||d===b))return;this.savePartial()}else if(d===46&&c)c.nextSibling?this.select(c.nextSibling.querySelector('.tag')):c.previousSibling&&this.select(c.previousSibling.querySelector('.tag')),this.container.removeChild(c),this.tags.splice(this.tags.indexOf(c.getAttribute('data-tag')),1),this.setInputWidth(),this.save();else if(d===8){if(c)c.previousSibling?this.select(c.previousSibling.querySelector('.tag')):c.nextSibling&&this.select(c.nextSibling.querySelector('.tag')),this.container.removeChild(c),this.tags.splice(this.tags.indexOf(c.getAttribute('data-tag')),1),this.setInputWidth(),this.save();else if(f&&g)this.select(f);else return;}else if(d===37){if(c)c.previousSibling&&this.select(c.previousSibling.querySelector('.tag'));else{if(!g)return;this.select(f)}}else if(d===39){if(!c)return;this.select(c.nextSibling.querySelector('.tag'))}else return this.select();return a.preventDefault(),!1}),this.input.addEventListener('input',()=>{this.element.value=this.getValue(),this.element.dispatchEvent(new Event('input'))}),this.input.addEventListener('paste',()=>setTimeout(savePartial,0)),this.container.addEventListener('mousedown',(a)=>{this.refocus(a)}),this.container.addEventListener('touchstart',(a)=>{this.refocus(a)}),this.savePartial(this.element.value),this.enabled=!0)}disable(){this.enabled&&!this.options.disabled&&(this.reset(),this.enabled=!1)}select(a){let b=this.container.querySelector('.is-active');b&&b.classList.remove('is-active'),a&&a.classList.add('is-active')}addTag(b){if(~b.indexOf(this.options.delimiter)&&(b=b.split(this.options.delimiter)),Array.isArray(b))return b.forEach((a)=>{this.addTag(a)});let c=b&&b.trim();if(!c)return!1;if('true'==this.options.lowercase&&(c=c.toLowerCase()),'true'==this.options.uppercase&&(c=c.toUpperCase()),this.options.duplicates||-1===this.tags.indexOf(c)){this.tags.push(c);let b=document.createElement('div');b.className='control',b.setAttribute('data-tag',c);let d=document.createElement('div');d.className='tags',d.classList.add('has-addons');let e=document.createElement('span');if(e.className='tag',e.classList.add('is-active'),this.select(e),e.innerHTML=c,d.appendChild(e),this.options.allowDelete){let b=document.createElement('a');b.className='tag',b.classList.add('is-delete'),a.forEach((a)=>{b.addEventListener(a,(a)=>{let b,c=a.target.parentNode,d=Array.prototype.slice.call(this.container.querySelectorAll('.tag')).pop(),e=this.caretAtStart(this.input);if(c&&(b=this.container.querySelector('[data-tag="'+c.innerText.trim()+'"]')),b)this.select(b.previousSibling),this.container.removeChild(b),this.tags.splice(this.tags.indexOf(b.getAttribute('data-tag')),1),this.setInputWidth(),this.save();else if(d&&e)this.select(d);else return})}),d.appendChild(b)}b.appendChild(d),this.container.insertBefore(b,this.input)}}getValue(){return this.tags.join(this.options.delimiter)}setValue(a){Array.prototype.slice.call(this.container.querySelectorAll('.tag')).forEach((a)=>{this.tags.splice(this.tags.indexOf(a.innerHTML),1),this.container.removeChild(a)}),this.savePartial(a)}setInputWidth(){let a=Array.prototype.slice.call(this.container.querySelectorAll('.control')).pop();this.container.offsetWidth&&(this.input.style.width=Math.max(this.container.offsetWidth-(a?a.offsetLeft+a.offsetWidth:30)-30,this.container.offsetWidth/4)+'px')}savePartial(a){'string'==typeof a||Array.isArray(a)||(a=this.input.value),!1!==this.addTag(a)&&(this.input.value='',this.save(),this.setInputWidth())}save(){this.element.value=this.tags.join(this.options.delimiter),this.element.dispatchEvent(new Event('change'))}caretAtStart(a){try{return 0===a.selectionStart&&0===a.selectionEnd}catch(b){return''===a.value}}refocus(a){return(a.target.classList.contains('tag')&&this.select(a.target),a.target===this.input)?this.select():(this.input.focus(),a.preventDefault(),!1)}reset(){this.tags=[]}destroy(){this.disable(),this.reset(),this.element=null}}return c});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"name": "bulma-tagsinput",
"version": "1.0.11",
"version": "1.1.0",
"description": "Bulma.io extension to add interaction on input tags",
"main": "dist/bulma-tagsinput.sass",
"scripts": {
......@@ -22,40 +22,43 @@
"url": "https://github.com/Wikiki/bulma-tagsinput/issues"
},
"homepage": "https://github.com/Wikiki/bulma-tagsinput#readme",
"scripts": {
"build": "gulp"
},
"devDependencies": {
"@babel/core": "^7.0.0-beta.39",
"@babel/preset-env": "^7.0.0-beta.39",
"babel-core": "^7.0.0-beta.3",
"bulma": "^0.6.2",
"camelcase": "^4.1.0",
"conventional-github-releaser": "^2.0.0",
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^4.1.0",
"gulp-babel": "^7.0.1",
"gulp-babel-minify": "^0.3.0",
"gulp-better-rollup": "^3.0.0",
"gulp-bump": "^3.1.0",
"gulp-clean-css": "^3.9.2",
"gulp-concat": "^2.6.1",
"gulp-conventional-changelog": "^1.1.11",
"gulp-git": "^2.5.1",
"gulp-postcss": "^7.0.1",
"gulp-sass": "^3.1.0",
"gulp-sourcemaps": "^2.6.4",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.8",
"rollup-plugin-babel": "^3.0.3",
"run-sequence": "^2.2.1"
"ansi-colors": "^2.0.1",
"babel-core": "latest",
"babel-jest": "latest",
"babel-loader": "latest",
"babel-plugin-transform-object-rest-spread": "latest",
"babel-preset-env": "latest",
"bulma": "latest",
"camelcase": "latest",
"commitizen": "latest",
"cz-conventional-changelog": "latest",
"del": "latest",
"fancy-log": "^1.3.2",
"gulp": "^4.0.0",
"gulp-autoprefixer": "latest",
"gulp-clean-css": "latest",
"gulp-concat": "latest",
"gulp-postcss": "latest",
"gulp-sass": "latest",
"gulp-uglify": "latest",
"husky": "latest",
"jest": "latest",
"regenerator-runtime": "latest",
"rollup": "latest",
"semantic-release": "latest",
"travis-deploy-once": "latest",
"webpack": "latest",
"webpack-stream": "latest"
},
"czConfig": {
"path": "node_modules/cz-conventional-changelog"
},
"files": [
"dist/bulma-tagsinput.sass",
"dist/bulma-tagsinput.min.css",
"dist/bulma-tagsinput.js",
"dist/bulma-tagsinput.min.js",
"dist/css/bulma-tagsinput.sass",
"dist/css/bulma-tagsinput.min.css",
"dist/js/bulma-tagsinput.js",
"dist/js/bulma-tagsinput.min.js",
"LICENSE",
"README.md"
]
......
This diff is collapsed.
const defaultOptions = {
disabled: false,
delimiter: ',',
allowDelete: true,
lowercase: false,
uppercase: false,
duplicates: true
};
export default defaultOptions;
\ No newline at end of file
This diff is collapsed.
export default class EventEmitter {
constructor(listeners = []) {
this._listeners = new Map(listeners);
this._middlewares = new Map();
}
listenerCount(eventName) {
if (!this._listeners.has(eventName)) {
return 0;
}
const eventListeners = this._listeners.get(eventName);
return eventListeners.length;
}
removeListeners(eventName = null, middleware = false) {
if (eventName !== null) {
if (Array.isArray(eventName)) {
name.forEach(e => this.removeListeners(e, middleware));
} else {
this._listeners.delete(eventName);
if (middleware) {
this.removeMiddleware(eventName);
}
}
} else {
this._listeners = new Map();
}
}
middleware(eventName, fn) {
if (Array.isArray(eventName)) {
name.forEach(e => this.middleware(e, fn));
} else {
if (!Array.isArray(this._middlewares.get(eventName))) {
this._middlewares.set(eventName, []);
}
(this._middlewares.get(eventName)).push(fn);
}
}
removeMiddleware(eventName = null) {
if (eventName !== null) {
if (Array.isArray(eventName)) {
name.forEach(e => this.removeMiddleware(e));
} else {
this._middlewares.delete(eventName);
}
} else {
this._middlewares = new Map();
}
}
on(name, callback, once = false) {
if (Array.isArray(name)) {
name.forEach(e => this.on(e, callback));
} else {
name = name.toString();
const split = name.split(/,|, | /);
if (split.length > 1) {
split.forEach(e => this.on(e, callback));
} else {
if (!Array.isArray(this._listeners.get(name))) {
this._listeners.set(name, []);
}
(this._listeners.get(name)).push({once: once, callback: callback});
}
}
}
once(name, callback) {
this.on(name, callback, true);
}
emit(name, data, silent = false) {
name = name.toString();
let listeners = this._listeners.get(name);
let middlewares = null;
let doneCount = 0;
let execute = silent;
if (Array.isArray(listeners)) {
listeners.forEach((listener, index) => {
// Start Middleware checks unless we're doing a silent emit
if (!silent) {
middlewares = this._middlewares.get(name);
// Check and execute Middleware
if (Array.isArray(middlewares)) {
middlewares.forEach(middleware => {
middleware(data, (newData = null) => {
if (newData !== null) {
data = newData;
}
doneCount++;
}, name);
});
if (doneCount >= middlewares.length) {
execute = true;
}
} else {
execute = true;
}
}
// If Middleware checks have been passed, execute
if (execute) {
if (listener.once) {
listeners[index] = null;
}
listener.callback(data);
}
});
// Dirty way of removing used Events
while (listeners.indexOf(null) !== -1) {
listeners.splice(listeners.indexOf(null), 1);
}
}
}
}
export const isString = unknown => (typeof unknown === 'string' || ((!!unknown && typeof unknown === 'object') && Object.prototype.toString.call(unknown) === '[object String]'));
export const isDate = unknown => (Object.prototype.toString.call(unknown) === '[object Date]' || unknown instanceof Date) && !isNaN(unknown.valueOf());
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment