UNPKG

coveo-search-ui

Version:

Coveo JavaScript Search Framework

1,266 lines (1,093 loc) • 800 kB
webpackJsonpCoveo__temporary([13,3],{ /***/ 131: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ResponsiveDropdownContent_1 = __webpack_require__(94); var ResponsiveComponentsUtils = /** @class */ (function () { function ResponsiveComponentsUtils() { } ResponsiveComponentsUtils.shouldDrawFacetSlider = function (root, facetSliderElement) { return ResponsiveDropdownContent_1.ResponsiveDropdownContent.isTargetInsideOpenedDropdown(facetSliderElement) || !this.isSmallFacetActivated(root); }; ResponsiveComponentsUtils.isSmallTabsActivated = function (root) { return root.hasClass(this.smallTabsClassName); }; ResponsiveComponentsUtils.isSmallFacetActivated = function (root) { return root.hasClass(this.smallFacetClassName); }; ResponsiveComponentsUtils.isSmallRecommendationActivated = function (root) { return root.hasClass(this.smallRecommendationClassName); }; ResponsiveComponentsUtils.activateSmallTabs = function (root) { root.addClass(this.smallTabsClassName); }; ResponsiveComponentsUtils.deactivateSmallTabs = function (root) { root.removeClass(this.smallTabsClassName); }; ResponsiveComponentsUtils.activateSmallFacet = function (root) { root.addClass(this.smallFacetClassName); }; ResponsiveComponentsUtils.deactivateSmallFacet = function (root) { root.removeClass(this.smallFacetClassName); }; ResponsiveComponentsUtils.activateSmallRecommendation = function (root) { root.addClass(this.smallRecommendationClassName); }; ResponsiveComponentsUtils.deactivateSmallRecommendation = function (root) { root.removeClass(this.smallRecommendationClassName); }; ResponsiveComponentsUtils.smallTabsClassName = 'coveo-small-tabs'; ResponsiveComponentsUtils.smallFacetClassName = 'coveo-small-facets'; ResponsiveComponentsUtils.smallRecommendationClassName = 'coveo-small-recommendation'; return ResponsiveComponentsUtils; }()); exports.ResponsiveComponentsUtils = ResponsiveComponentsUtils; /***/ }), /***/ 187: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // CONCATENATED MODULE: ./node_modules/d3-collection/src/map.js var prefix = "$"; function Map() {} Map.prototype = map.prototype = { constructor: Map, has: function(key) { return (prefix + key) in this; }, get: function(key) { return this[prefix + key]; }, set: function(key, value) { this[prefix + key] = value; return this; }, remove: function(key) { var property = prefix + key; return property in this && delete this[property]; }, clear: function() { for (var property in this) if (property[0] === prefix) delete this[property]; }, keys: function() { var keys = []; for (var property in this) if (property[0] === prefix) keys.push(property.slice(1)); return keys; }, values: function() { var values = []; for (var property in this) if (property[0] === prefix) values.push(this[property]); return values; }, entries: function() { var entries = []; for (var property in this) if (property[0] === prefix) entries.push({key: property.slice(1), value: this[property]}); return entries; }, size: function() { var size = 0; for (var property in this) if (property[0] === prefix) ++size; return size; }, empty: function() { for (var property in this) if (property[0] === prefix) return false; return true; }, each: function(f) { for (var property in this) if (property[0] === prefix) f(this[property], property.slice(1), this); } }; function map(object, f) { var map = new Map; // Copy constructor. if (object instanceof Map) object.each(function(value, key) { map.set(key, value); }); // Index array by numeric index or specified key function. else if (Array.isArray(object)) { var i = -1, n = object.length, o; if (f == null) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f(o = object[i], i, object), o); } // Convert object to map. else if (object) for (var key in object) map.set(key, object[key]); return map; } /* harmony default export */ var src_map = (map); // CONCATENATED MODULE: ./node_modules/d3-collection/src/nest.js /* harmony default export */ var src_nest = (function() { var keys = [], sortKeys = [], sortValues, rollup, nest; function apply(array, depth, createResult, setResult) { if (depth >= keys.length) { if (sortValues != null) array.sort(sortValues); return rollup != null ? rollup(array) : array; } var i = -1, n = array.length, key = keys[depth++], keyValue, value, valuesByKey = src_map(), values, result = createResult(); while (++i < n) { if (values = valuesByKey.get(keyValue = key(value = array[i]) + "")) { values.push(value); } else { valuesByKey.set(keyValue, [value]); } } valuesByKey.each(function(values, key) { setResult(result, key, apply(values, depth, createResult, setResult)); }); return result; } function entries(map, depth) { if (++depth > keys.length) return map; var array, sortKey = sortKeys[depth - 1]; if (rollup != null && depth >= keys.length) array = map.entries(); else array = [], map.each(function(v, k) { array.push({key: k, values: entries(v, depth)}); }); return sortKey != null ? array.sort(function(a, b) { return sortKey(a.key, b.key); }) : array; } return nest = { object: function(array) { return apply(array, 0, createObject, setObject); }, map: function(array) { return apply(array, 0, createMap, setMap); }, entries: function(array) { return entries(apply(array, 0, createMap, setMap), 0); }, key: function(d) { keys.push(d); return nest; }, sortKeys: function(order) { sortKeys[keys.length - 1] = order; return nest; }, sortValues: function(order) { sortValues = order; return nest; }, rollup: function(f) { rollup = f; return nest; } }; }); function createObject() { return {}; } function setObject(object, key, value) { object[key] = value; } function createMap() { return src_map(); } function setMap(map, key, value) { map.set(key, value); } // CONCATENATED MODULE: ./node_modules/d3-collection/src/set.js function Set() {} var proto = src_map.prototype; Set.prototype = set.prototype = { constructor: Set, has: proto.has, add: function(value) { value += ""; this[prefix + value] = value; return this; }, remove: proto.remove, clear: proto.clear, values: proto.keys, size: proto.size, empty: proto.empty, each: proto.each }; function set(object, f) { var set = new Set; // Copy constructor. if (object instanceof Set) object.each(function(value) { set.add(value); }); // Otherwise, assume it’s an array. else if (object) { var i = -1, n = object.length; if (f == null) while (++i < n) set.add(object[i]); else while (++i < n) set.add(f(object[i], i, object)); } return set; } /* harmony default export */ var src_set = (set); // CONCATENATED MODULE: ./node_modules/d3-collection/src/keys.js /* harmony default export */ var src_keys = (function(map) { var keys = []; for (var key in map) keys.push(key); return keys; }); // CONCATENATED MODULE: ./node_modules/d3-collection/src/values.js /* harmony default export */ var src_values = (function(map) { var values = []; for (var key in map) values.push(map[key]); return values; }); // CONCATENATED MODULE: ./node_modules/d3-collection/src/entries.js /* harmony default export */ var src_entries = (function(map) { var entries = []; for (var key in map) entries.push({key: key, value: map[key]}); return entries; }); // CONCATENATED MODULE: ./node_modules/d3-collection/src/index.js /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "d", function() { return src_nest; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "e", function() { return src_set; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "c", function() { return src_map; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "b", function() { return src_keys; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "f", function() { return src_values; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "a", function() { return src_entries; }); /***/ }), /***/ 188: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // CONCATENATED MODULE: ./node_modules/d3-time/src/interval.js var t0 = new Date, t1 = new Date; function newInterval(floori, offseti, count, field) { function interval(date) { return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; } interval.floor = function(date) { return floori(date = new Date(+date)), date; }; interval.ceil = function(date) { return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; }; interval.round = function(date) { var d0 = interval(date), d1 = interval.ceil(date); return date - d0 < d1 - date ? d0 : d1; }; interval.offset = function(date, step) { return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; }; interval.range = function(start, stop, step) { var range = [], previous; start = interval.ceil(start); step = step == null ? 1 : Math.floor(step); if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date do range.push(previous = new Date(+start)), offseti(start, step), floori(start); while (previous < start && start < stop); return range; }; interval.filter = function(test) { return newInterval(function(date) { if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); }, function(date, step) { if (date >= date) { if (step < 0) while (++step <= 0) { while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty } else while (--step >= 0) { while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty } } }); }; if (count) { interval.count = function(start, end) { t0.setTime(+start), t1.setTime(+end); floori(t0), floori(t1); return Math.floor(count(t0, t1)); }; interval.every = function(step) { step = Math.floor(step); return !isFinite(step) || !(step > 0) ? null : !(step > 1) ? interval : interval.filter(field ? function(d) { return field(d) % step === 0; } : function(d) { return interval.count(0, d) % step === 0; }); }; } return interval; } // CONCATENATED MODULE: ./node_modules/d3-time/src/millisecond.js var millisecond = newInterval(function() { // noop }, function(date, step) { date.setTime(+date + step); }, function(start, end) { return end - start; }); // An optimized implementation for this simple case. millisecond.every = function(k) { k = Math.floor(k); if (!isFinite(k) || !(k > 0)) return null; if (!(k > 1)) return millisecond; return newInterval(function(date) { date.setTime(Math.floor(date / k) * k); }, function(date, step) { date.setTime(+date + step * k); }, function(start, end) { return (end - start) / k; }); }; /* harmony default export */ var src_millisecond = (millisecond); var milliseconds = millisecond.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/duration.js var durationSecond = 1e3; var durationMinute = 6e4; var durationHour = 36e5; var durationDay = 864e5; var durationWeek = 6048e5; // CONCATENATED MODULE: ./node_modules/d3-time/src/second.js var second = newInterval(function(date) { date.setTime(date - date.getMilliseconds()); }, function(date, step) { date.setTime(+date + step * durationSecond); }, function(start, end) { return (end - start) / durationSecond; }, function(date) { return date.getUTCSeconds(); }); /* harmony default export */ var src_second = (second); var seconds = second.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/minute.js var minute = newInterval(function(date) { date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); }, function(date, step) { date.setTime(+date + step * durationMinute); }, function(start, end) { return (end - start) / durationMinute; }, function(date) { return date.getMinutes(); }); /* harmony default export */ var src_minute = (minute); var minutes = minute.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/hour.js var hour = newInterval(function(date) { date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); }, function(date, step) { date.setTime(+date + step * durationHour); }, function(start, end) { return (end - start) / durationHour; }, function(date) { return date.getHours(); }); /* harmony default export */ var src_hour = (hour); var hours = hour.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/day.js var day = newInterval(function(date) { date.setHours(0, 0, 0, 0); }, function(date, step) { date.setDate(date.getDate() + step); }, function(start, end) { return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay; }, function(date) { return date.getDate() - 1; }); /* harmony default export */ var src_day = (day); var days = day.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/week.js function weekday(i) { return newInterval(function(date) { date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); date.setHours(0, 0, 0, 0); }, function(date, step) { date.setDate(date.getDate() + step * 7); }, function(start, end) { return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; }); } var sunday = weekday(0); var monday = weekday(1); var tuesday = weekday(2); var wednesday = weekday(3); var thursday = weekday(4); var friday = weekday(5); var saturday = weekday(6); var sundays = sunday.range; var mondays = monday.range; var tuesdays = tuesday.range; var wednesdays = wednesday.range; var thursdays = thursday.range; var fridays = friday.range; var saturdays = saturday.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/month.js var month = newInterval(function(date) { date.setDate(1); date.setHours(0, 0, 0, 0); }, function(date, step) { date.setMonth(date.getMonth() + step); }, function(start, end) { return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; }, function(date) { return date.getMonth(); }); /* harmony default export */ var src_month = (month); var months = month.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/year.js var year = newInterval(function(date) { date.setMonth(0, 1); date.setHours(0, 0, 0, 0); }, function(date, step) { date.setFullYear(date.getFullYear() + step); }, function(start, end) { return end.getFullYear() - start.getFullYear(); }, function(date) { return date.getFullYear(); }); // An optimized implementation for this simple case. year.every = function(k) { return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { date.setFullYear(Math.floor(date.getFullYear() / k) * k); date.setMonth(0, 1); date.setHours(0, 0, 0, 0); }, function(date, step) { date.setFullYear(date.getFullYear() + step * k); }); }; /* harmony default export */ var src_year = (year); var years = year.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/utcMinute.js var utcMinute = newInterval(function(date) { date.setUTCSeconds(0, 0); }, function(date, step) { date.setTime(+date + step * durationMinute); }, function(start, end) { return (end - start) / durationMinute; }, function(date) { return date.getUTCMinutes(); }); /* harmony default export */ var src_utcMinute = (utcMinute); var utcMinutes = utcMinute.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/utcHour.js var utcHour = newInterval(function(date) { date.setUTCMinutes(0, 0, 0); }, function(date, step) { date.setTime(+date + step * durationHour); }, function(start, end) { return (end - start) / durationHour; }, function(date) { return date.getUTCHours(); }); /* harmony default export */ var src_utcHour = (utcHour); var utcHours = utcHour.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/utcDay.js var utcDay = newInterval(function(date) { date.setUTCHours(0, 0, 0, 0); }, function(date, step) { date.setUTCDate(date.getUTCDate() + step); }, function(start, end) { return (end - start) / durationDay; }, function(date) { return date.getUTCDate() - 1; }); /* harmony default export */ var src_utcDay = (utcDay); var utcDays = utcDay.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/utcWeek.js function utcWeekday(i) { return newInterval(function(date) { date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); date.setUTCHours(0, 0, 0, 0); }, function(date, step) { date.setUTCDate(date.getUTCDate() + step * 7); }, function(start, end) { return (end - start) / durationWeek; }); } var utcSunday = utcWeekday(0); var utcMonday = utcWeekday(1); var utcTuesday = utcWeekday(2); var utcWednesday = utcWeekday(3); var utcThursday = utcWeekday(4); var utcFriday = utcWeekday(5); var utcSaturday = utcWeekday(6); var utcSundays = utcSunday.range; var utcMondays = utcMonday.range; var utcTuesdays = utcTuesday.range; var utcWednesdays = utcWednesday.range; var utcThursdays = utcThursday.range; var utcFridays = utcFriday.range; var utcSaturdays = utcSaturday.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/utcMonth.js var utcMonth = newInterval(function(date) { date.setUTCDate(1); date.setUTCHours(0, 0, 0, 0); }, function(date, step) { date.setUTCMonth(date.getUTCMonth() + step); }, function(start, end) { return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; }, function(date) { return date.getUTCMonth(); }); /* harmony default export */ var src_utcMonth = (utcMonth); var utcMonths = utcMonth.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/utcYear.js var utcYear = newInterval(function(date) { date.setUTCMonth(0, 1); date.setUTCHours(0, 0, 0, 0); }, function(date, step) { date.setUTCFullYear(date.getUTCFullYear() + step); }, function(start, end) { return end.getUTCFullYear() - start.getUTCFullYear(); }, function(date) { return date.getUTCFullYear(); }); // An optimized implementation for this simple case. utcYear.every = function(k) { return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); date.setUTCMonth(0, 1); date.setUTCHours(0, 0, 0, 0); }, function(date, step) { date.setUTCFullYear(date.getUTCFullYear() + step * k); }); }; /* harmony default export */ var src_utcYear = (utcYear); var utcYears = utcYear.range; // CONCATENATED MODULE: ./node_modules/d3-time/src/index.js /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "g", function() { return newInterval; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "h", function() { return src_millisecond; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "i", function() { return milliseconds; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "L", function() { return src_millisecond; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "M", function() { return milliseconds; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "r", function() { return src_second; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "s", function() { return seconds; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "V", function() { return src_second; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "W", function() { return seconds; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "j", function() { return src_minute; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "k", function() { return minutes; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "e", function() { return src_hour; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "f", function() { return hours; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "a", function() { return src_day; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "b", function() { return days; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "B", function() { return sunday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "C", function() { return sundays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "t", function() { return sunday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "u", function() { return sundays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "l", function() { return monday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "m", function() { return mondays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "x", function() { return tuesday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "y", function() { return tuesdays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "z", function() { return wednesday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "A", function() { return wednesdays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "v", function() { return thursday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "w", function() { return thursdays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "c", function() { return friday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "d", function() { return fridays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "p", function() { return saturday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "q", function() { return saturdays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "n", function() { return src_month; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "o", function() { return months; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "D", function() { return src_year; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "E", function() { return years; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "N", function() { return src_utcMinute; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "O", function() { return utcMinutes; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "J", function() { return src_utcHour; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "K", function() { return utcHours; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "F", function() { return src_utcDay; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "G", function() { return utcDays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "_5", function() { return utcSunday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "_6", function() { return utcSundays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "X", function() { return utcSunday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Y", function() { return utcSundays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "P", function() { return utcMonday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Q", function() { return utcMondays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "_1", function() { return utcTuesday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "_2", function() { return utcTuesdays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "_3", function() { return utcWednesday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "_4", function() { return utcWednesdays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Z", function() { return utcThursday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "_0", function() { return utcThursdays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "H", function() { return utcFriday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "I", function() { return utcFridays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "T", function() { return utcSaturday; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "U", function() { return utcSaturdays; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "R", function() { return src_utcMonth; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "S", function() { return utcMonths; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "_7", function() { return src_utcYear; }); /* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "_8", function() { return utcYears; }); /***/ }), /***/ 199: /***/ (function(module, exports, __webpack_require__) { "use strict"; /// <reference path="../Facet/FacetHeader.ts" /> /// <reference path="../../controllers/FacetSliderQueryController.ts" /> var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); __webpack_require__(615); var underscore_1 = __webpack_require__(0); var FacetSliderQueryController_1 = __webpack_require__(616); var BreadcrumbEvents_1 = __webpack_require__(35); var InitializationEvents_1 = __webpack_require__(17); var QueryEvents_1 = __webpack_require__(11); var SearchAlertEvents_1 = __webpack_require__(87); var SliderEvents_1 = __webpack_require__(143); var GlobalExports_1 = __webpack_require__(3); var Assert_1 = __webpack_require__(5); var MiscModules_1 = __webpack_require__(67); var Model_1 = __webpack_require__(18); var QueryStateModel_1 = __webpack_require__(13); var Strings_1 = __webpack_require__(6); var AccessibilityUtils_1 = __webpack_require__(48); var Dom_1 = __webpack_require__(1); var SVGDom_1 = __webpack_require__(16); var SVGIcons_1 = __webpack_require__(12); var Utils_1 = __webpack_require__(4); var AnalyticsActionListMeta_1 = __webpack_require__(10); var Component_1 = __webpack_require__(7); var ComponentOptions_1 = __webpack_require__(8); var Initialization_1 = __webpack_require__(2); var FacetHeader_1 = __webpack_require__(485); var Slider_1 = __webpack_require__(617); var ResponsiveComponentsUtils_1 = __webpack_require__(131); var ResponsiveDropdown_1 = __webpack_require__(124); var ResponsiveFacetOptions_1 = __webpack_require__(85); var ResponsiveFacetSlider_1 = __webpack_require__(619); /** * The `FacetSlider` component creates a facet which contains a slider widget that allows the end user to filter results * based on a range of numerical values (e.g., a date range, a price range, etc.). * * **Note:** * > This component does **not** inherit from the [`Facet`]{@link Facet} component. Consequently, it does not offer the * > same configuration options. Moreover, some of the `FacetSlider` options (see * > [`getSteps`]{@link FacetSlider.options.getSteps} and [`valueCaption`]{@link FacetSlider.options.valueCaption}) * > cannot be configured as `data-` attributes in the markup. If you wish to configure those options, you must either * > do so in the [`init`]{@link init} call of your search interface (see * > [Passing Component Options in the init Call](https://docs.coveo.com/en/346/#passing-component-options-in-the-init-call)), * > or before the `init` call, using the `options` top-level function (see * > [Passing Component Options Before the init Call](https://docs.coveo.com/en/346/#passing-component-options-before-the-init-call)). * @notSupportedIn salesforcefree */ var FacetSlider = /** @class */ (function (_super) { __extends(FacetSlider, _super); /** * Creates a new `FacetSlider` component. Binds multiple query events as well. * @param element The HTMLElement on which to instantiate the component. * @param options The options for the `FacetSlider` component. * @param bindings The bindings that the component requires to function normally. If not set, these will be * automatically resolved (with a slower execution time). * @param slider */ function FacetSlider(element, options, bindings, slider) { var _this = _super.call(this, element, FacetSlider.ID, bindings) || this; _this.element = element; _this.options = options; _this.slider = slider; _this.isSimpleSliderConfig = false; _this.isFieldValueCompatible = false; _this.isEmpty = false; _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, FacetSlider, options); _this.isSimpleSliderConfig = _this.options.start != null && _this.options.end != null; ResponsiveFacetSlider_1.ResponsiveFacetSlider.init(_this.root, _this, _this.options); if (_this.options.excludeOuterBounds == null) { _this.options.excludeOuterBounds = false; } _this.normalizeStartAndEndOptionsValues(); _this.facetQueryController = new FacetSliderQueryController_1.FacetSliderQueryController(_this); _this.bindQueryStateEvents(); _this.bindQueryEvents(); _this.bindResizeEvents(); _this.bindBreadcrumbEvents(); _this.bind.onRootElement(SearchAlertEvents_1.SearchAlertsEvents.searchAlertsPopulateMessage, function (args) { return _this.handlePopulateSearchAlerts(args); }); return _this; } FacetSlider.prototype.isCurrentlyDisplayed = function () { if (!Dom_1.$$(this.element).isVisible()) { return false; } if (Dom_1.$$(this.element).hasClass('coveo-disabled-empty')) { return false; } return true; }; FacetSlider.prototype.createDom = function () { this.facetHeader = new FacetHeader_1.FacetHeader({ field: this.options.field, facetElement: this.element, title: this.options.title, enableClearElement: true, enableCollapseElement: true, facetSlider: this }); this.element.appendChild(this.facetHeader.build()); }; /** * Resets the `FacetSlider` (meaning that you need to set the range value as inactive). */ FacetSlider.prototype.reset = function () { if (this.slider) { this.slider.initializeState(); this.updateQueryState(); this.updateAppearanceDependingOnState(); } }; /** * Gets the current selection in the slider. * * **Note:** * > This method returns an array of number for selected date values. These numbers represent a number of milliseconds * > before or after January 1, 1970. Therefore, you can use these numbers to instantiate standard JavaScript Date * > objects. * * @returns {any} An array of number containing the first and last selected values, if possible. An array containing * two `undefined` values otherwise. */ FacetSlider.prototype.getSelectedValues = function () { if (this.startOfSlider != undefined && this.endOfSlider != undefined) { return [this.startOfSlider, this.endOfSlider]; } else { return [undefined, undefined]; } }; /** * Sets the selected values in the slider. * * **Note:** * > You must set date values with numbers representing a number of milliseconds before or after January 1, 1970. You * > can easily extract such numbers from standard JavaScript Date objects. * * @param values [start, end] An array containing the first and last values to select in the slider. */ FacetSlider.prototype.setSelectedValues = function (values) { this.setupSliderIfNeeded(undefined); this.startOfSlider = values[0]; this.endOfSlider = values[1]; this.slider.setValues([this.startOfSlider, this.endOfSlider]); this.updateAppearanceDependingOnState(); }; /** * Indicates whether the `FacetSlider` is active. An active `FacetSlider` outputs an expression in the query when a * search is performed. * @returns {boolean} `true` if the FacetSlider is active; `false` otherwise. */ FacetSlider.prototype.isActive = function () { return (!isNaN(this.startOfSlider) && !isNaN(this.endOfSlider) && !isNaN(this.initialStartOfSlider) && !isNaN(this.initialEndOfSlider) && (this.startOfSlider != this.initialStartOfSlider || this.endOfSlider != this.initialEndOfSlider)); }; FacetSlider.prototype.getSliderBoundaryForQuery = function () { var needToReturnABoundary = false; if (!this.slider) { needToReturnABoundary = true; } else if (this.slider && this.isActive()) { needToReturnABoundary = true; } if (needToReturnABoundary) { return this.generateBoundary(); } else { return undefined; } }; // There is delayed graph data if at the time the facet slider tried to draw, the facet was hidden in the // facet dropdown. This method will draw delayed graph data if it exists. FacetSlider.prototype.drawDelayedGraphData = function () { if (this.delayedGraphData != null && !this.isEmpty) { this.slider.drawGraph(this.delayedGraphData); } this.delayedGraphData = null; }; FacetSlider.prototype.hasAGraph = function () { return this.options.graph != undefined; }; FacetSlider.prototype.normalizeStartAndEndOptionsValues = function () { if (this.options.start) { this.options.start = this.options.dateField ? new Date(this.options.start.replace(/-/g, '/')).getTime() : Number(this.options.start); } if (this.options.end) { this.options.end = this.options.dateField ? new Date(this.options.end.replace(/-/g, '/')).getTime() : Number(this.options.end); } }; FacetSlider.prototype.bindQueryEvents = function () { var _this = this; this.bind.onRootElement(QueryEvents_1.QueryEvents.newQuery, function () { return _this.handleNewQuery(); }); this.bind.onRootElement(QueryEvents_1.QueryEvents.noResults, function () { return _this.handleNoresults(); }); this.bind.onRootElement(QueryEvents_1.QueryEvents.deferredQuerySuccess, function (args) { return _this.handleDeferredQuerySuccess(args); }); this.bind.onRootElement(QueryEvents_1.QueryEvents.buildingQuery, function (args) { return _this.handleBuildingQuery(args); }); this.bind.onRootElement(QueryEvents_1.QueryEvents.doneBuildingQuery, function (args) { return _this.handleDoneBuildingQuery(args); }); }; FacetSlider.prototype.bindResizeEvents = function () { var _this = this; this.onResize = underscore_1.debounce(function () { if (ResponsiveComponentsUtils_1.ResponsiveComponentsUtils.shouldDrawFacetSlider(Dom_1.$$(_this.root), Dom_1.$$(_this.element)) && _this.slider && !_this.isEmpty) { if (_this.delayedGraphData) { _this.drawDelayedGraphData(); } else { _this.slider.drawGraph(); } } if (_this.slider) { _this.slider.onMoving(); } }, 250); window.addEventListener('resize', this.onResize); this.bind.onRootElement(ResponsiveDropdown_1.ResponsiveDropdownEvent.OPEN, this.onResize); // This is used inside SF integration this.bind.onRootElement('onPopupOpen', this.onResize); Dom_1.$$(this.root).on(InitializationEvents_1.InitializationEvents.nuke, function () { return _this.handleNuke(); }); }; FacetSlider.prototype.bindBreadcrumbEvents = function () { var _this = this; this.bind.onRootElement(BreadcrumbEvents_1.BreadcrumbEvents.clearBreadcrumb, function () { return _this.reset(); }); this.bind.onRootElement(BreadcrumbEvents_1.BreadcrumbEvents.populateBreadcrumb, function (args) { return _this.handlePopulateBreadcrumb(args); }); }; FacetSlider.prototype.handleNoresults = function () { this.isEmpty = true; this.updateAppearanceDependingOnState(); }; FacetSlider.prototype.handleNewQuery = function () { this.isEmpty = false; }; FacetSlider.prototype.handleRangeQueryStateChanged = function (args) { this.setupSliderIfNeeded(args); this.startOfSlider = args.value[0] == undefined ? this.startOfSlider : args.value[0]; this.endOfSlider = args.value[1] == undefined ? this.endOfSlider : args.value[1]; this.setSelectedValues([this.startOfSlider, this.endOfSlider]); }; FacetSlider.prototype.handlePopulateBreadcrumb = function (args) { var _this = this; var populateBreadcrumb = function () { if (_this.isActive()) { args.breadcrumbs.push({ element: _this.buildBreadcrumbFacetSlider(args.headingLevel) }); } }; if (this.slider) { populateBreadcrumb(); } else { Dom_1.$$(this.root).one(QueryEvents_1.QueryEvents.deferredQuerySuccess, function () { populateBreadcrumb(); Dom_1.$$(_this.root).trigger(BreadcrumbEvents_1.BreadcrumbEvents.redrawBreadcrumb); }); } }; FacetSlider.prototype.handlePopulateSearchAlerts = function (args) { if (this.isActive()) { args.text.push(Dom_1.$$(this.buildBreadcrumbFacetSlider()).text()); } }; FacetSlider.prototype.buildBreadcrumbFacetSlider = function (headingLevel) { var _this = this; var elem = Dom_1.$$('div', { className: 'coveo-facet-slider-breadcrumb' }).el; var title = Dom_1.$$(AccessibilityUtils_1.getHeadingTag(headingLevel, 'span'), { className: 'coveo-facet-slider-breadcrumb-title' }); title.text(this.options.title + ': '); elem.appendChild(title.el); var values = Dom_1.$$('span', { className: 'coveo-facet-slider-breadcrumb-values' }); elem.appendChild(values.el); var value = Dom_1.$$('span', { className: 'coveo-facet-slider-breadcrumb-value' }); var caption = Dom_1.$$('span', { className: 'coveo-facet-slider-breadcrumb-caption' }); caption.text(this.slider.getCaption()); value.append(caption.el); values.el.appendChild(value.el); var clear = Dom_1.$$('span', { className: 'coveo-facet-slider-breadcrumb-clear' }, SVGIcons_1.SVGIcons.icons.mainClear); SVGDom_1.SVGDom.addClassToSVGInContainer(clear.el, 'coveo-facet-slider-clear-svg'); value.el.appendChild(clear.el); value.on('click', function () { _this.reset(); _this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.facetClearAll, { facetId: _this.options.id, facetField: _this.options.field.toString(), facetTitle: _this.options.title }); _this.queryController.executeQuery(); }); return elem; }; FacetSlider.prototype.initSlider = function () { this.buildSlider(); this.slider.initializeState([this.startOfSlider, this.endOfSlider]); this.updateAppearanceDependingOnState(); }; FacetSlider.prototype.bindQueryStateEvents = function () { var _this = this; this.rangeQueryStateAttribute = QueryStateModel_1.QueryStateModel.getFacetId(this.options.id) + ':range'; this.queryStateModel.registerNewAttribute(this.rangeQueryStateAttribute, [undefined, undefined]); var eventName = this.queryStateModel.getEventName(Model_1.Model.eventTypes.changeOne + this.rangeQueryStateAttribute); this.bind.onRootElement(eventName, function (args) { _this.slider ? _this.handleRangeQueryStateChanged(args) : _this.setRangeStateSliderStillNotCreated(args); }); }; FacetSlider.prototype.setRangeStateSliderStillNotCreated = function (args) { this.rangeFromUrlState = this.copyValues(args.value); }; FacetSlider.prototype.buildSlider = function () { var _this = this; var sliderContainer = Dom_1.$$('div', { className: 'coveo-slider-container' }).el; if (this.hasAGraph()) { Dom_1.$$(sliderContainer).addClass('coveo-with-graph'); } var sliderDiv = Dom_1.$$('div').el; this.slider = this.slider ? this.slider : new Slider_1.Slider(sliderDiv, __assign({}, this.options, { dateField: this.options.dateField }), this.root); Dom_1.$$(sliderDiv).on(SliderEvents_1.SliderEvents.endSlide, function (e, args) { _this.handleEndSlide(args); }); Dom_1.$$(sliderDiv).on(SliderEvents_1.SliderEvents.duringSlide, function (e, args) { _this.handleDuringSlide(args); }); if (this.hasAGraph()) { Dom_1.$$(sliderDiv).on(SliderEvents_1.SliderEvents.graphValueSelected, function (e, args) { _this.handleGraphValueSelected(args); }); } sliderContainer.appendChild(sliderDiv); this.element.appendChild(sliderContainer); this.updateAppearanceDependingOnState(); }; FacetSlider.prototype.handleBuildingQuery = function (data) { Assert_1.Assert.exists(data); Assert_1.Assert.exists(data.queryBuilder); var boundary = this.getSliderBoundaryForQuery(); if (boundary != undefined) { this.facetQueryController.prepareForNewQuery(); var expression = this.facetQueryController.computeOurFilterExpression(boundary); if (Utils_1.Utils.isNonEmptyString(expression)) { this.logger.trace('Putting filter in query', expression); data.queryBuilder.advancedExpression.add(expression); } } }; FacetSlider.prototype.handleDoneBuildingQuery = function (data) { var queryBuilder = data.queryBuilder; this.facetQueryController.putGroupByIntoQueryBuilder(queryBuilder); }; FacetSlider.prototype.handleDeferredQuerySuccess = function (data) { this.ensureDom(); this.setupSliderIfNeeded(data); var groupByResults = data.results.groupByResults[this.facetQueryController.lastGroupByRequestIndex]; this.isEmpty = this.isFacetEmpty(groupByResults, data); this.updateAppearanceDependingOnState(); if (this.hasAGraph()) { this.renderToSliderGraph(data); } }; FacetSlider.prototype.handleEndSlide = function (args) { var values = args.slider.getValues(); this.startOfSlider = values[0]; this.endOfSlider = values[1]; if (this.updateQueryState(values)) { this.updateAppearanceDependingOnState(); this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.facetRangeSlider, { facetId: this.options.id, facetField: this.options.field.toString(), facetRangeStart: this.startOfSlider.toString(), facetRangeEnd: this.endOfSlider.toString() }); this.queryController.executeQuery(); } }; FacetSlider.prototype.handleDuringSlide = function (args) { var values = args.slider.getValues(); this.startOfSlider = values[0]; this.endOfSlider = values[1]; this.slider.setValues([this.startOfSlider, this.endOfSlider]); this.updateAppearanceDependingOnState(true); }; FacetSlider.prototype.handleGraphValueSelected = function (args) { if ((this.options.rangeSlider && this.startOfSlider != args.start) || this.endOfSlider != args.end) { if (this.options.rangeSlider) { this.startOfSlider = args.start; } this.endOfSlider = args.end; this.slider.setValues([this.startOfSlider, this.endOfSlider]); this.updateQueryState(); this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.facetRangeGraph, { facetId: this.options.id, facetField: this.options.field.toString(), facetRangeStart: this.startOfSlider.toString(), facetRangeEnd: this.endOfSlider.toString() }); this.queryController.executeQuery(); } }; FacetSlider.prototype.updateQueryState = function (values, silent) { if (values === void 0) { values = this.slider.getValues(); } if (silent === void 0) { silent = false; } var copyOfValues = this.copyValues(values); var start = values[0] + 0.0; var end = values[1] + 0.0; var model = this.queryStateModel.get(this.rangeQueryStateAttribute); if (model == null || copyOfValues[0] != model[0] || copyOfValues[1] != model[1]) { copyOfValues[0] = start; copyOfValues[1] = end; this.queryStateModel.set(this.rangeQueryStateAttribute, copyOfValues, { silent: silent }); return true; } return false; }; FacetSlider.prototype.copyValues = function (values) { // Creating a copy of the values prevents an unwanted automatic update of the state while sliding // That's the cleanest way I found to copy that array correctly var copyOfValues = []; copyOfValues[0] = Number(values[0]) + 0.0; copyOfValues[1] = Number(values[1]) + 0.0; return copyOfValues; }; FacetSlider.prototype.renderToSliderGraph = function (data) { var _this = this; var rawGroupByResults = data.results.groupByResults[this.facetQueryController.graphGroupByQueriesIndex]; var graphData; var totalGraphResults = 0; if (rawGroupByResults) { graphData = underscore_1.map(rawGroupByResults.values, function (value) { totalGraphResults += value.numberOfResults; var start = value.value.split('..')[0]; var end = value.value.split('..')[1]; if (!_this.options.dateField) { start = Number(start); end = Number(end); } else { start = new Date(start.split('@')[0]).getTime(); end = new Date(end.split('@')[0]).getTime(); } var y = value.numberOfResults; return { start: start, y: y, end: end, isDate: _this.options.dateField }; }); } if (totalGraphResults == 0) { this.isEmpty = true; this.updateAppearanceDependingOnState(); } if (graphData != undefined && !this.isDropdownHidden()) { // This is deferred since it might be called on initialization with a placehoder over the facet during load time // We need to wait that the animation is gone so that the width/height calculation done by the graph are okay. MiscModule