survey-analytics 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fesm/shared.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.2.1
2
+ * surveyjs - SurveyJS Dashboard library v2.2.2
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -140,6 +140,191 @@ var surveyStrings = englishStrings;
140
140
  localization.locales["en"] = englishStrings;
141
141
  localization.localeNames["en"] = "English";
142
142
 
143
+ class DocumentHelper {
144
+ static createSelector(options, isSelected, handler) {
145
+ const selectWrapper = document.createElement("div");
146
+ selectWrapper.className = "sa-question__select-wrapper";
147
+ const select = document.createElement("select");
148
+ select.className = "sa-question__select";
149
+ options.forEach((option) => {
150
+ let optionElement = DocumentHelper.createElement("option", "", {
151
+ value: option.value,
152
+ text: option.text,
153
+ selected: isSelected(option),
154
+ });
155
+ select.appendChild(optionElement);
156
+ });
157
+ select.onchange = handler;
158
+ selectWrapper.appendChild(select);
159
+ return selectWrapper;
160
+ }
161
+ static createButton(handler, text = "", className = "sa-toolbar__button") {
162
+ const button = DocumentHelper.createElement("span", className, {
163
+ innerText: text,
164
+ onclick: handler,
165
+ });
166
+ return button;
167
+ }
168
+ static createElement(tagName, className = "", attrs) {
169
+ var el = document.createElement(tagName);
170
+ el.className = className;
171
+ if (!!attrs) {
172
+ Object.keys(attrs).forEach(function (key) {
173
+ el[key] = attrs[key];
174
+ });
175
+ }
176
+ return el;
177
+ }
178
+ static createSvgElement(path) {
179
+ const svgElem = document.createElementNS("http://www.w3.org/2000/svg", "svg");
180
+ const useElem = document.createElementNS("http://www.w3.org/2000/svg", "use");
181
+ useElem.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#sa-svg-" + path);
182
+ svgElem.appendChild(useElem);
183
+ return svgElem;
184
+ }
185
+ static createSvgButton(path) {
186
+ const btn = (DocumentHelper.createElement("button", "sa-table__svg-button"));
187
+ btn.appendChild(DocumentHelper.createSvgElement(path));
188
+ return btn;
189
+ }
190
+ static createSvgToggleButton(svgPath1, svPpath2, text1, text2, handler1, handler2, state = "first", className = "sa-toolbar__button sa-toolbar__svg-button") {
191
+ const svg1 = DocumentHelper.createSvgElement(svgPath1);
192
+ const svg2 = DocumentHelper.createSvgElement(svPpath2);
193
+ const button = DocumentHelper.createElement("button", className);
194
+ const toggle = (e) => {
195
+ if (state === "first") {
196
+ state = "second";
197
+ button.title = text2;
198
+ button.removeChild(svg1);
199
+ button.appendChild(svg2);
200
+ handler2(e);
201
+ }
202
+ else if (state === "second") {
203
+ state = "first";
204
+ button.title = text1;
205
+ button.removeChild(svg2);
206
+ button.appendChild(svg1);
207
+ handler1(e);
208
+ }
209
+ };
210
+ if (state === "first") {
211
+ button.title = text1;
212
+ button.appendChild(svg1);
213
+ }
214
+ else if ((state = "second")) {
215
+ button.title = text2;
216
+ button.appendChild(svg2);
217
+ }
218
+ button.onclick = toggle;
219
+ return button;
220
+ }
221
+ static createInput(className, placeholder = "", defaultValue = "") {
222
+ var el = DocumentHelper.createElement("input", className, {
223
+ placeholder: placeholder,
224
+ defaultValue: defaultValue,
225
+ });
226
+ return el;
227
+ }
228
+ }
229
+ function createCommercialLicenseLink() {
230
+ const container = DocumentHelper.createElement("div", "sa-commercial");
231
+ const link = DocumentHelper.createElement("a", "sa-commercial__text", {
232
+ href: "https://www.surveyjs.io/Buy",
233
+ target: "_blank",
234
+ });
235
+ const containerSpan = DocumentHelper.createElement("span", "");
236
+ const icon = DocumentHelper.createSvgElement("noncommercial");
237
+ const textSpan = DocumentHelper.createElement("span", "sa-commercial__product", {
238
+ innerText: "Please purchase a SurveyJS Analytics developer license to use it in your app.",
239
+ });
240
+ container.appendChild(link).appendChild(containerSpan);
241
+ containerSpan.appendChild(icon);
242
+ containerSpan.appendChild(textSpan);
243
+ return container;
244
+ }
245
+ function createLoadingIndicator() {
246
+ const container = DocumentHelper.createElement("div", "sa-data-loading-indicator-panel");
247
+ const loadingIndicator = DocumentHelper.createElement("div", "sa-data-loading-indicator");
248
+ loadingIndicator.innerHTML = `
249
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
250
+ <g clip-path="url(#clip0_17928_11482)">
251
+ <path d="M32 64C14.36 64 0 49.65 0 32C0 14.35 14.36 0 32 0C49.64 0 64 14.35 64 32C64 49.65 49.64 64 32 64ZM32 4C16.56 4 4 16.56 4 32C4 47.44 16.56 60 32 60C47.44 60 60 47.44 60 32C60 16.56 47.44 4 32 4Z" fill="#E5E5E5"></path>
252
+ <path d="M53.2101 55.2104C52.7001 55.2104 52.1901 55.0104 51.8001 54.6204C51.0201 53.8404 51.0201 52.5704 51.8001 51.7904C57.0901 46.5004 60.0001 39.4704 60.0001 31.9904C60.0001 24.5104 57.0901 17.4804 51.8001 12.1904C51.0201 11.4104 51.0201 10.1404 51.8001 9.36039C52.5801 8.58039 53.8501 8.58039 54.6301 9.36039C60.6701 15.4004 64.0001 23.4404 64.0001 31.9904C64.0001 40.5404 60.6701 48.5704 54.6301 54.6204C54.2401 55.0104 53.7301 55.2104 53.2201 55.2104H53.2101Z" fill="#19B394"></path>
253
+ </g>
254
+ <defs>
255
+ <clipPath id="clip0_17928_11482">
256
+ <rect width="64" height="64" fill="white"></rect>
257
+ </clipPath>
258
+ </defs>
259
+ </svg>
260
+ `;
261
+ container.appendChild(loadingIndicator);
262
+ return container;
263
+ }
264
+ class DataHelper {
265
+ static zipArrays(...arrays) {
266
+ let zipArray = [];
267
+ for (let i = 0; i < arrays[0].length; i++) {
268
+ zipArray[i] = [];
269
+ arrays.forEach((arr) => {
270
+ zipArray[i].push(arr[i]);
271
+ });
272
+ }
273
+ return zipArray;
274
+ }
275
+ static unzipArrays(zipArray) {
276
+ let arrays = [];
277
+ zipArray.forEach((value, i) => {
278
+ value.forEach((val, j) => {
279
+ if (!arrays[j])
280
+ arrays[j] = [];
281
+ arrays[j][i] = val;
282
+ });
283
+ });
284
+ return arrays;
285
+ }
286
+ static sortDictionary(keys, values, desc) {
287
+ let dictionary = this.zipArrays(keys, values);
288
+ let comparator = (a, b, asc = true) => {
289
+ let result = a[1] < b[1] ? 1 : a[1] == b[1] ? 0 : -1;
290
+ return asc ? result : result * -1;
291
+ };
292
+ dictionary.sort((a, b) => {
293
+ return desc ? comparator(a, b, false) : comparator(a, b);
294
+ });
295
+ let keysAndValues = this.unzipArrays(dictionary);
296
+ return { keys: keysAndValues[0], values: keysAndValues[1] };
297
+ }
298
+ static toPercentage(value, maxValue) {
299
+ return (value / maxValue) * 100;
300
+ }
301
+ }
302
+ function createLinksContainer(links) {
303
+ const linksContainer = DocumentHelper.createElement("div");
304
+ links.forEach((link) => {
305
+ linksContainer.appendChild(DocumentHelper.createElement("a", "", {
306
+ innerText: link.name,
307
+ download: link.name,
308
+ href: link.content,
309
+ }));
310
+ });
311
+ return linksContainer;
312
+ }
313
+ function createImagesContainer(links) {
314
+ const linksContainer = DocumentHelper.createElement("div");
315
+ links.forEach((link) => {
316
+ linksContainer.appendChild(DocumentHelper.createElement("img", "", {
317
+ alt: link.name,
318
+ src: link.content,
319
+ }));
320
+ });
321
+ return linksContainer;
322
+ }
323
+ function toPrecision(value, precision = 2) {
324
+ const base = Math.pow(10, precision);
325
+ return Math.round(base * value) / base;
326
+ }
327
+
143
328
  // This dictionary contains 1 untranslated or inherited localization strings.
