@everymatrix/helper-filters 1.87.25 → 1.87.27

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.
@@ -4,6 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-3fa5f550.js');
6
6
 
7
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
8
+
7
9
  /**
8
10
  * @name setClientStyling
9
11
  * @description Method used to create and append to the passed element of the widget a style element with the content received
@@ -49,18 +51,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
49
51
  * @param {HTMLElement} stylingContainer The highest element of the widget
50
52
  * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
51
53
  * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
54
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
52
55
  */
53
- function setStreamStyling(stylingContainer, domain, subscription) {
54
- if (window.emMessageBus) {
55
- const sheet = document.createElement('style');
56
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
57
+ if (!window.emMessageBus) return;
56
58
 
57
- window.emMessageBus.subscribe(domain, (data) => {
58
- sheet.innerHTML = data;
59
- if (stylingContainer) {
60
- stylingContainer.appendChild(sheet);
61
- }
62
- });
59
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
60
+
61
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
62
+ subscription = getStyleTagSubscription(stylingContainer, domain);
63
+
64
+ return subscription;
63
65
  }
66
+
67
+ if (!window[StyleCacheKey]) {
68
+ window[StyleCacheKey] = {};
69
+ }
70
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
71
+
72
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
73
+ const wrappedUnsubscribe = () => {
74
+ if (window[StyleCacheKey][domain]) {
75
+ const cachedObject = window[StyleCacheKey][domain];
76
+ cachedObject.refCount > 1
77
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
78
+ : delete window[StyleCacheKey][domain];
79
+ }
80
+
81
+ originalUnsubscribe();
82
+ };
83
+ subscription.unsubscribe = wrappedUnsubscribe;
84
+
85
+ return subscription;
86
+ }
87
+
88
+ function getStyleTagSubscription(stylingContainer, domain) {
89
+ const sheet = document.createElement('style');
90
+
91
+ return window.emMessageBus.subscribe(domain, (data) => {
92
+ if (stylingContainer) {
93
+ sheet.innerHTML = data;
94
+ stylingContainer.appendChild(sheet);
95
+ }
96
+ });
97
+ }
98
+
99
+ function getAdoptStyleSubscription(stylingContainer, domain) {
100
+ return window.emMessageBus.subscribe(domain, (data) => {
101
+ if (!stylingContainer) return;
102
+
103
+ const shadowRoot = stylingContainer.getRootNode();
104
+ const cacheStyleObject = window[StyleCacheKey];
105
+ let cachedStyle = cacheStyleObject[domain]?.sheet;
106
+
107
+ if (!cachedStyle) {
108
+ cachedStyle = new CSSStyleSheet();
109
+ cachedStyle.replaceSync(data);
110
+ cacheStyleObject[domain] = {
111
+ sheet: cachedStyle,
112
+ refCount: 1
113
+ };
114
+ } else {
115
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
116
+ }
117
+
118
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
119
+ if (!currentSheets.includes(cachedStyle)) {
120
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
121
+ }
122
+ });
64
123
  }
65
124
 
