coveo-search-ui
Version:
Coveo JavaScript Search Framework
1,130 lines (1,079 loc) • 157 kB
JavaScript
webpackJsonpCoveo__temporary([18,42,56],{
/***/ 180:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
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 });
var ExternalModulesShim_1 = __webpack_require__(26);
var FocusTrap_1 = __webpack_require__(471);
var Strings_1 = __webpack_require__(6);
var Dom_1 = __webpack_require__(1);
var KeyboardUtils_1 = __webpack_require__(25);
var Core_1 = __webpack_require__(20);
var AccessibleModal = /** @class */ (function () {
function AccessibleModal(className, ownerElement, modalboxModule, options) {
if (modalboxModule === void 0) { modalboxModule = ExternalModulesShim_1.ModalBox; }
if (options === void 0) { options = {}; }
this.className = className;
this.ownerElement = ownerElement;
this.modalboxModule = modalboxModule;
this.options = __assign({
sizeMod: 'big'
}, options);
}
Object.defineProperty(AccessibleModal.prototype, "isOpen", {
get: function () {
return !!this.focusTrap;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AccessibleModal.prototype, "element", {
get: function () {
return this.activeModal && this.activeModal.modalBox;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AccessibleModal.prototype, "content", {
get: function () {
return this.activeModal && this.activeModal.content;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AccessibleModal.prototype, "wrapper", {
get: function () {
return this.activeModal && this.activeModal.wrapper;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AccessibleModal.prototype, "headerElement", {
get: function () {
return this.element && this.element.querySelector('.coveo-modal-header h1');
},
enumerable: true,
configurable: true
});
AccessibleModal.prototype.openResult = function (parameters) {
if (this.isOpen) {
return;
}
this.openModalAndTrap({
content: parameters.content,
validation: parameters.validation,
origin: parameters.origin,
title: Core_1.DomUtils.getQuickviewHeader(parameters.result, parameters.options, parameters.bindings).el
});
this.makeAccessible(parameters.options.title || parameters.result.title);
};
AccessibleModal.prototype.open = function (parameters) {
if (this.isOpen) {
return;
}
this.openModalAndTrap(parameters);
this.makeAccessible();
};
AccessibleModal.prototype.openModalAndTrap = function (parameters) {
var _this = this;
this.initiallyFocusedElement = parameters.origin || document.activeElement;
this.activeModal = this.modalboxModule.open(parameters.content, {
title: parameters.title,
className: this.className,
validation: function () {
_this.onModalClose();
return parameters.validation();
},
body: this.ownerElement,
sizeMod: this.options.sizeMod,
overlayClose: this.options.overlayClose
});
this.focusTrap = new FocusTrap_1.FocusTrap(this.element);
};
AccessibleModal.prototype.close = function () {
if (!this.isOpen) {
return;
}
this.activeModal.close();
this.activeModal = null;
};
AccessibleModal.prototype.makeAccessible = function (title) {
this.element.setAttribute('aria-modal', 'true');
if (title) {
this.headerElement.setAttribute('aria-label', title);
}
this.makeCloseButtonAccessible();
this.updateFocus();
};
Object.defineProperty(AccessibleModal.prototype, "closeButton", {
get: function () {
return this.element.querySelector('.coveo-small-close');
},
enumerable: true,
configurable: true
});
AccessibleModal.prototype.makeCloseButtonAccessible = function () {
var closeButton = this.closeButton;
closeButton.setAttribute('aria-label', Strings_1.l('Close'));
closeButton.setAttribute('role', 'button');
closeButton.tabIndex = 0;
Dom_1.$$(closeButton).on('keyup', KeyboardUtils_1.KeyboardUtils.keypressAction(KeyboardUtils_1.KEYBOARD.ENTER, function () { return closeButton.click(); }));
};
AccessibleModal.prototype.updateFocus = function () {
var focusOnElement = (this.options.focusOnOpen && this.options.focusOnOpen()) || this.closeButton;
focusOnElement.focus();
};
AccessibleModal.prototype.onModalClose = function () {
this.focusTrap.disable();
this.focusTrap = null;
if (this.initiallyFocusedElement && document.body.contains(this.initiallyFocusedElement)) {
this.initiallyFocusedElement.focus();
}
};
return AccessibleModal;
}());
exports.AccessibleModal = AccessibleModal;
/***/ }),
/***/ 230:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var dompurify_1 = __webpack_require__(589);
var Dom_1 = __webpack_require__(1);
var ResultLinkCommon_1 = __webpack_require__(475);
exports.getDefaultSnippetStyle = function (contentClassName) { return "\n body {\n font-family: \"Lato\", \"Helvetica Neue\", Helvetica, Arial, sans-serif, sans-serif;\n }\n\n ." + contentClassName + " > :first-child {\n margin-top: 0;\n }\n\n ." + contentClassName + " > :last-child {\n margin-bottom: 0;\n }\n"; };
function getSanitizedAnswerSnippet(questionAnswer) {
if (!questionAnswer.answerSnippet) {
return '';
}
// dompurify can fail to execute in some environment (salesforce locker service)
try {
return dompurify_1.sanitize(questionAnswer.answerSnippet, {
USE_PROFILES: { html: true }
});
}
catch (e) {
return questionAnswer.answerSnippet;
}
}
exports.getSanitizedAnswerSnippet = getSanitizedAnswerSnippet;
exports.transformSnippetLinks = function (renderedSnippetParent, alwaysOpenInNewWindow, logAnalytics) {
Dom_1.Dom.nodeListToArray(renderedSnippetParent.querySelectorAll('a')).forEach(function (link) {
ResultLinkCommon_1.bindAnalyticsToLink(link, function () { return logAnalytics(link); });
link.target = alwaysOpenInNewWindow ? '_blank' : '_top';
});
};
/***/ }),
/***/ 299:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
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;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var ExternalModulesShim_1 = __webpack_require__(26);
var GlobalExports_1 = __webpack_require__(3);
var Component_1 = __webpack_require__(7);
var Core_1 = __webpack_require__(20);
__webpack_require__(705);
var underscore_1 = __webpack_require__(0);
var UserFeedbackBanner_1 = __webpack_require__(706);
var AnalyticsActionListMeta_1 = __webpack_require__(10);
var HeightLimiter_1 = __webpack_require__(707);
var ExplanationModal_1 = __webpack_require__(708);
var Strings_1 = __webpack_require__(6);
var AttachShadowPolyfill_1 = __webpack_require__(523);
var Utils_1 = __webpack_require__(4);
var ComponentOptions_1 = __webpack_require__(8);
var SmartSnippetCommon_1 = __webpack_require__(230);
var ResultLink_1 = __webpack_require__(71);
var reasons = [
{
analytics: AnalyticsActionListMeta_1.AnalyticsSmartSnippetFeedbackReason.DoesNotAnswer,
localeKey: 'UsefulnessFeedbackDoesNotAnswer'
},
{
analytics: AnalyticsActionListMeta_1.AnalyticsSmartSnippetFeedbackReason.PartiallyAnswers,
localeKey: 'UsefulnessFeedbackPartiallyAnswers'
},
{
analytics: AnalyticsActionListMeta_1.AnalyticsSmartSnippetFeedbackReason.WasNotAQuestion,
localeKey: 'UsefulnessFeedbackWasNotAQuestion'
},
{
analytics: AnalyticsActionListMeta_1.AnalyticsSmartSnippetFeedbackReason.Other,
localeKey: 'Other',
hasDetails: true
}
];
var BASE_CLASSNAME = 'coveo-smart-snippet';
var QUESTION_CLASSNAME = BASE_CLASSNAME + "-question";
var ANSWER_CONTAINER_CLASSNAME = BASE_CLASSNAME + "-answer";
var HAS_ANSWER_CLASSNAME = BASE_CLASSNAME + "-has-answer";
var SHADOW_CLASSNAME = BASE_CLASSNAME + "-content";
var CONTENT_CLASSNAME = BASE_CLASSNAME + "-content-wrapper";
var SOURCE_CLASSNAME = BASE_CLASSNAME + "-source";
var SOURCE_TITLE_CLASSNAME = SOURCE_CLASSNAME + "-title";
var SOURCE_URL_CLASSNAME = SOURCE_CLASSNAME + "-url";
exports.SmartSnippetClassNames = {
QUESTION_CLASSNAME: QUESTION_CLASSNAME,
ANSWER_CONTAINER_CLASSNAME: ANSWER_CONTAINER_CLASSNAME,
HAS_ANSWER_CLASSNAME: HAS_ANSWER_CLASSNAME,
SHADOW_CLASSNAME: SHADOW_CLASSNAME,
CONTENT_CLASSNAME: CONTENT_CLASSNAME,
SOURCE_CLASSNAME: SOURCE_CLASSNAME,
SOURCE_TITLE_CLASSNAME: SOURCE_TITLE_CLASSNAME,
SOURCE_URL_CLASSNAME: SOURCE_URL_CLASSNAME
};
/**
* The SmartSnippet component displays the excerpt of a document that would be most likely to answer a particular query.
*
* This excerpt can be visually customized using inline styling.
*/
var SmartSnippet = /** @class */ (function (_super) {
__extends(SmartSnippet, _super);
function SmartSnippet(element, options, bindings, ModalBox) {
if (ModalBox === void 0) { ModalBox = ExternalModulesShim_1.ModalBox; }
var _this = _super.call(this, element, SmartSnippet.ID, bindings) || this;
_this.element = element;
_this.options = options;
_this.ModalBox = ModalBox;
_this.lastRenderedResult = null;
_this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, SmartSnippet, options);
_this.bind.onRootElement(Core_1.QueryEvents.deferredQuerySuccess, function (data) { return _this.handleQuerySuccess(data); });
return _this;
}
Object.defineProperty(SmartSnippet.prototype, "loading", {
get: function () {
return this.shadowLoading;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SmartSnippet.prototype, "style", {
get: function () {
var styles = Core_1.$$(this.element)
.children()
.filter(function (element) { return element instanceof HTMLScriptElement && element.type.toLowerCase() === 'text/css'; })
.map(function (element) { return element.innerHTML; });
return styles.length ? styles.join('\n') : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SmartSnippet.prototype, "hasAnswer", {
set: function (hasAnswer) {
Core_1.$$(this.element).toggleClass(HAS_ANSWER_CLASSNAME, hasAnswer);
},
enumerable: true,
configurable: true
});
SmartSnippet.prototype.createDom = function () {
var _this = this;
this.element.appendChild(this.buildAnswerContainer());
this.feedbackBanner = new UserFeedbackBanner_1.UserFeedbackBanner(function (isUseful) { return (isUseful ? _this.sendLikeSmartSnippetAnalytics() : _this.sendDislikeSmartSnippetAnalytics()); }, function () { return _this.openExplanationModal(); });
this.element.appendChild(this.feedbackBanner.build());
this.explanationModal = new ExplanationModal_1.ExplanationModal({
reasons: reasons.map(function (reason) {
return ({
label: Strings_1.l(reason.localeKey),
id: reason.analytics.replace(/_/g, '-'),
onSelect: function () { return _this.sendExplanationAnalytics(reason.analytics, _this.explanationModal.details); },
hasDetails: reason.hasDetails
});
}),
onClosed: function () { return _this.sendCloseFeedbackModalAnalytics(); },
ownerElement: this.searchInterface.options.modalContainer,
modalBoxModule: this.ModalBox
});
};
SmartSnippet.prototype.buildAnswerContainer = function () {
return Core_1.$$('div', {
className: ANSWER_CONTAINER_CLASSNAME
}, this.buildQuestion(), this.buildShadow(), this.buildHeightLimiter(), this.buildSourceContainer()).el;
};
SmartSnippet.prototype.buildQuestion = function () {
return (this.questionContainer = Core_1.$$('div', { className: QUESTION_CLASSNAME }).el);
};
SmartSnippet.prototype.buildShadow = function () {
var _this = this;
this.shadowContainer = Core_1.$$('div', { className: SHADOW_CLASSNAME }).el;
this.snippetContainer = Core_1.$$('section', { className: CONTENT_CLASSNAME }).el;
this.shadowLoading = AttachShadowPolyfill_1.attachShadow(this.shadowContainer, {
mode: 'open',
title: Strings_1.l('AnswerSnippet'),
onSizeChanged: function () { return _this.handleAnswerSizeChanged(); },
useIFrame: this.options.useIFrame
}).then(function (shadow) {
shadow.appendChild(_this.snippetContainer);
var style = _this.buildStyle();
shadow.appendChild(style);
return shadow;
});
return this.shadowContainer;
};
SmartSnippet.prototype.buildHeightLimiter = function () {
var _this = this;
return (this.heightLimiter = new HeightLimiter_1.HeightLimiter(this.shadowContainer, this.shadowContainer.childNodes.item(0), this.options.maximumSnippetHeight, function (isExpanded) { return (isExpanded ? _this.sendExpandSmartSnippetAnalytics() : _this.sendCollapseSmartSnippetAnalytics()); })).toggleButton;
};
SmartSnippet.prototype.buildSourceContainer = function () {
return (this.sourceContainer = Core_1.$$('div', { className: SOURCE_CLASSNAME }).el);
};
SmartSnippet.prototype.buildStyle = function () {
var style = Utils_1.Utils.isNullOrUndefined(this.style) ? SmartSnippetCommon_1.getDefaultSnippetStyle(CONTENT_CLASSNAME) : this.style;
var styleTag = document.createElement('style');
styleTag.innerHTML = style;
return styleTag;
};
SmartSnippet.prototype.handleAnswerSizeChanged = function () {
this.heightLimiter.onContentHeightChanged();
};
/**
* @warning This method only works for the demo. In practice, the source of the answer will not always be part of the results.
*/
SmartSnippet.prototype.getCorrespondingResult = function (questionAnswer) {
var lastResults = this.queryController.getLastResults().results;
var childResults = underscore_1.flatten(underscore_1.map(lastResults, function (lastResult) { return lastResult.childResults; }));
var attachments = underscore_1.flatten(underscore_1.map(lastResults, function (lastResult) { return lastResult.attachments; }));
return underscore_1.find(underscore_1.compact(lastResults.concat(childResults, attachments)), function (result) { return result.raw[questionAnswer.documentId.contentIdKey] === questionAnswer.documentId.contentIdValue; });
};
SmartSnippet.prototype.handleQuerySuccess = function (data) {
return __awaiter(this, void 0, void 0, function () {
var questionAnswer;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
questionAnswer = data.results.questionAnswer;
if (!this.containsQuestionAnswer(questionAnswer)) {
this.hasAnswer = false;
return [2 /*return*/];
}
this.hasAnswer = true;
this.searchUid = data.results.searchUid;
return [4 /*yield*/, this.render(questionAnswer)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
SmartSnippet.prototype.containsQuestionAnswer = function (questionAnswer) {
return questionAnswer && questionAnswer.question && questionAnswer.answerSnippet;
};
SmartSnippet.prototype.render = function (questionAnswer) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
this.ensureDom();
this.feedbackBanner.reset();
this.questionContainer.innerText = questionAnswer.question;
this.renderSnippet(questionAnswer);
this.lastRenderedResult = this.getCorrespondingResult(questionAnswer);
if (this.lastRenderedResult) {
this.renderSource();
}
else {
this.lastRenderedResult = null;
}
return [2 /*return*/];
});
});
};
SmartSnippet.prototype.renderSnippet = function (questionAnswer) {
var _this = this;
this.snippetContainer.innerHTML = SmartSnippetCommon_1.getSanitizedAnswerSnippet(questionAnswer);
SmartSnippetCommon_1.transformSnippetLinks(this.snippetContainer, this.options.alwaysOpenInNewWindow, function (link) { return _this.sendClickSnippetLinkAnalytics(link); });
};
SmartSnippet.prototype.renderSource = function () {
var container = Core_1.$$(this.sourceContainer);
container.empty();
container.append(this.renderSourceUrl().el);
container.append(this.renderSourceTitle().el);
};
SmartSnippet.prototype.renderSourceTitle = function () {
var link = this.buildLink(SOURCE_TITLE_CLASSNAME);
link.text(Utils_1.Utils.getFieldValue(this.lastRenderedResult, this.options.titleField));
return link;
};
SmartSnippet.prototype.renderSourceUrl = function () {
var link = this.buildLink(SOURCE_URL_CLASSNAME);
link.text(link.el.href);
return link;
};
SmartSnippet.prototype.buildLink = function (className) {
var _this = this;
var element = Core_1.$$('a', { className: 'CoveoResultLink' });
element.addClass(className);
new ResultLink_1.ResultLink(element.el, {
hrefTemplate: this.options.hrefTemplate,
logAnalytics: function (href) { return _this.sendClickSourceAnalytics(element.el, href); },
alwaysOpenInNewWindow: this.options.alwaysOpenInNewWindow
}, __assign({}, this.getBindings(), { resultElement: this.element }), this.lastRenderedResult);
return element;
};
SmartSnippet.prototype.openExplanationModal = function () {
this.sendOpenFeedbackModalAnalytics();
this.explanationModal.open(this.feedbackBanner.explainWhy);
};
SmartSnippet.prototype.sendLikeSmartSnippetAnalytics = function () {
return this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.likeSmartSnippet, { searchQueryUid: this.searchUid }, this.element);
};
SmartSnippet.prototype.sendDislikeSmartSnippetAnalytics = function () {
return this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.dislikeSmartSnippet, { searchQueryUid: this.searchUid }, this.element);
};
SmartSnippet.prototype.sendExpandSmartSnippetAnalytics = function () {
return this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.expandSmartSnippet, { searchQueryUid: this.searchUid }, this.element);
};
SmartSnippet.prototype.sendCollapseSmartSnippetAnalytics = function () {
return this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.collapseSmartSnippet, { searchQueryUid: this.searchUid }, this.element);
};
SmartSnippet.prototype.sendOpenFeedbackModalAnalytics = function () {
return this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.openSmartSnippetFeedbackModal, { searchQueryUid: this.searchUid }, this.element);
};
SmartSnippet.prototype.sendCloseFeedbackModalAnalytics = function () {
return this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.closeSmartSnippetFeedbackModal, { searchQueryUid: this.searchUid }, this.element);
};
SmartSnippet.prototype.sendExplanationAnalytics = function (reason, details) {
return this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.sendSmartSnippetReason, {
searchQueryUid: this.searchUid,
reason: reason,
details: details
}, this.element);
};
SmartSnippet.prototype.sendClickSourceAnalytics = function (element, href) {
return this.usageAnalytics.logClickEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.openSmartSnippetSource, {
searchQueryUid: this.searchUid,
documentTitle: this.lastRenderedResult.title,
author: Utils_1.Utils.getFieldValue(this.lastRenderedResult, 'author'),
documentURL: href
}, this.lastRenderedResult, element);
};
SmartSnippet.prototype.sendClickSnippetLinkAnalytics = function (link) {
return this.usageAnalytics.logClickEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.openSmartSnippetInlineLink, {
searchQueryUid: this.searchUid,
linkText: link.innerText,
linkURL: link.href
}, this.lastRenderedResult, link);
};
SmartSnippet.ID = 'SmartSnippet';
SmartSnippet.doExport = function () {
GlobalExports_1.exportGlobally({
SmartSnippet: SmartSnippet
});
};
/**
* The options for the SmartSnippet
* @componentOptions
*/
SmartSnippet.options = {
/**
* The maximum height an answer can have in pixels.
* Any part of an answer exceeding this height will be hidden by default and expendable via a "show more" button.
* Default value is `250`.
*/
maximumSnippetHeight: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 250, min: 0 }),
/**
* The field to display for the title.
*/
titleField: ComponentOptions_1.ComponentOptions.buildFieldOption({ defaultValue: '@title' }),
/**
* Specifies a template literal from which to generate the title and URI's `href` attribute value (see
* [Template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals)).
*
* This option overrides the [`field`]{@link SmartSnippet.options.uriField} option value.
*
* The template literal can reference any number of fields from the parent result. It can also reference global
* scope properties.
*
* **Examples:**
*
* - The following markup generates an `href` value such as `http://uri.com?id=itemTitle`:
*
* ```html
* <a class='CoveoSmartSnippet' data-href-template='${clickUri}?id=${raw.title}'></a>
* ```
*
* - The following markup generates an `href` value such as `localhost/fooBar`:
*
* ```html
* <a class='CoveoSmartSnippet' data-href-template='${window.location.hostname}/{Foo.Bar}'></a>
* ```
*
* Default value is `undefined`.
*/
hrefTemplate: ComponentOptions_1.ComponentOptions.buildStringOption(),
/**
* Specifies whether the component should open its links in a new window instead of opening them in the current
* context.
*
* Default value is `false`.
*/
alwaysOpenInNewWindow: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),
/**
* Specify if the SmartSnippet should be displayed inside an iframe or not.
*
* Use this option in specific cases where your environment has limitations around iframe usage.
*
* **Examples:**
*
* ```html
* <div class='CoveoSmartSnippet' data-use-i-frame='true'></div>
* ```
*
* Default value is `true`.
*/
useIFrame: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true })
};
return SmartSnippet;
}(Component_1.Component));
exports.SmartSnippet = SmartSnippet;
Core_1.Initialization.registerAutoCreateComponent(SmartSnippet);
/***/ }),
/***/ 471:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Defer_1 = __webpack_require__(31);
var underscore_1 = __webpack_require__(0);
var Dom_1 = __webpack_require__(1);
var FocusTrap = /** @class */ (function () {
function FocusTrap(container, options) {
if (options === void 0) { options = {
focusableSelector: '[tabindex], button'
}; }
this.container = container;
this.options = options;
this.hiddenElements = [];
this.enable();
}
Object.defineProperty(FocusTrap.prototype, "focusableElements", {
get: function () {
return underscore_1.chain(Dom_1.Dom.nodeListToArray(this.container.querySelectorAll(this.options.focusableSelector)))
.filter(function (element) { return Dom_1.$$(element).isVisible(); })
.sortBy(function (element) { return element.tabIndex; })
.value();
},
enumerable: true,
configurable: true
});
FocusTrap.prototype.disable = function () {
document.removeEventListener('focusin', this.focusInEvent);
document.removeEventListener('focusout', this.focusOutEvent);
this.showHiddenElements();
this.enabled = false;
};
FocusTrap.prototype.enable = function () {
var _this = this;
document.addEventListener('focusin', (this.focusInEvent = function (e) { return _this.onFocusIn(e); }));
document.addEventListener('focusout', (this.focusOutEvent = function (e) { return _this.onFocusOut(e); }));
this.hideAllExcept(this.container);
this.enabled = true;
};
FocusTrap.prototype.showHiddenElements = function () {
while (this.hiddenElements.length) {
this.hiddenElements.pop().removeAttribute('aria-hidden');
}
};
FocusTrap.prototype.hideElement = function (element) {
if (element.getAttribute('aria-hidden')) {
return;
}
this.hiddenElements.push(element);
element.setAttribute('aria-hidden', "" + true);
};
FocusTrap.prototype.hideSiblings = function (allowedElement) {
var _this = this;
var parent = allowedElement.parentElement;
if (parent) {
underscore_1.without(Dom_1.$$(parent).children(), allowedElement).forEach(function (elementToHide) {
_this.hideElement(elementToHide);
});
}
};
FocusTrap.prototype.hideAllExcept = function (allowedElement) {
this.hideSiblings(allowedElement);
var parent = allowedElement.parentElement;
if (parent && parent !== document.body) {
this.hideAllExcept(parent);
}
};
FocusTrap.prototype.getFocusableSibling = function (element, previous) {
if (previous === void 0) { previous = false; }
var elements = this.focusableElements;
var currentIndex = elements.indexOf(element);
if (currentIndex === -1) {
return null;
}
return elements[(currentIndex + (previous ? -1 : 1) + elements.length) % elements.length];
};
FocusTrap.prototype.focusSibling = function (element, previous) {
if (previous === void 0) { previous = false; }
var sibling = this.getFocusableSibling(element, previous);
if (sibling) {
sibling.focus();
}
};
FocusTrap.prototype.focusFirstElement = function () {
var elements = this.focusableElements;
if (elements.length) {
elements[0].focus();
}
};
FocusTrap.prototype.elementIsBefore = function (oldElement, newElement) {
if (!newElement) {
return false;
}
return oldElement.compareDocumentPosition(newElement) === Node.DOCUMENT_POSITION_PRECEDING;
};
FocusTrap.prototype.onLosingFocus = function (oldElement, newElement) {
var _this = this;
Defer_1.Defer.defer(function () {
if (!_this.enabled) {
return;
}
_this.enabled = false;
if (oldElement && _this.focusIsAllowed(oldElement)) {
_this.focusSibling(oldElement, _this.elementIsBefore(oldElement, newElement));
}
else {
_this.focusFirstElement();
}
_this.enabled = true;
});
};
FocusTrap.prototype.focusIsAllowed = function (element) {
return this.container.contains(element);
};
FocusTrap.prototype.elementIsInPage = function (element) {
return element && element !== document.body.parentElement;
};
FocusTrap.prototype.onFocusIn = function (e) {
if (!this.enabled) {
return;
}
var oldElement = e.relatedTarget;
var handledByFocusOut = this.elementIsInPage(oldElement);
if (handledByFocusOut) {
return;
}
var newElement = e.target;
if (!this.elementIsInPage(newElement)) {
return;
}
if (!this.focusIsAllowed(newElement)) {
this.onLosingFocus(null, newElement);
}
};
FocusTrap.prototype.onFocusOut = function (e) {
if (!this.enabled) {
return;
}
var newElement = e.relatedTarget;
if (!this.elementIsInPage(newElement)) {
return;
}
if (!newElement || !this.focusIsAllowed(newElement)) {
this.onLosingFocus(e.target, newElement);
}
};
return FocusTrap;
}());
exports.FocusTrap = FocusTrap;
/***/ }),
/***/ 475:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var underscore_1 = __webpack_require__(0);
var Dom_1 = __webpack_require__(1);
function bindAnalyticsToLink(element, logAnalytics) {
var executeOnlyOnce = underscore_1.once(function () { return logAnalytics(); });
Dom_1.$$(element).on(['contextmenu', 'click', 'mousedown', 'mouseup'], executeOnlyOnce);
var longPressTimer;
Dom_1.$$(element).on('touchstart', function () {
longPressTimer = window.setTimeout(executeOnlyOnce, 1000);
});
Dom_1.$$(element).on('touchend', function () {
if (longPressTimer) {
clearTimeout(longPressTimer);
}
});
}
exports.bindAnalyticsToLink = bindAnalyticsToLink;
/***/ }),
/***/ 523:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var Dom_1 = __webpack_require__(1);
__webpack_require__(588);
function attachShadow(element, options) {
return __awaiter(this, void 0, void 0, function () {
var elementOptions, autoUpdateContainer, contentBody, onLoad, shadowRootContainer;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
elementOptions = { className: 'coveo-shadow-iframe', scrolling: 'no', title: options.title };
if (!options.useIFrame) return [3 /*break*/, 2];
autoUpdateContainer = Dom_1.$$('iframe', elementOptions).el;
onLoad = new Promise(function (resolve) { return autoUpdateContainer.addEventListener('load', function () { return resolve(); }); });
element.appendChild(autoUpdateContainer);
return [4 /*yield*/, onLoad];
case 1:
_a.sent();
contentBody = autoUpdateContainer.contentDocument.body;
return [3 /*break*/, 3];
case 2:
autoUpdateContainer = Dom_1.$$('div', elementOptions).el;
contentBody = autoUpdateContainer;
element.appendChild(autoUpdateContainer);
_a.label = 3;
case 3:
contentBody.style.margin = '0';
shadowRootContainer = Dom_1.$$('div', { style: 'overflow: auto;' }).el;
contentBody.appendChild(shadowRootContainer);
autoUpdateHeight(autoUpdateContainer, shadowRootContainer, options.onSizeChanged);
if (options.mode === 'open') {
Object.defineProperty(element, 'shadowRoot', { get: function () { return shadowRootContainer; } });
}
return [2 /*return*/, shadowRootContainer];
}
});
});
}
exports.attachShadow = attachShadow;
function autoUpdateHeight(elementToResize, content, onUpdate) {
var lastWidth = content.clientWidth;
var lastHeight = content.clientHeight;
var heightObserver = new MutationObserver(function () {
if (lastWidth === content.clientWidth && lastHeight === content.clientHeight) {
return;
}
lastWidth = content.clientWidth;
lastHeight = content.clientHeight;
elementToResize.style.width = content.clientWidth + "px";
elementToResize.style.height = content.clientHeight + "px";
if (onUpdate) {
onUpdate();
}
});
heightObserver.observe(content, {
attributes: true,
characterData: true,
childList: true,
subtree: true
});
}
/***/ }),
/***/ 535:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 561:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 588:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 589:
/***/ (function(module, exports, __webpack_require__) {
/*! @license DOMPurify 2.5.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.5.4/LICENSE */
(function (global, factory) {
true ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.DOMPurify = factory());
})(this, (function () { 'use strict';
function _typeof(obj) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var hasOwnProperty = Object.hasOwnProperty,
setPrototypeOf = Object.setPrototypeOf,
isFrozen = Object.isFrozen,
getPrototypeOf = Object.getPrototypeOf,
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
var freeze = Object.freeze,
seal = Object.seal,
create = Object.create; // eslint-disable-line import/no-mutable-exports
var _ref = typeof Reflect !== 'undefined' && Reflect,
apply = _ref.apply,
construct = _ref.construct;
if (!apply) {
apply = function apply(fun, thisValue, args) {
return fun.apply(thisValue, args);
};
}
if (!freeze) {
freeze = function freeze(x) {
return x;
};
}
if (!seal) {
seal = function seal(x) {
return x;
};
}
if (!construct) {
construct = function construct(Func, args) {
return _construct(Func, _toConsumableArray(args));
};
}
var arrayForEach = unapply(Array.prototype.forEach);
var arrayPop = unapply(Array.prototype.pop);
var arrayPush = unapply(Array.prototype.push);
var stringToLowerCase = unapply(String.prototype.toLowerCase);
var stringToString = unapply(String.prototype.toString);
var stringMatch = unapply(String.prototype.match);
var stringReplace = unapply(String.prototype.replace);
var stringIndexOf = unapply(String.prototype.indexOf);
var stringTrim = unapply(String.prototype.trim);
var regExpTest = unapply(RegExp.prototype.test);
var typeErrorCreate = unconstruct(TypeError);
function numberIsNaN(x) {
// eslint-disable-next-line unicorn/prefer-number-properties
return typeof x === 'number' && isNaN(x);
}
function unapply(func) {
return function (thisArg) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return apply(func, thisArg, args);
};
}
function unconstruct(func) {
return function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return construct(func, args);
};
}
/* Add properties to a lookup table */
function addToSet(set, array, transformCaseFunc) {
var _transformCaseFunc;
transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;
if (setPrototypeOf) {
// Make 'in' and truthy checks like Boolean(set.constructor)
// independent of any properties defined on Object.prototype.
// Prevent prototype setters from intercepting set as a this value.
setPrototypeOf(set, null);
}
var l = array.length;
while (l--) {
var element = array[l];
if (typeof element === 'string') {
var lcElement = transformCaseFunc(element);
if (lcElement !== element) {
// Config presets (e.g. tags.js, attrs.js) are immutable.
if (!isFrozen(array)) {
array[l] = lcElement;
}
element = lcElement;
}
}
set[element] = true;
}
return set;
}
/* Shallow clone an object */
function clone(object) {
var newObject = create(null);
var property;
for (property in object) {
if (apply(hasOwnProperty, object, [property]) === true) {
newObject[property] = object[property];
}
}
return newObject;
}
/* IE10 doesn't support __lookupGetter__ so lets'
* simulate it. It also automatically checks
* if the prop is function or getter and behaves
* accordingly. */
function lookupGetter(object, prop) {
while (object !== null) {
var desc = getOwnPropertyDescriptor(object, prop);
if (desc) {
if (desc.get) {
return unapply(desc.get);
}
if (typeof desc.value === 'function') {
return unapply(desc.value);
}
}
object = getPrototypeOf(object);
}
function fallbackValue(element) {
console.warn('fallback value for', element);
return null;
}
return fallbackValue;
}
var html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
// SVG
var svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
// List of SVG elements that are disallowed by default.
// We still need to know them so that we can do namespace
// checks properly in case one wants to add them to
// allow-list.
var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
var mathMl$1 = freeze(['math', 'menclose',