144
329
  // These strings are commented out. Uncomment and edit them if you want to add your translations.
145
330
  var farsiStrings = {
@@ -1226,191 +1411,6 @@ var finnishStrings = {
1226
1411
  localization.locales["fi"] = finnishStrings;
1227
1412
  localization.localeNames["fi"] = "Suomi";
1228
1413
 
1229
- class DocumentHelper {
1230
- static createSelector(options, isSelected, handler) {
1231
- const selectWrapper = document.createElement("div");
1232
- selectWrapper.className = "sa-question__select-wrapper";
1233
- const select = document.createElement("select");
1234
- select.className = "sa-question__select";
1235
- options.forEach((option) => {
1236
- let optionElement = DocumentHelper.createElement("option", "", {
1237
- value: option.value,
1238
- text: option.text,
1239
- selected: isSelected(option),
1240
- });
1241
- select.appendChild(optionElement);
1242
- });
1243
- select.onchange = handler;
1244
- selectWrapper.appendChild(select);
1245
- return selectWrapper;
1246
- }
1247
- static createButton(handler, text = "", className = "sa-toolbar__button") {
1248
- const button = DocumentHelper.createElement("span", className, {
1249
- innerText: text,
1250
- onclick: handler,
1251
- });
1252
- return button;
1253
- }
1254
- static createElement(tagName, className = "", attrs) {
1255
- var el = document.createElement(tagName);
1256
- el.className = className;
1257
- if (!!attrs) {
1258
- Object.keys(attrs).forEach(function (key) {
1259
- el[key] = attrs[key];
1260
- });
1261
- }
1262
- return el;
1263
- }
1264
- static createSvgElement(path) {
1265
- const svgElem = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1266
- const useElem = document.createElementNS("http://www.w3.org/2000/svg", "use");
1267
- useElem.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#sa-svg-" + path);
1268
- svgElem.appendChild(useElem);
1269
- return svgElem;
1270
- }
1271
- static createSvgButton(path) {
1272
- const btn = (DocumentHelper.createElement("button", "sa-table__svg-button"));
1273
- btn.appendChild(DocumentHelper.createSvgElement(path));
1274
- return btn;
1275
- }
1276
- static createSvgToggleButton(svgPath1, svPpath2, text1, text2, handler1, handler2, state = "first", className = "sa-toolbar__button sa-toolbar__svg-button") {
1277
- const svg1 = DocumentHelper.createSvgElement(svgPath1);
1278
- const svg2 = DocumentHelper.createSvgElement(svPpath2);
1279
- const button = DocumentHelper.createElement("button", className);
1280
- const toggle = (e) => {
1281
- if (state === "first") {
1282
- state = "second";
1283
- button.title = text2;
1284
- button.removeChild(svg1);
1285
- button.appendChild(svg2);
1286
- handler2(e);
1287
- }
1288
- else if (state === "second") {
1289
- state = "first";
1290
- button.title = text1;
1291
- button.removeChild(svg2);
1292
- button.appendChild(svg1);
1293
- handler1(e);
1294
- }
1295
- };
1296
- if (state === "first") {
1297
- button.title = text1;
1298
- button.appendChild(svg1);
1299
- }
1300
- else if ((state = "second")) {
1301
- button.title = text2;
1302
- button.appendChild(svg2);
1303
- }
1304
- button.onclick = toggle;
1305
- return button;
1306
- }
1307
- static createInput(className, placeholder = "", defaultValue = "") {
1308
- var el = DocumentHelper.createElement("input", className, {
1309
- placeholder: placeholder,
1310
- defaultValue: defaultValue,
1311
- });
1312
- return el;
1313
- }
1314
- }
1315
- function createCommercialLicenseLink() {
1316
- const container = DocumentHelper.createElement("div", "sa-commercial");
1317
- const link = DocumentHelper.createElement("a", "sa-commercial__text", {
1318
- href: "https://www.surveyjs.io/Buy",
1319
- target: "_blank",
1320
- });
1321
- const containerSpan = DocumentHelper.createElement("span", "");
1322
- const icon = DocumentHelper.createSvgElement("noncommercial");
1323
- const textSpan = DocumentHelper.createElement("span", "sa-commercial__product", {
1324
- innerText: "Please purchase a SurveyJS Analytics developer license to use it in your app.",
1325
- });
1326
- container.appendChild(link).appendChild(containerSpan);
1327
- containerSpan.appendChild(icon);
1328
- containerSpan.appendChild(textSpan);
1329
- return container;
1330
- }
1331
- function createLoadingIndicator() {
1332
- const container = DocumentHelper.createElement("div", "sa-data-loading-indicator-panel");
1333
- const loadingIndicator = DocumentHelper.createElement("div", "sa-data-loading-indicator");
1334
- loadingIndicator.innerHTML = `
1335
- <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
1336
- <g clip-path="url(#clip0_17928_11482)">
1337
- <path d="M32 64C14.36 64 0 49.65 0 32C0 14.35 14.36 0 32 0C49.64 0 64 14.35 64 32C64 49.65 49.64 64 32 64ZM32 4C16.56 4 4 16.56 4 32C4 47.44 16.56 60 32 60C47.44 60 60 47.44 60 32C60 16.56 47.44 4 32 4Z" fill="#E5E5E5"></path>
1338
- <path d="M53.2101 55.2104C52.7001 55.2104 52.1901 55.0104 51.8001 54.6204C51.0201 53.8404 51.0201 52.5704 51.8001 51.7904C57.0901 46.5004 60.0001 39.4704 60.0001 31.9904C60.0001 24.5104 57.0901 17.4804 51.8001 12.1904C51.0201 11.4104 51.0201 10.1404 51.8001 9.36039C52.5801 8.58039 53.8501 8.58039 54.6301 9.36039C60.6701 15.4004 64.0001 23.4404 64.0001 31.9904C64.0001 40.5404 60.6701 48.5704 54.6301 54.6204C54.2401 55.0104 53.7301 55.2104 53.2201 55.2104H53.2101Z" fill="#19B394"></path>
1339
- </g>
1340
- <defs>
1341
- <clipPath id="clip0_17928_11482">
1342
- <rect width="64" height="64" fill="white"></rect>
1343
- </clipPath>
1344
- </defs>
1345
- </svg>
1346
- `;
1347
- container.appendChild(loadingIndicator);
1348
- return container;
1349
- }
1350
- class DataHelper {
1351
- static zipArrays(...arrays) {
1352
- let zipArray = [];
1353
- for (let i = 0; i < arrays[0].length; i++) {
1354
- zipArray[i] = [];
1355
- arrays.forEach((arr) => {
1356
- zipArray[i].push(arr[i]);
1357
- });
1358
- }
1359
- return zipArray;
1360
- }
1361
- static unzipArrays(zipArray) {
1362
- let arrays = [];
1363
- zipArray.forEach((value, i) => {
1364
- value.forEach((val, j) => {
1365
- if (!arrays[j])
1366
- arrays[j] = [];
1367
- arrays[j][i] = val;
1368
- });
1369
- });
1370
- return arrays;
1371
- }
1372
- static sortDictionary(keys, values, desc) {
1373
- let dictionary = this.zipArrays(keys, values);
1374
- let comparator = (a, b, asc = true) => {
1375
- let result = a[1] < b[1] ? 1 : a[1] == b[1] ? 0 : -1;
1376
- return asc ? result : result * -1;
1377
- };
1378
- dictionary.sort((a, b) => {
1379
- return desc ? comparator(a, b, false) : comparator(a, b);
1380
- });
1381
- let keysAndValues = this.unzipArrays(dictionary);
1382
- return { keys: keysAndValues[0], values: keysAndValues[1] };
1383
- }
1384
- static toPercentage(value, maxValue) {
1385
- return (value / maxValue) * 100;
1386
- }
1387
- }
1388
- function createLinksContainer(links) {
1389
- const linksContainer = DocumentHelper.createElement("div");
1390
- links.forEach((link) => {
1391
- linksContainer.appendChild(DocumentHelper.createElement("a", "", {
1392
- innerText: link.name,
1393
- download: link.name,
1394
- href: link.content,
1395
- }));
1396
- });
1397
- return linksContainer;
1398
- }
1399
- function createImagesContainer(links) {
1400
- const linksContainer = DocumentHelper.createElement("div");
1401
- links.forEach((link) => {
1402
- linksContainer.appendChild(DocumentHelper.createElement("img", "", {
1403
- alt: link.name,
1404
- src: link.content,
1405
- }));
1406
- });
1407
- return linksContainer;
1408
- }
1409
- function toPrecision(value, precision = 2) {
1410
- const base = Math.pow(10, precision);
1411
- return Math.round(base * value) / base;
1412
- }
1413
-
1414
1414
  var iconsData = {
1415
1415
  "detail": "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><g><circle cx=\"1.5\" cy=\"8.5\" r=\"1.5\"></circle><circle cx=\"7.5\" cy=\"8.5\" r=\"1.5\"></circle><circle cx=\"13.5\" cy=\"8.5\" r=\"1.5\"></circle></g></svg>",
1416
1416
  "drag": "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><g><polygon points=\"13,5 12,6 13,7 9,7 9,3 10,4 11,3 8,0 5,3 6,4 7,3 7,7 3,7 4,6 3,5 0,8 3,11 4,10 3,9 7,9 7,13 6,12 5,13 8,16 11,13 10,12 9,13 9,9 13,9 12,10 13,11 16,8 \"></polygon></g></svg>",
@@ -1441,5 +1441,5 @@ function getIconSymbolTemplate(iconId, iconSvg) {
1441
1441
  const iconsHtml = Object.keys(iconsData).map(iconId => getIconSymbolTemplate(iconId, iconsData[iconId]));
1442
1442
  const svgTemplate = `<svg style="display:none;">${iconsHtml}<svg>`;
1443
1443
 
1444
- export { DocumentHelper as D, DataHelper as a, createCommercialLicenseLink as b, createLoadingIndicator as c, surveyStrings as d, createImagesContainer as e, createLinksContainer as f, localization as l, svgTemplate as s, toPrecision as t };
1444
+ export { DocumentHelper as D, DataHelper as a, createLinksContainer as b, createImagesContainer as c, createCommercialLicenseLink as d, svgTemplate as e, createLoadingIndicator as f, localization as l, surveyStrings as s, toPrecision as t };
1445
1445
  //# sourceMappingURL=shared.mjs.map