66
125
  const generalMultiSelectCss = ".multi-select-container{position:relative;font-family:\"Inter\", sans-serif;margin-top:4px;width:100%}.flex-row{display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;padding:8px 12px;padding-right:4px;border-radius:4px;background:var(--emw-selector-color-background, #e8ebef);cursor:pointer}.control{flex:1;display:flex;align-items:center;flex-wrap:nowrap;overflow:hidden}.control:focus-within{border-color:var(--emw--color-primary, #fed275);box-shadow:0 0 0 2px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15))}.chip{display:inline-flex;align-items:center;background:var(--emw--color-gray-50, #f5f5f5);color:var(--emw--color-dialog-typography, #000);border-radius:4px;padding:2px 8px;margin-right:6px;font-size:0.875rem;line-height:1.2;justify-content:space-between;flex:0 1 auto;min-width:0}.chip-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.overflow-chip{background:var(--emw--color-gray-100, #e6e6e6);color:var(--emw--color-gray-300, #333);width:20px;text-align:center;display:block}.remove-btn{background:none;border:none;font-size:1rem;margin-left:6px;cursor:pointer;color:var(--emw--color-gray-150, #6f6f6f)}.remove-btn:hover{color:var(--emw--color-error, red)}.placeholder{color:var(--emw--color-gray-150, #6f6f6f);font-size:0.875rem;padding:3px 8px;line-height:1.2}.arrow{margin-left:auto;font-size:0.8rem;width:20px;color:var(--emw--color-gray-150, #6f6f6f)}.dropdown{position:absolute;top:calc(100% + 4px);left:0;width:100%;max-height:240px;overflow-y:auto;border:1px solid var(--emw--color-gray-100, #e6e6e6);border-radius:6px;background:var(--emw--color-dialog-background, #ffffff);box-shadow:0 4px 12px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15));z-index:10}.dropdown-item{padding:10px 14px;cursor:pointer;font-size:0.875rem;line-height:1.4;transition:background 0.2s}.dropdown-item:hover{background:var(--emw--color-background-tertiary, #ccc);color:var(--emw--color-typography, #000)}.dropdown-item.selected{background:var(--emw--color-background-secondary, #f5f5f5);color:var(--emw--color-typography, #000);font-weight:500}.overflow-popover{position:absolute;top:var(--overflow-top, 0px);left:var(--overflow-left, 0px);max-width:200px;padding:12px;display:flex;flex-wrap:wrap;gap:6px;border:1px solid var(--emw--color-gray-100, #d0d5dd);border-radius:6px;background:var(--emw--color-background, #ffffff);box-shadow:0 4px 12px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15));z-index:20}";
@@ -149,13 +208,13 @@ const GeneralMultiSelect = class {
149
208
  }
150
209
  handleMbSourceChange(newValue, oldValue) {
151
210
  if (newValue != oldValue) {
152
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
211
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
153
212
  }
154
213
  }
