From 2fa92520ef88f3d27dedbe03d6c8a85d27561637 Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Tue, 12 Mar 2019 20:27:54 +0000 Subject: [PATCH 01/16] Updated Choices.js Fixes scrollbar issue in IE11. There is an EDGE-CASE where-by if a user were to select the same option twice, the dropdown doesn't go away. This is, however a very extreme case and we are on the right track --- src/scripts/choices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/choices.js b/src/scripts/choices.js index 24b028b..f334638 100644 --- a/src/scripts/choices.js +++ b/src/scripts/choices.js @@ -1386,7 +1386,7 @@ class Choices { _onMouseDown(event) { const { target, shiftKey } = event; // If we have our mouse down on the scrollbar and are on IE11... - if (target === this.choiceList && isIE11()) { + if (this.choiceList.element.contains(target) && isIE11()) { this._isScrollingOnIe = true; } From f9f63e7aba64099989672b1b813b130461b16507 Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Thu, 14 Mar 2019 11:23:12 +0000 Subject: [PATCH 02/16] Fix for the webpack issue export choices as a class to circumvent the webpack issue --- src/scripts/choices.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/scripts/choices.js b/src/scripts/choices.js index f334638..a8430d1 100644 --- a/src/scripts/choices.js +++ b/src/scripts/choices.js @@ -43,7 +43,7 @@ import { * Choices * @author Josh Johnson */ -class Choices { +export class Choices { constructor(element = '[data-choice]', userConfig = {}) { if (isType('String', element)) { const elements = Array.from(document.querySelectorAll(element)); @@ -2083,5 +2083,3 @@ class Choices { } Choices.userDefaults = {}; -// We cannot export default here due to Webpack: https://github.com/webpack/webpack/issues/3929 -module.exports = Choices; From 6486bbbd6de3365899af1ccee3f945bd074e0ae0 Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Thu, 14 Mar 2019 11:23:57 +0000 Subject: [PATCH 03/16] Updated tests to reflect changes to choices.js --- src/scripts/choices.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/choices.test.js b/src/scripts/choices.test.js index 12c21fa..03fb90c 100644 --- a/src/scripts/choices.test.js +++ b/src/scripts/choices.test.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { spy, stub } from 'sinon'; -import Choices from './choices'; +import { Choices } from './choices'; import { EVENTS, ACTION_TYPES } from './constants'; describe('choices', () => { From b1005061ff8bce3b8bca95da45aa1131c9fdb6bc Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Thu, 14 Mar 2019 11:44:46 +0000 Subject: [PATCH 04/16] Changed reference to Choices Because I have attempted to fix the WebPack issue with choices, I need to change how it is referenced --- src/scripts/reducers/choices.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/reducers/choices.test.js b/src/scripts/reducers/choices.test.js index 9563f6c..375a15a 100644 --- a/src/scripts/reducers/choices.test.js +++ b/src/scripts/reducers/choices.test.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import choices, { defaultState } from './choices'; +import { choices, defaultState } from './choices'; describe('reducers/choices', () => { it('should return same state when no action matches', () => { From cc32284e8a057b80c306f2596a4c6cc5973f10dd Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Thu, 14 Mar 2019 11:46:39 +0000 Subject: [PATCH 05/16] Updated reference to choices Because I have attempted to fix the WebPack issue with choices, I need to change how it is referenced --- src/scripts/reducers/index.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/reducers/index.test.js b/src/scripts/reducers/index.test.js index c662cc8..d35cdde 100644 --- a/src/scripts/reducers/index.test.js +++ b/src/scripts/reducers/index.test.js @@ -2,7 +2,7 @@ import { createStore } from 'redux'; import { expect } from 'chai'; import rootReducer from './index'; import groups from './groups'; -import choices from './choices'; +import { choices } from './choices'; import items from './items'; describe('reducers/rootReducer', () => { From 5018e4a7d4dc8ee017823151459c121d1cc1481a Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Thu, 14 Mar 2019 11:47:11 +0000 Subject: [PATCH 06/16] Updated reference to choices Because I have attempted to fix the WebPack issue with choices, I need to change how it is referenced --- src/scripts/reducers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/reducers/index.js b/src/scripts/reducers/index.js index 31dc7b3..a3fced6 100644 --- a/src/scripts/reducers/index.js +++ b/src/scripts/reducers/index.js @@ -1,7 +1,7 @@ import { combineReducers } from 'redux'; import items from './items'; import groups from './groups'; -import choices from './choices'; +import { choices } from './choices'; import general from './general'; import { cloneObject } from '../lib/utils'; From 2247eff08a8371fbb3938522a830d0c8c45ba8fc Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Thu, 14 Mar 2019 12:03:22 +0000 Subject: [PATCH 07/16] Added linting exclusion for WebPack --- src/scripts/choices.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scripts/choices.js b/src/scripts/choices.js index a8430d1..57233fc 100644 --- a/src/scripts/choices.js +++ b/src/scripts/choices.js @@ -1,3 +1,4 @@ +/* eslint-disable import/prefer-default-export */ import Fuse from 'fuse.js'; import merge from 'deepmerge'; From da87fa07cfc45d1f674ff047629a827152299bdc Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Thu, 14 Mar 2019 12:13:06 +0000 Subject: [PATCH 08/16] Update choices.test.js --- src/scripts/reducers/choices.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/reducers/choices.test.js b/src/scripts/reducers/choices.test.js index 375a15a..9563f6c 100644 --- a/src/scripts/reducers/choices.test.js +++ b/src/scripts/reducers/choices.test.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { choices, defaultState } from './choices'; +import choices, { defaultState } from './choices'; describe('reducers/choices', () => { it('should return same state when no action matches', () => { From 92680c0dc065692b2fb9d50649ddfb1ee5f4de37 Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Thu, 14 Mar 2019 12:20:43 +0000 Subject: [PATCH 09/16] Update index.js --- src/scripts/reducers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/reducers/index.js b/src/scripts/reducers/index.js index a3fced6..31dc7b3 100644 --- a/src/scripts/reducers/index.js +++ b/src/scripts/reducers/index.js @@ -1,7 +1,7 @@ import { combineReducers } from 'redux'; import items from './items'; import groups from './groups'; -import { choices } from './choices'; +import choices from './choices'; import general from './general'; import { cloneObject } from '../lib/utils'; From 03a45094b7316c31eaf937bc6f7b6259064b7aa9 Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Thu, 14 Mar 2019 12:31:29 +0000 Subject: [PATCH 10/16] Update index.test.js --- src/scripts/reducers/index.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/reducers/index.test.js b/src/scripts/reducers/index.test.js index d35cdde..c662cc8 100644 --- a/src/scripts/reducers/index.test.js +++ b/src/scripts/reducers/index.test.js @@ -2,7 +2,7 @@ import { createStore } from 'redux'; import { expect } from 'chai'; import rootReducer from './index'; import groups from './groups'; -import { choices } from './choices'; +import choices from './choices'; import items from './items'; describe('reducers/rootReducer', () => { From aceb838988d8b4ed05a3a05dfe0b9ae0408f4581 Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Fri, 15 Mar 2019 16:57:35 +0000 Subject: [PATCH 11/16] Rolled back webpack changes in Choices.js --- src/scripts/choices.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scripts/choices.js b/src/scripts/choices.js index 57233fc..f334638 100644 --- a/src/scripts/choices.js +++ b/src/scripts/choices.js @@ -1,4 +1,3 @@ -/* eslint-disable import/prefer-default-export */ import Fuse from 'fuse.js'; import merge from 'deepmerge'; @@ -44,7 +43,7 @@ import { * Choices * @author Josh Johnson */ -export class Choices { +class Choices { constructor(element = '[data-choice]', userConfig = {}) { if (isType('String', element)) { const elements = Array.from(document.querySelectorAll(element)); @@ -2084,3 +2083,5 @@ export class Choices { } Choices.userDefaults = {}; +// We cannot export default here due to Webpack: https://github.com/webpack/webpack/issues/3929 +module.exports = Choices; From 9c021408fa5f55bfe46dda970dc9835a07464713 Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Fri, 15 Mar 2019 16:57:57 +0000 Subject: [PATCH 12/16] Update choices.test.js --- src/scripts/choices.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/choices.test.js b/src/scripts/choices.test.js index 03fb90c..12c21fa 100644 --- a/src/scripts/choices.test.js +++ b/src/scripts/choices.test.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { spy, stub } from 'sinon'; -import { Choices } from './choices'; +import Choices from './choices'; import { EVENTS, ACTION_TYPES } from './constants'; describe('choices', () => { From 201b3c8adae4236245b296c9a07108ae781f4140 Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Fri, 15 Mar 2019 17:17:43 +0000 Subject: [PATCH 13/16] Updated version numbers --- public/test/select-multiple.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/test/select-multiple.html b/public/test/select-multiple.html index e860d20..30e076d 100644 --- a/public/test/select-multiple.html +++ b/public/test/select-multiple.html @@ -16,12 +16,12 @@ - + - - + + From f32995367b74e92a3814c964ae87a5b614d371aa Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Fri, 15 Mar 2019 17:18:23 +0000 Subject: [PATCH 14/16] Update select-one.html --- public/test/select-one.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/test/select-one.html b/public/test/select-one.html index de37a75..54657f0 100644 --- a/public/test/select-one.html +++ b/public/test/select-one.html @@ -16,12 +16,12 @@ - + - - + + From b08a5412f927aab39e7e578b03bd3dec3cd55345 Mon Sep 17 00:00:00 2001 From: Darren Mackintosh Date: Fri, 15 Mar 2019 17:18:58 +0000 Subject: [PATCH 15/16] Update text.html --- public/test/text.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/test/text.html b/public/test/text.html index 1d4ea24..f2e8003 100644 --- a/public/test/text.html +++ b/public/test/text.html @@ -16,12 +16,12 @@ - + - - + + From 63e5b516836dc94b47c20b52f1253a4da5864a17 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Fri, 29 Mar 2019 09:08:42 +0000 Subject: [PATCH 16/16] Update polyfill url --- public/assets/scripts/choices.js | 16 ++++++++-------- public/assets/scripts/choices.min.js | 10 +++++----- public/index.html | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/public/assets/scripts/choices.js b/public/assets/scripts/choices.js index bf1497b..5ed80b5 100644 --- a/public/assets/scripts/choices.js +++ b/public/assets/scripts/choices.js @@ -2114,13 +2114,13 @@ function () { var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; var replaceChoices = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; - if (!this._isSelectElement || !choices.length || !value) { + if (!this._isSelectElement || !value) { return this; } // Clear choices if needed if (replaceChoices) { - this._clearChoices(); + this.clearChoices(); } this.containerOuter.removeLoadingState(); @@ -2153,6 +2153,11 @@ function () { return this; } + }, { + key: "clearChoices", + value: function clearChoices() { + this._store.dispatch((0, _choices.clearChoices)()); + } }, { key: "clearStore", value: function clearStore() { @@ -3096,7 +3101,7 @@ function () { var target = event.target, shiftKey = event.shiftKey; // If we have our mouse down on the scrollbar and are on IE11... - if (target === this.choiceList && (0, _utils.isIE11)()) { + if (this.choiceList.element.contains(target) && (0, _utils.isIE11)()) { this._isScrollingOnIe = true; } @@ -3451,11 +3456,6 @@ function () { }); } } - }, { - key: "_clearChoices", - value: function _clearChoices() { - this._store.dispatch((0, _choices.clearChoices)()); - } }, { key: "_addGroup", value: function _addGroup(_ref15) { diff --git a/public/assets/scripts/choices.min.js b/public/assets/scripts/choices.min.js index 2f3baf0..674c639 100644 --- a/public/assets/scripts/choices.min.js +++ b/public/assets/scripts/choices.min.js @@ -1,5 +1,5 @@ -/*! choices.js v6.0.3 | (c) 2019 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Choices=t():e.Choices=t()}(window,function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/public/assets/scripts/",i(i.s=9)}([function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.cloneObject=t.existsInArray=t.isIE11=t.fetchFromObject=t.getWindowHeight=t.dispatchEvent=t.sortByScore=t.sortByAlpha=t.calcWidthOfInput=t.strToEl=t.sanitise=t.isScrolledIntoView=t.getAdjacentEl=t.findAncestorByAttrName=t.wrap=t.isElement=t.isType=t.getType=t.generateId=t.generateChars=t.getRandomNumber=void 0;var n=function(e,t){return Math.floor(Math.random()*(t-e)+e)};t.getRandomNumber=n;var r=function(e){for(var t="",i=0;i1&&void 0!==arguments[1]?arguments[1]:document.createElement("div");return e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t),t.appendChild(e)};t.findAncestorByAttrName=function(e,t){for(var i=e;i;){if(i.hasAttribute(t))return i;i=i.parentElement}return null};t.getAdjacentEl=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e&&t){var n=e.parentNode.parentNode,r=Array.from(n.querySelectorAll(t)),o=r.indexOf(e);return r[o+(i>0?1:-1)]}};t.isScrolledIntoView=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e)return i>0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop};var a=function(e){return s("String",e)?e.replace(/&/g,"&").replace(/>/g,"&rt;").replace(/".concat(a(i),""));if(r.style.position="absolute",r.style.padding="0",r.style.top="-9999px",r.style.left="-9999px",r.style.width="auto",r.style.whiteSpace="pre",document.body.contains(e)&&window.getComputedStyle){var o=window.getComputedStyle(e);o&&(r.style.fontSize=o.fontSize,r.style.fontFamily=o.fontFamily,r.style.fontWeight=o.fontWeight,r.style.fontStyle=o.fontStyle,r.style.letterSpacing=o.letterSpacing,r.style.textTransform=o.textTransform,r.style.padding=o.padding)}document.body.appendChild(r),requestAnimationFrame(function(){i&&r.offsetWidth!==e.offsetWidth&&(n=r.offsetWidth+4),document.body.removeChild(r),t.call(void 0,"".concat(n,"px"))})}else t.call(void 0,"".concat(n,"px"))};t.sortByAlpha=function(e,t){var i="".concat(e.label||e.value).toLowerCase(),n="".concat(t.label||t.value).toLowerCase();return in?1:0};t.sortByScore=function(e,t){return e.score-t.score};t.dispatchEvent=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=new CustomEvent(t,{detail:i,bubbles:!0,cancelable:!0});return e.dispatchEvent(n)};t.getWindowHeight=function(){var e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)};t.fetchFromObject=function e(t,i){var n=i.indexOf(".");return n>-1?e(t[i.substring(0,n)],i.substr(n+1)):t[i]};t.isIE11=function(){return!(!navigator.userAgent.match(/Trident/)||!navigator.userAgent.match(/rv[ :]11/))};t.existsInArray=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"value";return e.some(function(e){return s("String",t)?e[i]===t.trim():e[i]===t})};t.cloneObject=function(e){return JSON.parse(JSON.stringify(e))};t.diff=function(e,t){var i=Object.keys(e).sort(),n=Object.keys(t).sort();return i.filter(function(e){return n.indexOf(e)<0})}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SCROLLING_SPEED=t.KEY_CODES=t.ACTION_TYPES=t.EVENTS=t.DEFAULT_CONFIG=t.DEFAULT_CLASSNAMES=void 0;var n=i(0),r={containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemChoice:"choices__item--choice",placeholder:"choices__placeholder",group:"choices__group",groupHeading:"choices__heading",button:"choices__button",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",hiddenState:"is-hidden",flippedState:"is-flipped",loadingState:"is-loading",noResults:"has-no-results",noChoices:"has-no-choices"};t.DEFAULT_CLASSNAMES=r;var o={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,addItems:!0,addItemFilterFn:null,removeItems:!0,removeItemButton:!1,editItems:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sortFn:n.sortByAlpha,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat((0,n.sanitise)(e),'"')},maxItemText:function(e){return"Only ".concat(e," values can be added")},itemComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},callbackOnInit:null,callbackOnCreateTemplates:null,classNames:r};t.DEFAULT_CONFIG=o;t.EVENTS={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice"};t.ACTION_TYPES={ADD_CHOICE:"ADD_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM",CLEAR_ALL:"CLEAR_ALL"};t.KEY_CODES={BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34};t.SCROLLING_SPEED=4},function(e,t,i){"use strict";(function(e,n){var r,o=i(7);r="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e?e:n;var s=Object(o.a)(r);t.a=s}).call(this,i(3),i(16)(e))},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i(0);function r(e,t){for(var i=0;i