@qrvey/utils 1.11.0-2 → 1.11.0-3

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.
@@ -51,3 +51,8 @@ export interface IScriptItem {
51
51
  }
52
52
  export type TScriptItem = string | IScriptItem;
53
53
  export type TScriptType = "text/javascript" | "module" | string;
54
+ declare global {
55
+ interface Window {
56
+ loadedQrveyLibraries: string[];
57
+ }
58
+ }
@@ -37,18 +37,20 @@ exports.loadScript = exports.importScripts = void 0;
37
37
  * ]);
38
38
  */
39
39
  function importScripts(scripts) {
40
+ if (!window.loadedQrveyLibraries)
41
+ window.loadedQrveyLibraries = [];
40
42
  const promiseList = scripts.map((script) => {
41
43
  if (typeof script === "string") {
44
+ if (window.loadedQrveyLibraries.includes(script))
45
+ return;
42
46
  return loadScript(script);
43
47
  }
44
- if (script.namespace) {
45
- const exist = typeof script.namespace === "function"
46
- ? script.namespace()
47
- : window[script.namespace];
48
- if (exist) {
49
- return script.dependencies && importScripts(script.dependencies);
50
- }
51
- return loadScript(script.url, script.type, script.noModule).then(() => script.dependencies && importScripts(script.dependencies));
48
+ const exist = typeof script.namespace === "function"
49
+ ? script.namespace()
50
+ : window[script.namespace] ||
51
+ window.loadedQrveyLibraries.includes(script.url);
52
+ if (exist) {
53
+ return script.dependencies && importScripts(script.dependencies);
52
54
  }
53
55
  return loadScript(script.url, script.type, script.noModule).then(() => script.dependencies && importScripts(script.dependencies));
54
56
  });
@@ -68,12 +70,16 @@ function loadScript(url, type = "text/javascript", noModule = false) {
68
70
  type,
69
71
  noModule,
70
72
  defer: true,
71
- onload: resolve,
72
73
  src: url,
74
+ onload: () => {
75
+ window.loadedQrveyLibraries.push(url);
76
+ resolve();
77
+ },
73
78
  }));
74
79
  if (noModule && "noModule" in HTMLScriptElement.prototype) {
75
80
  // this Browser support ES6 module.
76
81
  // so, this script is not going to call onload method. resolving manually ....
82
+ window.loadedQrveyLibraries.push(url);
77
83
  resolve();
78
84
  }
79
85
  });
@@ -11,6 +11,7 @@ export interface II18nFilterPanel {
11
11
  card_all_except: string;
12
12
  card_all_selected: string;
13
13
  card_none_selected: string;
14
+ card_no_items: string;
14
15
  collapsed_title: string;
15
16
  delete_dialog: II18nFilterPanelDeleteDialog;
16
17
  empty_state: II18nFilterPanelEmptyState;
@@ -7,6 +7,7 @@ exports.I18N_FILTER_PANEL = {
7
7
  aggregated_filters_tooltip: "Logic is not editable for aggregated filters",
8
8
  card_all_except: "All Except:",
9
9
  card_all_selected: "All Selected",
10
+ card_no_items: "No items to filter",
10
11
  card_none_selected: "None",
11
12
  empty_state: {
12
13
  description: "No filters added",
@@ -51,3 +51,8 @@ export interface IScriptItem {
51
51
  }
52
52
  export type TScriptItem = string | IScriptItem;
53
53
  export type TScriptType = "text/javascript" | "module" | string;
54
+ declare global {
55
+ interface Window {
56
+ loadedQrveyLibraries: string[];
57
+ }
58
+ }
@@ -34,18 +34,20 @@
34
34
  * ]);
35
35
  */
36
36
  export function importScripts(scripts) {
37
+ if (!window.loadedQrveyLibraries)
38
+ window.loadedQrveyLibraries = [];
37
39
  const promiseList = scripts.map((script) => {
38
40
  if (typeof script === "string") {
41
+ if (window.loadedQrveyLibraries.includes(script))
42
+ return;
39
43
  return loadScript(script);
40
44
  }
41
- if (script.namespace) {
42
- const exist = typeof script.namespace === "function"
43
- ? script.namespace()
44
- : window[script.namespace];
45
- if (exist) {
46
- return script.dependencies && importScripts(script.dependencies);
47
- }
48
- return loadScript(script.url, script.type, script.noModule).then(() => script.dependencies && importScripts(script.dependencies));
45
+ const exist = typeof script.namespace === "function"
46
+ ? script.namespace()
47
+ : window[script.namespace] ||
48
+ window.loadedQrveyLibraries.includes(script.url);
49
+ if (exist) {
50
+ return script.dependencies && importScripts(script.dependencies);
49
51
  }
50
52
  return loadScript(script.url, script.type, script.noModule).then(() => script.dependencies && importScripts(script.dependencies));
51
53
  });
@@ -64,12 +66,16 @@ export function loadScript(url, type = "text/javascript", noModule = false) {
64
66
  type,
65
67
  noModule,
66
68
  defer: true,
67
- onload: resolve,
68
69
  src: url,
70
+ onload: () => {
71
+ window.loadedQrveyLibraries.push(url);
72
+ resolve();
73
+ },
69
74
  }));
70
75
  if (noModule && "noModule" in HTMLScriptElement.prototype) {
71
76
  // this Browser support ES6 module.
72
77
  // so, this script is not going to call onload method. resolving manually ....
78
+ window.loadedQrveyLibraries.push(url);
73
79
  resolve();
74
80
  }
75
81
  });
@@ -11,6 +11,7 @@ export interface II18nFilterPanel {
11
11
  card_all_except: string;
12
12
  card_all_selected: string;
13
13
  card_none_selected: string;
14
+ card_no_items: string;
14
15
  collapsed_title: string;
15
16
  delete_dialog: II18nFilterPanelDeleteDialog;
16
17
  empty_state: II18nFilterPanelEmptyState;
@@ -4,6 +4,7 @@ export const I18N_FILTER_PANEL = {
4
4
  aggregated_filters_tooltip: "Logic is not editable for aggregated filters",
5
5
  card_all_except: "All Except:",
6
6
  card_all_selected: "All Selected",
7
+ card_no_items: "No items to filter",
7
8
  card_none_selected: "None",
8
9
  empty_state: {
9
10
  description: "No filters added",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.11.0-2",
3
+ "version": "1.11.0-3",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",