155
214
  componentDidLoad() {
156
215
  if (this.stylingContainer) {
157
216
  if (this.mbSource)
158
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
217
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
159
218
  if (this.clientStyling)
160
219
  setClientStyling(this.stylingContainer, this.clientStyling);
161
220
  if (this.clientStylingUrl)
@@ -1,5 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, g as getAssetPath, h } from './index-2b6335f5.js';
2
2
 
3
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
4
+
3
5
  /**
4
6
  * @name setClientStyling
5
7
  * @description Method used to create and append to the passed element of the widget a style element with the content received
@@ -45,18 +47,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
45
47
  * @param {HTMLElement} stylingContainer The highest element of the widget
46
48
  * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
47
49
  * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
50
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
48
51
  */
49
- function setStreamStyling(stylingContainer, domain, subscription) {
50
- if (window.emMessageBus) {
51
- const sheet = document.createElement('style');
52
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
53
+ if (!window.emMessageBus) return;
52
54
 
53
- window.emMessageBus.subscribe(domain, (data) => {
54
- sheet.innerHTML = data;
55
- if (stylingContainer) {
56
- stylingContainer.appendChild(sheet);
57
- }
58
- });
55
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
56
+
57
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
58
+ subscription = getStyleTagSubscription(stylingContainer, domain);
59
+
60
+ return subscription;
59
61
  }
62
+
63
+ if (!window[StyleCacheKey]) {
64
+ window[StyleCacheKey] = {};
65
+ }
66
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
67
+
68
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
69
+ const wrappedUnsubscribe = () => {
70
+ if (window[StyleCacheKey][domain]) {
71
+ const cachedObject = window[StyleCacheKey][domain];
72
+ cachedObject.refCount > 1
73
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
74
+ : delete window[StyleCacheKey][domain];
75
+ }
76
+
77
+ originalUnsubscribe();
78
+ };
79
+ subscription.unsubscribe = wrappedUnsubscribe;
80
+
81
+ return subscription;
82
+ }
83
+
84
+ function getStyleTagSubscription(stylingContainer, domain) {
85
+ const sheet = document.createElement('style');
86
+
87
+ return window.emMessageBus.subscribe(domain, (data) => {
88
+ if (stylingContainer) {
89
+ sheet.innerHTML = data;
90
+ stylingContainer.appendChild(sheet);
91
+ }
92
+ });
93
+ }
94
+
95
+ function getAdoptStyleSubscription(stylingContainer, domain) {
96
+ return window.emMessageBus.subscribe(domain, (data) => {
97
+ if (!stylingContainer) return;
98
+
99
+ const shadowRoot = stylingContainer.getRootNode();
100
+ const cacheStyleObject = window[StyleCacheKey];
101
+ let cachedStyle = cacheStyleObject[domain]?.sheet;
102
+
103
+ if (!cachedStyle) {
104
+ cachedStyle = new CSSStyleSheet();
105
+ cachedStyle.replaceSync(data);
106
+ cacheStyleObject[domain] = {
107
+ sheet: cachedStyle,
108
+ refCount: 1
109
+ };
110
+ } else {
111
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
112
+ }
113
+
114
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
115
+ if (!currentSheets.includes(cachedStyle)) {
116
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
117
+ }
118
+ });
60
119
  }
61
120
 
62
121
  const generalMultiSelectCss = ".multi-select-container{position:relative;font-family:\"Inter\", sans-serif;margin-top:4px;width:100%}.flex-row{display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;padding:8px 12px;padding-right:4px;border-radius:4px;background:var(--emw-selector-color-background, #e8ebef);cursor:pointer}.control{flex:1;display:flex;align-items:center;flex-wrap:nowrap;overflow:hidden}.control:focus-within{border-color:var(--emw--color-primary, #fed275);box-shadow:0 0 0 2px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15))}.chip{display:inline-flex;align-items:center;background:var(--emw--color-gray-50, #f5f5f5);color:var(--emw--color-dialog-typography, #000);border-radius:4px;padding:2px 8px;margin-right:6px;font-size:0.875rem;line-height:1.2;justify-content:space-between;flex:0 1 auto;min-width:0}.chip-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.overflow-chip{background:var(--emw--color-gray-100, #e6e6e6);color:var(--emw--color-gray-300, #333);width:20px;text-align:center;display:block}.remove-btn{background:none;border:none;font-size:1rem;margin-left:6px;cursor:pointer;color:var(--emw--color-gray-150, #6f6f6f)}.remove-btn:hover{color:var(--emw--color-error, red)}.placeholder{color:var(--emw--color-gray-150, #6f6f6f);font-size:0.875rem;padding:3px 8px;line-height:1.2}.arrow{margin-left:auto;font-size:0.8rem;width:20px;color:var(--emw--color-gray-150, #6f6f6f)}.dropdown{position:absolute;top:calc(100% + 4px);left:0;width:100%;max-height:240px;overflow-y:auto;border:1px solid var(--emw--color-gray-100, #e6e6e6);border-radius:6px;background:var(--emw--color-dialog-background, #ffffff);box-shadow:0 4px 12px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15));z-index:10}.dropdown-item{padding:10px 14px;cursor:pointer;font-size:0.875rem;line-height:1.4;transition:background 0.2s}.dropdown-item:hover{background:var(--emw--color-background-tertiary, #ccc);color:var(--emw--color-typography, #000)}.dropdown-item.selected{background:var(--emw--color-background-secondary, #f5f5f5);color:var(--emw--color-typography, #000);font-weight:500}.overflow-popover{position:absolute;top:var(--overflow-top, 0px);left:var(--overflow-left, 0px);max-width:200px;padding:12px;display:flex;flex-wrap:wrap;gap:6px;border:1px solid var(--emw--color-gray-100, #d0d5dd);border-radius:6px;background:var(--emw--color-background, #ffffff);box-shadow:0 4px 12px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15));z-index:20}";
@@ -145,13 +204,13 @@ const GeneralMultiSelect = class {
145
204
  }
146
205
  handleMbSourceChange(newValue, oldValue) {
147
206
  if (newValue != oldValue) {
148
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
207
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
149
208
  }
150
209
  }
151
210
  componentDidLoad() {
152
211
  if (this.stylingContainer) {
153
212
  if (this.mbSource)
154
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
213
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
155
214
  if (this.clientStyling)
156
215
  setClientStyling(this.stylingContainer, this.clientStyling);
157
216
  if (this.clientStylingUrl)