| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms')) :
- typeof define === 'function' && define.amd ? define('angular-dual-listbox', ['exports', '@angular/core', '@angular/common', '@angular/forms'], factory) :
- (global = global || self, factory(global['angular-dual-listbox'] = {}, global.ng.core, global.ng.common, global.ng.forms));
- }(this, function (exports, core, common, forms) { 'use strict';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var BasicList = /** @class */ (function () {
- function BasicList(name) {
- this._name = name;
- this.last = null;
- this.picker = '';
- this.dragStart = false;
- this.dragOver = false;
- // Arrays will contain objects of { _id, _name }.
- this.pick = [];
- this.list = [];
- this.sift = [];
- }
- Object.defineProperty(BasicList.prototype, "name", {
- get: /**
- * @return {?}
- */
- function () {
- return this._name;
- },
- enumerable: true,
- configurable: true
- });
- return BasicList;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- var nextId = 0;
- var DualListComponent = /** @class */ (function () {
- function DualListComponent(differs) {
- this.differs = differs;
- this.id = "dual-list-" + nextId++;
- this.key = '_id';
- this.display = '_name';
- this.height = '100px';
- this.filter = false;
- this.format = DualListComponent.DEFAULT_FORMAT;
- this.sort = false;
- this.disabled = false;
- this.destinationChange = new core.EventEmitter();
- this.sorter = (/**
- * @param {?} a
- * @param {?} b
- * @return {?}
- */
- function (a, b) { return (a._name < b._name) ? -1 : ((a._name > b._name) ? 1 : 0); });
- this.available = new BasicList(DualListComponent.AVAILABLE_LIST_NAME);
- this.confirmed = new BasicList(DualListComponent.CONFIRMED_LIST_NAME);
- }
- /**
- * @param {?} changeRecord
- * @return {?}
- */
- DualListComponent.prototype.ngOnChanges = /**
- * @param {?} changeRecord
- * @return {?}
- */
- function (changeRecord) {
- if (changeRecord['filter']) {
- if (changeRecord['filter'].currentValue === false) {
- this.clearFilter(this.available);
- this.clearFilter(this.confirmed);
- }
- }
- if (changeRecord['sort']) {
- if (changeRecord['sort'].currentValue === true && this.compare === undefined) {
- this.compare = this.sorter;
- }
- else if (changeRecord['sort'].currentValue === false) {
- this.compare = undefined;
- }
- }
- if (changeRecord['format']) {
- this.format = changeRecord['format'].currentValue;
- if (typeof (this.format.direction) === 'undefined') {
- this.format.direction = DualListComponent.LTR;
- }
- if (typeof (this.format.add) === 'undefined') {
- this.format.add = DualListComponent.DEFAULT_FORMAT.add;
- }
- if (typeof (this.format.remove) === 'undefined') {
- this.format.remove = DualListComponent.DEFAULT_FORMAT.remove;
- }
- if (typeof (this.format.all) === 'undefined') {
- this.format.all = DualListComponent.DEFAULT_FORMAT.all;
- }
- if (typeof (this.format.none) === 'undefined') {
- this.format.none = DualListComponent.DEFAULT_FORMAT.none;
- }
- if (typeof (this.format.draggable) === 'undefined') {
- this.format.draggable = DualListComponent.DEFAULT_FORMAT.draggable;
- }
- }
- if (changeRecord['source']) {
- this.available = new BasicList(DualListComponent.AVAILABLE_LIST_NAME);
- this.updatedSource();
- this.updatedDestination();
- }
- if (changeRecord['destination']) {
- this.confirmed = new BasicList(DualListComponent.CONFIRMED_LIST_NAME);
- this.updatedDestination();
- this.updatedSource();
- }
- };
- /**
- * @return {?}
- */
- DualListComponent.prototype.ngDoCheck = /**
- * @return {?}
- */
- function () {
- if (this.source && this.buildAvailable(this.source)) {
- this.onFilter(this.available);
- }
- if (this.destination && this.buildConfirmed(this.destination)) {
- this.onFilter(this.confirmed);
- }
- };
- /**
- * @param {?} source
- * @return {?}
- */
- DualListComponent.prototype.buildAvailable = /**
- * @param {?} source
- * @return {?}
- */
- function (source) {
- var _this = this;
- /** @type {?} */
- var sourceChanges = this.sourceDiffer.diff(source);
- if (sourceChanges) {
- sourceChanges.forEachRemovedItem((/**
- * @param {?} r
- * @return {?}
- */
- function (r) {
- /** @type {?} */
- var idx = _this.findItemIndex(_this.available.list, r.item, _this.key);
- if (idx !== -1) {
- _this.available.list.splice(idx, 1);
- }
- }));
- sourceChanges.forEachAddedItem((/**
- * @param {?} r
- * @return {?}
- */
- function (r) {
- // Do not add duplicates even if source has duplicates.
- if (_this.findItemIndex(_this.available.list, r.item, _this.key) === -1) {
- _this.available.list.push({ _id: _this.makeId(r.item), _name: _this.makeName(r.item) });
- }
- }));
- if (this.compare !== undefined) {
- this.available.list.sort(this.compare);
- }
- this.available.sift = this.available.list;
- return true;
- }
- return false;
- };
- /**
- * @param {?} destination
- * @return {?}
- */
- DualListComponent.prototype.buildConfirmed = /**
- * @param {?} destination
- * @return {?}
- */
- function (destination) {
- var _this = this;
- /** @type {?} */
- var moved = false;
- /** @type {?} */
- var destChanges = this.destinationDiffer.diff(destination);
- if (destChanges) {
- destChanges.forEachRemovedItem((/**
- * @param {?} r
- * @return {?}
- */
- function (r) {
- /** @type {?} */
- var idx = _this.findItemIndex(_this.confirmed.list, r.item, _this.key);
- if (idx !== -1) {
- if (!_this.isItemSelected(_this.confirmed.pick, _this.confirmed.list[idx])) {
- _this.selectItem(_this.confirmed.pick, _this.confirmed.list[idx]);
- }
- _this.moveItem(_this.confirmed, _this.available, _this.confirmed.list[idx], false);
- moved = true;
- }
- }));
- destChanges.forEachAddedItem((/**
- * @param {?} r
- * @return {?}
- */
- function (r) {
- /** @type {?} */
- var idx = _this.findItemIndex(_this.available.list, r.item, _this.key);
- if (idx !== -1) {
- if (!_this.isItemSelected(_this.available.pick, _this.available.list[idx])) {
- _this.selectItem(_this.available.pick, _this.available.list[idx]);
- }
- _this.moveItem(_this.available, _this.confirmed, _this.available.list[idx], false);
- moved = true;
- }
- }));
- if (this.compare !== undefined) {
- this.confirmed.list.sort(this.compare);
- }
- this.confirmed.sift = this.confirmed.list;
- if (moved) {
- this.trueUp();
- }
- return true;
- }
- return false;
- };
- /**
- * @return {?}
- */
- DualListComponent.prototype.updatedSource = /**
- * @return {?}
- */
- function () {
- this.available.list.length = 0;
- this.available.pick.length = 0;
- if (this.source !== undefined) {
- this.sourceDiffer = this.differs.find(this.source).create(null);
- }
- };
- /**
- * @return {?}
- */
- DualListComponent.prototype.updatedDestination = /**
- * @return {?}
- */
- function () {
- if (this.destination !== undefined) {
- this.destinationDiffer = this.differs.find(this.destination).create(null);
- }
- };
- /**
- * @return {?}
- */
- DualListComponent.prototype.direction = /**
- * @return {?}
- */
- function () {
- return this.format.direction === DualListComponent.LTR;
- };
- /**
- * @param {?=} list
- * @return {?}
- */
- DualListComponent.prototype.dragEnd = /**
- * @param {?=} list
- * @return {?}
- */
- function (list) {
- if (list === void 0) { list = null; }
- if (list) {
- list.dragStart = false;
- }
- else {
- this.available.dragStart = false;
- this.confirmed.dragStart = false;
- }
- return false;
- };
- /**
- * @param {?} event
- * @param {?} item
- * @param {?} list
- * @return {?}
- */
- DualListComponent.prototype.drag = /**
- * @param {?} event
- * @param {?} item
- * @param {?} list
- * @return {?}
- */
- function (event, item, list) {
- if (!this.isItemSelected(list.pick, item)) {
- this.selectItem(list.pick, item);
- }
- list.dragStart = true;
- // Set a custom type to be this dual-list's id.
- event.dataTransfer.setData(this.id, item['_id']);
- };
- /**
- * @param {?} event
- * @param {?} list
- * @return {?}
- */
- DualListComponent.prototype.allowDrop = /**
- * @param {?} event
- * @param {?} list
- * @return {?}
- */
- function (event, list) {
- if (event.dataTransfer.types.length && (event.dataTransfer.types[0] === this.id)) {
- event.preventDefault();
- if (!list.dragStart) {
- list.dragOver = true;
- }
- }
- return false;
- };
- /**
- * @return {?}
- */
- DualListComponent.prototype.dragLeave = /**
- * @return {?}
- */
- function () {
- this.available.dragOver = false;
- this.confirmed.dragOver = false;
- };
- /**
- * @param {?} event
- * @param {?} list
- * @return {?}
- */
- DualListComponent.prototype.drop = /**
- * @param {?} event
- * @param {?} list
- * @return {?}
- */
- function (event, list) {
- if (event.dataTransfer.types.length && (event.dataTransfer.types[0] === this.id)) {
- event.preventDefault();
- this.dragLeave();
- this.dragEnd();
- if (list === this.available) {
- this.moveItem(this.available, this.confirmed);
- }
- else {
- this.moveItem(this.confirmed, this.available);
- }
- }
- };
- /**
- * @private
- * @return {?}
- */
- DualListComponent.prototype.trueUp = /**
- * @private
- * @return {?}
- */
- function () {
- var _this = this;
- /** @type {?} */
- var changed = false;
- // Clear removed items.
- /** @type {?} */
- var pos = this.destination.length;
- while ((pos -= 1) >= 0) {
- /** @type {?} */
- var mv = this.confirmed.list.filter((/**
- * @param {?} conf
- * @return {?}
- */
- function (conf) {
- if (typeof _this.destination[pos] === 'object') {
- return conf._id === _this.destination[pos][_this.key];
- }
- else {
- return conf._id === _this.destination[pos];
- }
- }));
- if (mv.length === 0) {
- // Not found so remove.
- this.destination.splice(pos, 1);
- changed = true;
- }
- }
- var _loop_1 = function (i, len) {
- /** @type {?} */
- var mv = this_1.destination.filter((/**
- * @param {?} d
- * @return {?}
- */
- function (d) {
- if (typeof d === 'object') {
- return (d[_this.key] === _this.confirmed.list[i]._id);
- }
- else {
- return (d === _this.confirmed.list[i]._id);
- }
- }));
- if (mv.length === 0) {
- // Not found so add.
- mv = this_1.source.filter((/**
- * @param {?} o
- * @return {?}
- */
- function (o) {
- if (typeof o === 'object') {
- return (o[_this.key] === _this.confirmed.list[i]._id);
- }
- else {
- return (o === _this.confirmed.list[i]._id);
- }
- }));
- if (mv.length > 0) {
- this_1.destination.push(mv[0]);
- changed = true;
- }
- }
- };
- var this_1 = this;
- // Push added items.
- for (var i = 0, len = this.confirmed.list.length; i < len; i += 1) {
- _loop_1(i);
- }
- if (changed) {
- this.destinationChange.emit(this.destination);
- }
- };
- /**
- * @param {?} list
- * @param {?} item
- * @param {?=} key
- * @return {?}
- */
- DualListComponent.prototype.findItemIndex = /**
- * @param {?} list
- * @param {?} item
- * @param {?=} key
- * @return {?}
- */
- function (list, item, key) {
- if (key === void 0) { key = '_id'; }
- /** @type {?} */
- var idx = -1;
- /**
- * @param {?} e
- * @return {?}
- */
- function matchObject(e) {
- if (e._id === item[key]) {
- idx = list.indexOf(e);
- return true;
- }
- return false;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- function match(e) {
- if (e._id === item) {
- idx = list.indexOf(e);
- return true;
- }
- return false;
- }
- // Assumption is that the arrays do not have duplicates.
- if (typeof item === 'object') {
- list.filter(matchObject);
- }
- else {
- list.filter(match);
- }
- return idx;
- };
- /**
- * @private
- * @param {?} source
- * @param {?} item
- * @return {?}
- */
- DualListComponent.prototype.makeUnavailable = /**
- * @private
- * @param {?} source
- * @param {?} item
- * @return {?}
- */
- function (source, item) {
- /** @type {?} */
- var idx = source.list.indexOf(item);
- if (idx !== -1) {
- source.list.splice(idx, 1);
- }
- };
- /**
- * @param {?} source
- * @param {?} target
- * @param {?=} item
- * @param {?=} trueup
- * @return {?}
- */
- DualListComponent.prototype.moveItem = /**
- * @param {?} source
- * @param {?} target
- * @param {?=} item
- * @param {?=} trueup
- * @return {?}
- */
- function (source, target, item, trueup) {
- var _this = this;
- if (item === void 0) { item = null; }
- if (trueup === void 0) { trueup = true; }
- /** @type {?} */
- var i = 0;
- /** @type {?} */
- var len = source.pick.length;
- if (item) {
- i = source.list.indexOf(item);
- len = i + 1;
- }
- var _loop_2 = function () {
- // Is the pick still in list?
- /** @type {?} */
- var mv = [];
- if (item) {
- /** @type {?} */
- var idx = this_2.findItemIndex(source.pick, item);
- if (idx !== -1) {
- mv[0] = source.pick[idx];
- }
- }
- else {
- mv = source.list.filter((/**
- * @param {?} src
- * @return {?}
- */
- function (src) {
- return (src._id === source.pick[i]._id);
- }));
- }
- // Should only ever be 1
- if (mv.length === 1) {
- // Add if not already in target.
- if (target.list.filter((/**
- * @param {?} trg
- * @return {?}
- */
- function (trg) { return trg._id === mv[0]._id; })).length === 0) {
- target.list.push(mv[0]);
- }
- this_2.makeUnavailable(source, mv[0]);
- }
- };
- var this_2 = this;
- for (; i < len; i += 1) {
- _loop_2();
- }
- if (this.compare !== undefined) {
- target.list.sort(this.compare);
- }
- source.pick.length = 0;
- // Update destination
- if (trueup) {
- this.trueUp();
- }
- // Delay ever-so-slightly to prevent race condition.
- setTimeout((/**
- * @return {?}
- */
- function () {
- _this.onFilter(source);
- _this.onFilter(target);
- }), 10);
- };
- /**
- * @param {?} list
- * @param {?} item
- * @return {?}
- */
- DualListComponent.prototype.isItemSelected = /**
- * @param {?} list
- * @param {?} item
- * @return {?}
- */
- function (list, item) {
- if (list.filter((/**
- * @param {?} e
- * @return {?}
- */
- function (e) { return Object.is(e, item); })).length > 0) {
- return true;
- }
- return false;
- };
- /**
- * @param {?} event
- * @param {?} index
- * @param {?} source
- * @param {?} item
- * @return {?}
- */
- DualListComponent.prototype.shiftClick = /**
- * @param {?} event
- * @param {?} index
- * @param {?} source
- * @param {?} item
- * @return {?}
- */
- function (event, index, source, item) {
- if (event.shiftKey && source.last && !Object.is(item, source.last)) {
- /** @type {?} */
- var idx = source.sift.indexOf(source.last);
- if (index > idx) {
- for (var i = (idx + 1); i < index; i += 1) {
- this.selectItem(source.pick, source.sift[i]);
- }
- }
- else if (idx !== -1) {
- for (var i = (index + 1); i < idx; i += 1) {
- this.selectItem(source.pick, source.sift[i]);
- }
- }
- }
- source.last = item;
- };
- /**
- * @param {?} list
- * @param {?} item
- * @return {?}
- */
- DualListComponent.prototype.selectItem = /**
- * @param {?} list
- * @param {?} item
- * @return {?}
- */
- function (list, item) {
- /** @type {?} */
- var pk = list.filter((/**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return Object.is(e, item);
- }));
- if (pk.length > 0) {
- // Already in list, so deselect.
- for (var i = 0, len = pk.length; i < len; i += 1) {
- /** @type {?} */
- var idx = list.indexOf(pk[i]);
- if (idx !== -1) {
- list.splice(idx, 1);
- }
- }
- }
- else {
- list.push(item);
- }
- };
- /**
- * @param {?} source
- * @return {?}
- */
- DualListComponent.prototype.selectAll = /**
- * @param {?} source
- * @return {?}
- */
- function (source) {
- source.pick.length = 0;
- source.pick = source.sift.slice(0);
- };
- /**
- * @param {?} source
- * @return {?}
- */
- DualListComponent.prototype.selectNone = /**
- * @param {?} source
- * @return {?}
- */
- function (source) {
- source.pick.length = 0;
- };
- /**
- * @param {?} source
- * @return {?}
- */
- DualListComponent.prototype.isAllSelected = /**
- * @param {?} source
- * @return {?}
- */
- function (source) {
- if (source.list.length === 0 || source.list.length === source.pick.length) {
- return true;
- }
- return false;
- };
- /**
- * @param {?} source
- * @return {?}
- */
- DualListComponent.prototype.isAnySelected = /**
- * @param {?} source
- * @return {?}
- */
- function (source) {
- if (source.pick.length > 0) {
- return true;
- }
- return false;
- };
- /**
- * @private
- * @param {?} source
- * @return {?}
- */
- DualListComponent.prototype.unpick = /**
- * @private
- * @param {?} source
- * @return {?}
- */
- function (source) {
- for (var i = source.pick.length - 1; i >= 0; i -= 1) {
- if (source.sift.indexOf(source.pick[i]) === -1) {
- source.pick.splice(i, 1);
- }
- }
- };
- /**
- * @param {?} source
- * @return {?}
- */
- DualListComponent.prototype.clearFilter = /**
- * @param {?} source
- * @return {?}
- */
- function (source) {
- if (source) {
- source.picker = '';
- this.onFilter(source);
- }
- };
- /**
- * @param {?} source
- * @return {?}
- */
- DualListComponent.prototype.onFilter = /**
- * @param {?} source
- * @return {?}
- */
- function (source) {
- var _this = this;
- if (source.picker.length > 0) {
- try {
- /** @type {?} */
- var filtered = source.list.filter((/**
- * @param {?} item
- * @return {?}
- */
- function (item) {
- if (Object.prototype.toString.call(item) === '[object Object]') {
- if (item._name !== undefined) {
- // @ts-ignore: remove when d.ts has locale as an argument.
- return item._name.toLocaleLowerCase(_this.format.locale).indexOf(source.picker.toLocaleLowerCase(_this.format.locale)) !== -1;
- }
- else {
- // @ts-ignore: remove when d.ts has locale as an argument.
- return JSON.stringify(item).toLocaleLowerCase(_this.format.locale).indexOf(source.picker.toLocaleLowerCase(_this.format.locale)) !== -1;
- }
- }
- else {
- // @ts-ignore: remove when d.ts has locale as an argument.
- return item.toLocaleLowerCase(_this.format.locale).indexOf(source.picker.toLocaleLowerCase(_this.format.locale)) !== -1;
- }
- }));
- source.sift = filtered;
- this.unpick(source);
- }
- catch (e) {
- if (e instanceof RangeError) {
- this.format.locale = undefined;
- }
- source.sift = source.list;
- }
- }
- else {
- source.sift = source.list;
- }
- };
- /**
- * @private
- * @param {?} item
- * @return {?}
- */
- DualListComponent.prototype.makeId = /**
- * @private
- * @param {?} item
- * @return {?}
- */
- function (item) {
- if (typeof item === 'object') {
- return item[this.key];
- }
- else {
- return item;
- }
- };
- // Allow for complex names by passing an array of strings.
- // Example: [display]="[ '_type.substring(0,1)', '_name' ]"
- // Allow for complex names by passing an array of strings.
- // Example: [display]="[ '_type.substring(0,1)', '_name' ]"
- /**
- * @protected
- * @param {?} item
- * @param {?=} separator
- * @return {?}
- */
- DualListComponent.prototype.makeName =
- // Allow for complex names by passing an array of strings.
- // Example: [display]="[ '_type.substring(0,1)', '_name' ]"
- /**
- * @protected
- * @param {?} item
- * @param {?=} separator
- * @return {?}
- */
- function (item, separator) {
- if (separator === void 0) { separator = '_'; }
- /** @type {?} */
- var display = this.display;
- /**
- * @param {?} itm
- * @return {?}
- */
- function fallback(itm) {
- switch (Object.prototype.toString.call(itm)) {
- case '[object Number]':
- return itm;
- case '[object String]':
- return itm;
- default:
- if (itm !== undefined) {
- return itm[display];
- }
- else {
- return 'undefined';
- }
- }
- }
- /** @type {?} */
- var str = '';
- if (this.display !== undefined) {
- switch (Object.prototype.toString.call(this.display)) {
- case '[object Function]':
- str = this.display(item);
- break;
- case '[object Array]':
- for (var i = 0, len = this.display.length; i < len; i += 1) {
- if (str.length > 0) {
- str = str + separator;
- }
- if (this.display[i].indexOf('.') === -1) {
- // Simple, just add to string.
- str = str + item[this.display[i]];
- }
- else {
- // Complex, some action needs to be performed
- /** @type {?} */
- var parts = this.display[i].split('.');
- /** @type {?} */
- var s = item[parts[0]];
- if (s) {
- // Use brute force
- if (parts[1].indexOf('substring') !== -1) {
- /** @type {?} */
- var nums = (parts[1].substring(parts[1].indexOf('(') + 1, parts[1].indexOf(')'))).split(',');
- switch (nums.length) {
- case 1:
- str = str + s.substring(parseInt(nums[0], 10));
- break;
- case 2:
- str = str + s.substring(parseInt(nums[0], 10), parseInt(nums[1], 10));
- break;
- default:
- str = str + s;
- break;
- }
- }
- else {
- // method not approved, so just add s.
- str = str + s;
- }
- }
- }
- }
- break;
- default:
- str = fallback(item);
- break;
- }
- }
- else {
- str = fallback(item);
- }
- return str;
- };
- DualListComponent.AVAILABLE_LIST_NAME = 'available';
- DualListComponent.CONFIRMED_LIST_NAME = 'confirmed';
- DualListComponent.LTR = 'left-to-right';
- DualListComponent.RTL = 'right-to-left';
- DualListComponent.DEFAULT_FORMAT = {
- add: 'Add',
- remove: 'Remove',
- all: 'All',
- none: 'None',
- direction: DualListComponent.LTR,
- draggable: true,
- locale: undefined
- };
- DualListComponent.decorators = [
- { type: core.Component, args: [{
- selector: 'dual-list',
- template: "<div class=\"dual-list\">\n\t<div class=\"listbox\" [ngStyle]=\"{ 'order' : direction() ? 1 : 2, 'margin-left' : direction() ? 0 : '10px' }\">\n\t\t<button type=\"button\" name=\"addBtn\" class=\"btn btn-primary btn-block\"\n\t\t\t(click)=\"moveItem(available, confirmed)\" [ngClass]=\"direction() ? 'point-right' : 'point-left'\"\n\t\t\t[disabled]=\"available.pick.length === 0\">{{format.add}}</button>\n\n\t\t<form *ngIf=\"filter\" class=\"filter\">\n\t\t\t<input class=\"form-control\" name=\"filterSource\" [(ngModel)]=\"available.picker\" (ngModelChange)=\"onFilter(available)\">\n\t\t</form>\n\n\t\t<div class=\"record-picker\">\n\t\t\t<ul [ngStyle]=\"{'max-height': height, 'min-height': height}\" [ngClass]=\"{over:available.dragOver}\"\n\t\t\t\t(drop)=\"drop($event, confirmed)\" (dragover)=\"allowDrop($event, available)\" (dragleave)=\"dragLeave()\">\n\t\t\t\t<li *ngFor=\"let item of available.sift; let idx=index;\"\n\t\t\t\t\t(click)=\"disabled ? null : selectItem(available.pick, item); shiftClick($event, idx, available, item)\"\n\t\t\t\t\t[ngClass]=\"{selected: isItemSelected(available.pick, item), disabled: disabled}\"\n\t\t\t\t\t[draggable]=\"!disabled && format.draggable\" (dragstart)=\"drag($event, item, available)\" (dragend)=\"dragEnd(available)\"\n\t\t\t\t><label>{{item._name}}</label></li>\n\t\t\t</ul>\n\t\t</div>\n\n\t\t<div class=\"button-bar\">\n\t\t\t<button type=\"button\" class=\"btn btn-primary pull-left\" (click)=\"selectAll(available)\"\n\t\t\t\t[disabled]=\"disabled || isAllSelected(available)\">{{format.all}}</button>\n\t\t\t<button type=\"button\" class=\"btn btn-default pull-right\" (click)=\"selectNone(available)\"\n\t\t\t\t[disabled]=\"!isAnySelected(available)\">{{format.none}}</button>\n\t\t</div>\n\t</div>\n\n\t<div class=\"listbox\" [ngStyle]=\"{ 'order' : direction() ? 2 : 1, 'margin-left' : direction() ? '10px' : 0 }\">\n\t\t<button type=\"button\" name=\"removeBtn\" class=\"btn btn-primary btn-block\"\n\t\t\t(click)=\"moveItem(confirmed, available)\" [ngClass]=\"direction() ? 'point-left' : 'point-right'\"\n\t\t\t[disabled]=\"confirmed.pick.length === 0\">{{format.remove}}</button>\n\n\t\t<form *ngIf=\"filter\" class=\"filter\">\n\t\t\t<input class=\"form-control\" name=\"filterDestination\" [(ngModel)]=\"confirmed.picker\" (ngModelChange)=\"onFilter(confirmed)\">\n\t\t</form>\n\n\t\t<div class=\"record-picker\">\n\t\t\t<ul [ngStyle]=\"{'max-height': height, 'min-height': height}\" [ngClass]=\"{over:confirmed.dragOver}\"\n\t\t\t\t(drop)=\"drop($event, available)\" (dragover)=\"allowDrop($event, confirmed)\" (dragleave)=\"dragLeave()\">\n\t\t\t\t<li #itmConf *ngFor=\"let item of confirmed.sift; let idx=index;\"\n\t\t\t\t\t(click)=\"disabled ? null : selectItem(confirmed.pick, item); shiftClick($event, idx, confirmed, item)\"\n\t\t\t\t\t[ngClass]=\"{selected: isItemSelected(confirmed.pick, item), disabled: disabled}\"\n\t\t\t\t\t[draggable]=\"!disabled && format.draggable\" (dragstart)=\"drag($event, item, confirmed)\" (dragend)=\"dragEnd(confirmed)\"\n\t\t\t\t><label>{{item._name}}</label></li>\n\t\t\t</ul>\n\t\t</div>\n\n\t\t<div class=\"button-bar\">\n\t\t\t<button type=\"button\" class=\"btn btn-primary pull-left\" (click)=\"selectAll(confirmed)\"\n\t\t\t\t[disabled]=\"disabled || isAllSelected(confirmed)\">{{format.all}}</button>\n\t\t\t<button type=\"button\" class=\"btn btn-default pull-right\" (click)=\"selectNone(confirmed)\"\n\t\t\t\t[disabled]=\"!isAnySelected(confirmed)\">{{format.none}}</button>\n\t\t</div>\n\t</div>\n</div>\n",
- styles: ["div.record-picker{overflow-x:hidden;overflow-y:auto;border:1px solid #ddd;border-radius:8px;position:relative;cursor:pointer;scrollbar-base-color:#337ab7;scrollbar-3dlight-color:#337ab7;scrollbar-highlight-color:#337ab7;scrollbar-track-color:#eee;scrollbar-arrow-color:gray;scrollbar-shadow-color:gray;scrollbar-dark-shadow-color:gray}div.record-picker::-webkit-scrollbar{width:12px}div.record-picker::-webkit-scrollbar-button{width:0;height:0}div.record-picker::-webkit-scrollbar-track{background:#eee;box-shadow:0 0 3px #dfdfdf inset;border-top-right-radius:8px;border-bottom-right-radius:8px}div.record-picker::-webkit-scrollbar-thumb{background:#337ab7;border:thin solid gray;border-top-right-radius:8px;border-bottom-right-radius:8px}div.record-picker::-webkit-scrollbar-thumb:hover{background:#286090}.record-picker ul{margin:0;padding:0 0 1px}.record-picker li{border-top:thin solid #ddd;border-bottom:1px solid #ddd;display:block;padding:2px 2px 2px 10px;margin-bottom:-1px;font-size:.85em;cursor:pointer;white-space:nowrap;min-height:16px}.record-picker li:hover{background-color:#f5f5f5}.record-picker li.selected{background-color:#d9edf7}.record-picker li.selected:hover{background-color:#c4e3f3}.record-picker li.disabled{opacity:.5;cursor:default;background-color:inherit}.record-picker li:first-child{border-top-left-radius:8px;border-top-right-radius:8px;border-top:none}.record-picker li:last-child{border-bottom-left-radius:8px;border-bottom-right-radius:8px;border-bottom:none}.record-picker label{cursor:pointer;font-weight:inherit;font-size:14px;padding:4px;margin-bottom:-1px;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.record-picker ul.over{background-color:#d3d3d3}.dual-list{display:flex;flex-direction:row;align-content:flex-start}.dual-list .listbox{width:50%;margin:0}.dual-list .button-bar{margin-top:8px}.point-right::after{content:\"\\25B6\";padding-left:1em}.point-left::before{content:\"\\25C0\";padding-right:1em}.dual-list .button-bar button{width:47%}button.btn-block{display:block;width:100%;margin-bottom:8px}.filter{margin-bottom:-2.2em}.filter::after{content:\"o\";width:40px;color:transparent;font-size:2em;background-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path d=\"M0 64l192 192v192l128-32V256L512 64H0z\"/></svg>');background-repeat:no-repeat;background-position:center center;opacity:.2;top:-36px;left:calc(100% - 21px);position:relative}"]
- }] }
- ];
- /** @nocollapse */
- DualListComponent.ctorParameters = function () { return [
- { type: core.IterableDiffers }
- ]; };
- DualListComponent.propDecorators = {
- id: [{ type: core.Input }],
- key: [{ type: core.Input }],
- display: [{ type: core.Input }],
- height: [{ type: core.Input }],
- filter: [{ type: core.Input }],
- format: [{ type: core.Input }],
- sort: [{ type: core.Input }],
- compare: [{ type: core.Input }],
- disabled: [{ type: core.Input }],
- source: [{ type: core.Input }],
- destination: [{ type: core.Input }],
- destinationChange: [{ type: core.Output }]
- };
- return DualListComponent;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var AngularDualListBoxModule = /** @class */ (function () {
- function AngularDualListBoxModule() {
- }
- AngularDualListBoxModule.decorators = [
- { type: core.NgModule, args: [{
- imports: [
- common.CommonModule,
- forms.FormsModule
- ],
- declarations: [DualListComponent],
- exports: [DualListComponent]
- },] }
- ];
- return AngularDualListBoxModule;
- }());
- exports.AngularDualListBoxModule = AngularDualListBoxModule;
- exports.BasicList = BasicList;
- exports.DualListComponent = DualListComponent;
- Object.defineProperty(exports, '__esModule', { value: true });
- }));
- //# sourceMappingURL=angular-dual-listbox.umd.js.map
|