@everymatrix/lottery-oddsbom-bullet-group 0.7.26 → 0.7.28

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const lotteryOddsbomBulletGroup = require('./lottery-oddsbom-bullet-group-a0684dc8.js');
5
+ const lotteryOddsbomBulletGroup = require('./lottery-oddsbom-bullet-group-001f8c5a.js');
6
6
  require('./index-887155dc.js');
7
7
 
8
8
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  const index = require('./index-887155dc.js');
4
4
 
5
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
6
+
5
7
  /**
6
8
  * @name setClientStyling
7
9
  * @description Method used to create and append to the passed element of the widget a style element with the content received
@@ -47,18 +49,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
47
49
  * @param {HTMLElement} stylingContainer The highest element of the widget
48
50
  * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
49
51
  * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
52
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
50
53
  */
51
- function setStreamStyling(stylingContainer, domain, subscription) {
52
- if (window.emMessageBus) {
53
- const sheet = document.createElement('style');
54
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
55
+ if (!window.emMessageBus) return;
54
56
 
55
- window.emMessageBus.subscribe(domain, (data) => {
56
- sheet.innerHTML = data;
57
- if (stylingContainer) {
58
- stylingContainer.appendChild(sheet);
59
- }
60
- });
57
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
58
+
59
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
60
+ subscription = getStyleTagSubscription(stylingContainer, domain);
61
+
62
+ return subscription;
63
+ }
64
+
65
+ if (!window[StyleCacheKey]) {
66
+ window[StyleCacheKey] = {};
61
67
  }
68
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
69
+
70
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
71
+ const wrappedUnsubscribe = () => {
72
+ if (window[StyleCacheKey][domain]) {
73
+ const cachedObject = window[StyleCacheKey][domain];
74
+ cachedObject.refCount > 1
75
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
76
+ : delete window[StyleCacheKey][domain];
77
+ }
78
+
79
+ originalUnsubscribe();
80
+ };
81
+ subscription.unsubscribe = wrappedUnsubscribe;
82
+
83
+ return subscription;
84
+ }
85
+
86
+ function getStyleTagSubscription(stylingContainer, domain) {
87
+ const sheet = document.createElement('style');
88
+
89
+ return window.emMessageBus.subscribe(domain, (data) => {
90
+ if (stylingContainer) {
91
+ sheet.innerHTML = data;
92
+ stylingContainer.appendChild(sheet);
93
+ }
94
+ });
95
+ }
96
+
97
+ function getAdoptStyleSubscription(stylingContainer, domain) {
98
+ return window.emMessageBus.subscribe(domain, (data) => {
99
+ if (!stylingContainer) return;
100
+
101
+ const shadowRoot = stylingContainer.getRootNode();
102
+ const cacheStyleObject = window[StyleCacheKey];
103
+ let cachedStyle = cacheStyleObject[domain]?.sheet;
104
+
105
+ if (!cachedStyle) {
106
+ cachedStyle = new CSSStyleSheet();
107
+ cachedStyle.replaceSync(data);
108
+ cacheStyleObject[domain] = {
109
+ sheet: cachedStyle,
110
+ refCount: 1
111
+ };
112
+ } else {
113
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
114
+ }
115
+
116
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
117
+ if (!currentSheets.includes(cachedStyle)) {
118
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
119
+ }
120
+ });
62
121
  }
63
122
 
64
123
  const lotteryOddsbomBulletGroupCss = ".oddsbomBulletGroup{width:100%}.oddsbomBulletGroup .oddsbomBulletGroup-list{display:flex;flex-wrap:wrap;align-items:center;gap:12px}.oddsbomBulletGroup .selection-bullet-list{justify-content:flex-end}";
@@ -107,7 +166,7 @@ const LotteryOddsbomBulletGroup = class {
107
166
  }
108
167
  handleMbSourceChange(newValue, oldValue) {
109
168
  if (newValue != oldValue) {
110
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
169
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
111
170
  }
112
171
  }
113
172
  oddsbomBulletToggleHandler(event) {
@@ -150,7 +209,7 @@ const LotteryOddsbomBulletGroup = class {
150
209
  componentDidLoad() {
151
210
  if (this.stylingContainer) {
152
211
  if (this.mbSource)
153
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
212
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
154
213
  if (this.clientStyling)
155
214
  setClientStyling(this.stylingContainer, this.clientStyling);
156
215
  if (this.clientStylingUrl)
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-887155dc.js');
6
- const lotteryOddsbomBulletGroup = require('./lottery-oddsbom-bullet-group-a0684dc8.js');
6
+ const lotteryOddsbomBulletGroup = require('./lottery-oddsbom-bullet-group-001f8c5a.js');
7
7
 
8
8
  // This icon file is generated automatically.
9
9
  var DeleteFilled = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M864 256H736v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zm-200 0H360v-72h304v72z" } }] }, "name": "delete", "theme": "filled" };
@@ -91,13 +91,13 @@ const LotteryOddsbomBullet = class {
91
91
  }
92
92
  handleMbSourceChange(newValue, oldValue) {
93
93
  if (newValue != oldValue) {
94
- lotteryOddsbomBulletGroup.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
94
+ lotteryOddsbomBulletGroup.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
95
95
  }
96
96
  }
97
97
  componentDidLoad() {
98
98
  if (this.stylingContainer) {
99
99
  if (this.mbSource)
100
- lotteryOddsbomBulletGroup.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
100
+ lotteryOddsbomBulletGroup.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
101
101
  if (this.clientStyling)
102
102
  lotteryOddsbomBulletGroup.setClientStyling(this.stylingContainer, this.clientStyling);
103
103
  if (this.clientStylingUrl)
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { L as LotteryOddsbomBulletGroup } from './lottery-oddsbom-bullet-group-471fda1e.js';
1
+ export { L as LotteryOddsbomBulletGroup } from './lottery-oddsbom-bullet-group-d66a61e2.js';
2
2
  import './index-85e87cde.js';
@@ -1,5 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-85e87cde.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;
61
+ }
62
+
63
+ if (!window[StyleCacheKey]) {
64
+ window[StyleCacheKey] = {};
59
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 lotteryOddsbomBulletGroupCss = ".oddsbomBulletGroup{width:100%}.oddsbomBulletGroup .oddsbomBulletGroup-list{display:flex;flex-wrap:wrap;align-items:center;gap:12px}.oddsbomBulletGroup .selection-bullet-list{justify-content:flex-end}";
@@ -105,7 +164,7 @@ const LotteryOddsbomBulletGroup = class {
105
164
  }
106
165
  handleMbSourceChange(newValue, oldValue) {
107
166
  if (newValue != oldValue) {
108
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
167
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
109
168
  }
110
169
  }
111
170
  oddsbomBulletToggleHandler(event) {
@@ -148,7 +207,7 @@ const LotteryOddsbomBulletGroup = class {
148
207
  componentDidLoad() {
149
208
  if (this.stylingContainer) {
150
209
  if (this.mbSource)
151
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
210
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
152
211
  if (this.clientStyling)
153
212
  setClientStyling(this.stylingContainer, this.clientStyling);
154
213
  if (this.clientStylingUrl)
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-85e87cde.js';
2
- import { s as setClientStyling, a as setClientStylingURL, b as setStreamStyling } from './lottery-oddsbom-bullet-group-471fda1e.js';
3
- export { L as lottery_oddsbom_bullet_group } from './lottery-oddsbom-bullet-group-471fda1e.js';
2
+ import { s as setClientStyling, a as setClientStylingURL, b as setStreamStyling } from './lottery-oddsbom-bullet-group-d66a61e2.js';
3
+ export { L as lottery_oddsbom_bullet_group } from './lottery-oddsbom-bullet-group-d66a61e2.js';
4
4
 
5
5
  // This icon file is generated automatically.
6
6
  var DeleteFilled = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M864 256H736v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zm-200 0H360v-72h304v72z" } }] }, "name": "delete", "theme": "filled" };
@@ -88,13 +88,13 @@ const LotteryOddsbomBullet = class {
88
88
  }
89
89
  handleMbSourceChange(newValue, oldValue) {
90
90
  if (newValue != oldValue) {
91
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
91
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
92
92
  }
93
93
  }
94
94
  componentDidLoad() {
95
95
  if (this.stylingContainer) {
96
96
  if (this.mbSource)
97
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
97
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
98
98
  if (this.clientStyling)
99
99
  setClientStyling(this.stylingContainer, this.clientStyling);
100
100
  if (this.clientStylingUrl)
@@ -1 +1 @@
1
- export{L as LotteryOddsbomBulletGroup}from"./lottery-oddsbom-bullet-group-471fda1e.js";import"./index-85e87cde.js";
1
+ export{L as LotteryOddsbomBulletGroup}from"./lottery-oddsbom-bullet-group-d66a61e2.js";import"./index-85e87cde.js";
@@ -0,0 +1 @@
1
+ import{r as t,c as e,h as i}from"./index-85e87cde.js";const s="__WIDGET_GLOBAL_STYLE_CACHE__";function l(t,e){if(t){const i=document.createElement("style");i.innerHTML=e,t.appendChild(i)}}function o(t,e){if(!t||!e)return;const i=new URL(e);fetch(i.href).then((t=>t.text())).then((e=>{const i=document.createElement("style");i.innerHTML=e,t&&t.appendChild(i)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}function n(t,e,i,l=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!l)return i=function(t,e){const i=document.createElement("style");return window.emMessageBus.subscribe(e,(e=>{t&&(i.innerHTML=e,t.appendChild(i))}))}(t,e),i;window[s]||(window[s]={}),i=function(t,e){return window.emMessageBus.subscribe(e,(i=>{if(!t)return;const l=t.getRootNode(),o=window[s];let n=o[e]?.sheet;n?o[e].refCount=o[e].refCount+1:(n=new CSSStyleSheet,n.replaceSync(i),o[e]={sheet:n,refCount:1});const d=l.adoptedStyleSheets||[];d.includes(n)||(l.adoptedStyleSheets=[...d,n])}))}(t,e);const o=i.unsubscribe.bind(i);return i.unsubscribe=()=>{if(window[s][e]){const t=window[s][e];t.refCount>1?t.refCount=t.refCount-1:delete window[s][e]}o()},i}const d=class{constructor(i){t(this,i),this.addSelectionEvent=e(this,"addSelection",7),this.deleteSelectionEvent=e(this,"deleteSelection",7),this.deleteSelectionOriginEvent=e(this,"deleteSelectionOrigin",7),this.oddsbomBulletGroupToggleEvent=e(this,"oddsbomBulletGroupToggle",7),this.oddsbomBulletGroupAddedByMoreBtnDelEvent=e(this,"oddsbomBulletGroupAddedByMoreBtnDel",7),this.oddsbomBulletCallDialogFromGroupEvent=e(this,"oddsbomBulletCallDialogFromGroup",7),this.selectionIdx=void 0,this.matchIdx=void 0,this.bulletConfigs=[],this.bulletConfigsDeleteOrigin=[],this.addSelectionConfig=void 0,this.isDeleteByIcon=void 0,this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0,this.bulletListClass=void 0,this.innerBulletConfigs=void 0,this.innerBulletConfigsDeleteOrigin=void 0}handleBulletConfigsChange(t){this.innerBulletConfigs=t.map((t=>Object.assign({},t)))}handleBulletConfigsDeleteOriginChange(t){this.innerBulletConfigsDeleteOrigin=t.map((t=>Object.assign({},t)))}componentWillLoad(){this.handleBulletConfigsChange(this.bulletConfigs)}handleClientStylingChange(t,e){t!=e&&l(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(t,e){t!=e&&o(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(t,e){t!=e&&n(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription)}oddsbomBulletToggleHandler(t){const e=t.detail,{matchIdx:i,selectionIdx:s}=this,l=[...this.innerBulletConfigs],o=Object.assign({},l[e]);o.isSelected=!o.isSelected,l[e]=o,this.innerBulletConfigs=l,this.oddsbomBulletGroupToggleEvent.emit({bulletSelctionArr:this.innerBulletConfigs,matchIdx:i,selectionIdx:s})}oddsbomBulletDeleteHandler(t){const e=t.detail,{matchIdx:i,selectionIdx:s}=this,l=[...this.innerBulletConfigsDeleteOrigin],o=Object.assign({},l[e]);o.isSelected=!o.isSelected,l[e]=o,this.innerBulletConfigsDeleteOrigin=l,this.oddsbomBulletGroupToggleEvent.emit({bulletSelctionArr:this.innerBulletConfigsDeleteOrigin,matchIdx:i,selectionIdx:s})}oddsbomBulletAddedByMoreBtnDeleteHandler(t){const e=t.detail,{matchIdx:i,selectionIdx:s}=this;this.oddsbomBulletGroupAddedByMoreBtnDelEvent.emit({delText:e,matchIdx:i,selectionIdx:s})}componentDidLoad(){this.stylingContainer&&(this.mbSource&&n(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription),this.clientStyling&&l(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&o(this.stylingContainer,this.clientStylingUrl))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}handleOddsbomBulletCallDialog(){const{matchIdx:t,selectionIdx:e}=this;this.oddsbomBulletCallDialogFromGroupEvent.emit({matchIdx:t,selectionIdx:e})}render(){return i("div",{key:"38102a447cf8fafc8f7a7e5a122c7ccbc2ce8b4a",class:"oddsbomBulletGroup",ref:t=>this.stylingContainer=t},i("div",{key:"59ca1df498575356eb3438b45e9431b1bc7ee2dd",class:`oddsbomBulletGroup-list ${this.bulletListClass||""}`},this.innerBulletConfigs.map((t=>i("lottery-oddsbom-bullet",t.isAddMoreBtn?{text:`${this.addSelectionConfig.maxOverScore}+`,disabled:t.isDisabled,isCallDialogBtn:!0,onOddsbomBulletCallDialog:this.handleOddsbomBulletCallDialog.bind(this)}:{text:t.text,idx:t.idx,isSelected:t.isSelected,disabled:t.isDisabled,isDeleteByIcon:this.isDeleteByIcon,isAddedByMoreBtn:t.isAddedByMoreBtn})))))}static get watchers(){return{bulletConfigs:["handleBulletConfigsChange"],bulletConfigsDeleteOrigin:["handleBulletConfigsDeleteOriginChange"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"]}}};d.style=".oddsbomBulletGroup{width:100%}.oddsbomBulletGroup .oddsbomBulletGroup-list{display:flex;flex-wrap:wrap;align-items:center;gap:12px}.oddsbomBulletGroup .selection-bullet-list{justify-content:flex-end}";export{d as L,o as a,n as b,l as s}
@@ -1 +1 @@
1
- import{r as t,c as o,h as e}from"./index-85e87cde.js";import{s as l,a as s,b as d}from"./lottery-oddsbom-bullet-group-471fda1e.js";export{L as lottery_oddsbom_bullet_group}from"./lottery-oddsbom-bullet-group-471fda1e.js";var r=function(){return r=Object.assign||function(t){for(var o,e=1,l=arguments.length;e<l;e++)for(var s in o=arguments[e])Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s]);return t},r.apply(this,arguments)},n={primaryColor:"#333",secondaryColor:"#E6E6E6"};function i(t,o){var e="svg"===t.tag?r(r({},t.attrs),o.extraSVGAttrs||{}):t.attrs,l=Object.keys(e).reduce((function(t,o){var l=e[o],s="".concat(o,'="').concat(l,'"');return t.push(s),t}),[]),s=l.length?" "+l.join(" "):"",d=(t.children||[]).map((function(t){return i(t,o)})).join("");return d&&d.length?"<".concat(t.tag).concat(s,">").concat(d,"</").concat(t.tag,">"):"<".concat(t.tag).concat(s," />")}const a=function(t,o){if(void 0===o&&(o={}),"function"==typeof t.icon){var e=o.placeholders||n;return i(t.icon(e.primaryColor,e.secondaryColor),o)}return i(t.icon,o)}({icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M864 256H736v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zm-200 0H360v-72h304v72z"}}]},name:"delete",theme:"filled"},{extraSVGAttrs:{width:"18px",height:"18px",fill:""}}),h=class{constructor(e){t(this,e),this.oddsbomBulletToggleEvent=o(this,"oddsbomBulletToggle",7),this.oddsbomBulletDeleteEvent=o(this,"oddsbomBulletDelete",7),this.oddsbomBulletAddedByMoreBtnDeleteEvent=o(this,"oddsbomBulletAddedByMoreBtnDelete",7),this.oddsbomBulletCallDialogEvent=o(this,"oddsbomBulletCallDialog",7),this.isSelected=void 0,this.disabled=void 0,this.text=void 0,this.idx=void 0,this.isReading=void 0,this.isDeleteByIcon=void 0,this.isCallDialogBtn=void 0,this.isAddedByMoreBtn=void 0,this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0}handleClientStylingChange(t,o){t!=o&&l(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(t,o){t!=o&&s(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(t,o){t!=o&&d(this.stylingContainer,`${this.mbSource}.Style`)}componentDidLoad(){this.stylingContainer&&(this.mbSource&&d(this.stylingContainer,`${this.mbSource}.Style`),this.clientStyling&&l(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&s(this.stylingContainer,this.clientStylingUrl))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}handleClick(){this.isCallDialogBtn?this.oddsbomBulletCallDialogEvent.emit():this.isDeleteByIcon?this.isAddedByMoreBtn?this.oddsbomBulletAddedByMoreBtnDeleteEvent.emit(this.text):this.oddsbomBulletDeleteEvent.emit(this.idx):this.disabled||this.oddsbomBulletToggleEvent.emit(this.idx)}render(){return e("div",{key:"e21cf46108e35dcbf7d65e8c6a5f12f5d5ae49cb",class:"OddsbomBullet",ref:t=>this.stylingContainer=t},e("button",{key:"4edf5cd481d8283bd71f6806b6f93949e1308095",class:{OddsbomBulletBtn__normal:!0,OddsbomBulletBtn__selected:this.isSelected,OddsbomBulletBtn__disabled:this.disabled,isDeleteByIcon:this.isDeleteByIcon,isCallDialogBtn:this.isCallDialogBtn||this.isReading},onClick:this.handleClick.bind(this),disabled:this.disabled},e("span",{key:"fa1aed0293dc004808e6992c069d6992317b0788",class:"OddsbomBullet--deleteIcon",innerHTML:a}),e("span",{key:"53ed96f2c2b833d21488049f987b6131718d563e",class:"OddsbomBullet--text"},this.text)))}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"]}}};h.style=".OddsbomBullet .OddsbomBulletBtn__normal{width:32px;height:32px;display:flex;align-items:center;justify-content:center;background:var(--emw--color-background, #fff);border:2px solid var(--emw--color-primary, #0d196e);border-radius:var(--emw--border-radius-medium, 8px);color:var(--emw--color-typography, #000);font-weight:bold;cursor:pointer;transition:transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.2s ease, background-color 0.3s;user-select:none;position:relative}.OddsbomBullet .OddsbomBulletBtn__normal:hover{transform:scale(1.15) rotate(-5deg);box-shadow:var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15)) 7px 6px 6px}.OddsbomBullet .OddsbomBulletBtn__normal .OddsbomBullet--deleteIcon{display:none}.OddsbomBullet .OddsbomBulletBtn__normal.isDeleteByIcon:hover{background-color:var(--emw--color-background, #fff)}.OddsbomBullet .OddsbomBulletBtn__normal.isDeleteByIcon:hover .OddsbomBullet--text{display:none}.OddsbomBullet .OddsbomBulletBtn__normal.isDeleteByIcon:hover .OddsbomBullet--deleteIcon{display:inline;fill:var(--emw--color-typography, #000)}.OddsbomBullet .OddsbomBulletBtn__normal.isCallDialogBtn:hover{transform:none;box-shadow:none}.OddsbomBullet .OddsbomBulletBtn__normal.OddsbomBulletBtn__selected{background-color:var(--emw--color-primary, #0d196e);color:var(--emw--color-typography-inverse, #fff);transform:scale(1.05);box-shadow:0 5px 10px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15))}.OddsbomBullet .OddsbomBulletBtn__normal.OddsbomBulletBtn__disabled{background-color:var(--emw--color-gray-50, #f5f5f5);border-color:var(--emw--color-gray-100, #e6e6e6);color:var(--emw--color-gray-150, #6f6f6f);cursor:not-allowed;transform:none;box-shadow:none}.OddsbomBullet .OddsbomBulletBtn__normal.OddsbomBulletBtn__disabled:hover{transform:none;box-shadow:none}";export{h as lottery_oddsbom_bullet}
1
+ import{r as t,c as o,h as e}from"./index-85e87cde.js";import{s as l,a as s,b as d}from"./lottery-oddsbom-bullet-group-d66a61e2.js";export{L as lottery_oddsbom_bullet_group}from"./lottery-oddsbom-bullet-group-d66a61e2.js";var r=function(){return r=Object.assign||function(t){for(var o,e=1,l=arguments.length;e<l;e++)for(var s in o=arguments[e])Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s]);return t},r.apply(this,arguments)},i={primaryColor:"#333",secondaryColor:"#E6E6E6"};function n(t,o){var e="svg"===t.tag?r(r({},t.attrs),o.extraSVGAttrs||{}):t.attrs,l=Object.keys(e).reduce((function(t,o){var l=e[o],s="".concat(o,'="').concat(l,'"');return t.push(s),t}),[]),s=l.length?" "+l.join(" "):"",d=(t.children||[]).map((function(t){return n(t,o)})).join("");return d&&d.length?"<".concat(t.tag).concat(s,">").concat(d,"</").concat(t.tag,">"):"<".concat(t.tag).concat(s," />")}const a=function(t,o){if(void 0===o&&(o={}),"function"==typeof t.icon){var e=o.placeholders||i;return n(t.icon(e.primaryColor,e.secondaryColor),o)}return n(t.icon,o)}({icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M864 256H736v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zm-200 0H360v-72h304v72z"}}]},name:"delete",theme:"filled"},{extraSVGAttrs:{width:"18px",height:"18px",fill:""}}),h=class{constructor(e){t(this,e),this.oddsbomBulletToggleEvent=o(this,"oddsbomBulletToggle",7),this.oddsbomBulletDeleteEvent=o(this,"oddsbomBulletDelete",7),this.oddsbomBulletAddedByMoreBtnDeleteEvent=o(this,"oddsbomBulletAddedByMoreBtnDelete",7),this.oddsbomBulletCallDialogEvent=o(this,"oddsbomBulletCallDialog",7),this.isSelected=void 0,this.disabled=void 0,this.text=void 0,this.idx=void 0,this.isReading=void 0,this.isDeleteByIcon=void 0,this.isCallDialogBtn=void 0,this.isAddedByMoreBtn=void 0,this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0}handleClientStylingChange(t,o){t!=o&&l(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(t,o){t!=o&&s(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(t,o){t!=o&&d(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription)}componentDidLoad(){this.stylingContainer&&(this.mbSource&&d(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription),this.clientStyling&&l(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&s(this.stylingContainer,this.clientStylingUrl))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}handleClick(){this.isCallDialogBtn?this.oddsbomBulletCallDialogEvent.emit():this.isDeleteByIcon?this.isAddedByMoreBtn?this.oddsbomBulletAddedByMoreBtnDeleteEvent.emit(this.text):this.oddsbomBulletDeleteEvent.emit(this.idx):this.disabled||this.oddsbomBulletToggleEvent.emit(this.idx)}render(){return e("div",{key:"e21cf46108e35dcbf7d65e8c6a5f12f5d5ae49cb",class:"OddsbomBullet",ref:t=>this.stylingContainer=t},e("button",{key:"4edf5cd481d8283bd71f6806b6f93949e1308095",class:{OddsbomBulletBtn__normal:!0,OddsbomBulletBtn__selected:this.isSelected,OddsbomBulletBtn__disabled:this.disabled,isDeleteByIcon:this.isDeleteByIcon,isCallDialogBtn:this.isCallDialogBtn||this.isReading},onClick:this.handleClick.bind(this),disabled:this.disabled},e("span",{key:"fa1aed0293dc004808e6992c069d6992317b0788",class:"OddsbomBullet--deleteIcon",innerHTML:a}),e("span",{key:"53ed96f2c2b833d21488049f987b6131718d563e",class:"OddsbomBullet--text"},this.text)))}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"]}}};h.style=".OddsbomBullet .OddsbomBulletBtn__normal{width:32px;height:32px;display:flex;align-items:center;justify-content:center;background:var(--emw--color-background, #fff);border:2px solid var(--emw--color-primary, #0d196e);border-radius:var(--emw--border-radius-medium, 8px);color:var(--emw--color-typography, #000);font-weight:bold;cursor:pointer;transition:transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.2s ease, background-color 0.3s;user-select:none;position:relative}.OddsbomBullet .OddsbomBulletBtn__normal:hover{transform:scale(1.15) rotate(-5deg);box-shadow:var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15)) 7px 6px 6px}.OddsbomBullet .OddsbomBulletBtn__normal .OddsbomBullet--deleteIcon{display:none}.OddsbomBullet .OddsbomBulletBtn__normal.isDeleteByIcon:hover{background-color:var(--emw--color-background, #fff)}.OddsbomBullet .OddsbomBulletBtn__normal.isDeleteByIcon:hover .OddsbomBullet--text{display:none}.OddsbomBullet .OddsbomBulletBtn__normal.isDeleteByIcon:hover .OddsbomBullet--deleteIcon{display:inline;fill:var(--emw--color-typography, #000)}.OddsbomBullet .OddsbomBulletBtn__normal.isCallDialogBtn:hover{transform:none;box-shadow:none}.OddsbomBullet .OddsbomBulletBtn__normal.OddsbomBulletBtn__selected{background-color:var(--emw--color-primary, #0d196e);color:var(--emw--color-typography-inverse, #fff);transform:scale(1.05);box-shadow:0 5px 10px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15))}.OddsbomBullet .OddsbomBulletBtn__normal.OddsbomBulletBtn__disabled{background-color:var(--emw--color-gray-50, #f5f5f5);border-color:var(--emw--color-gray-100, #e6e6e6);color:var(--emw--color-gray-150, #6f6f6f);cursor:not-allowed;transform:none;box-shadow:none}.OddsbomBullet .OddsbomBulletBtn__normal.OddsbomBulletBtn__disabled:hover{transform:none;box-shadow:none}";export{h as lottery_oddsbom_bullet}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/lottery-oddsbom-bullet-group",
3
- "version": "0.7.26",
3
+ "version": "0.7.28",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",
@@ -1 +0,0 @@
1
- import{r as t,c as e,h as i}from"./index-85e87cde.js";function l(t,e){if(t){const i=document.createElement("style");i.innerHTML=e,t.appendChild(i)}}function s(t,e){if(!t||!e)return;const i=new URL(e);fetch(i.href).then((t=>t.text())).then((e=>{const i=document.createElement("style");i.innerHTML=e,t&&t.appendChild(i)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}function o(t,e){if(window.emMessageBus){const i=document.createElement("style");window.emMessageBus.subscribe(e,(e=>{i.innerHTML=e,t&&t.appendChild(i)}))}}const d=class{constructor(i){t(this,i),this.addSelectionEvent=e(this,"addSelection",7),this.deleteSelectionEvent=e(this,"deleteSelection",7),this.deleteSelectionOriginEvent=e(this,"deleteSelectionOrigin",7),this.oddsbomBulletGroupToggleEvent=e(this,"oddsbomBulletGroupToggle",7),this.oddsbomBulletGroupAddedByMoreBtnDelEvent=e(this,"oddsbomBulletGroupAddedByMoreBtnDel",7),this.oddsbomBulletCallDialogFromGroupEvent=e(this,"oddsbomBulletCallDialogFromGroup",7),this.selectionIdx=void 0,this.matchIdx=void 0,this.bulletConfigs=[],this.bulletConfigsDeleteOrigin=[],this.addSelectionConfig=void 0,this.isDeleteByIcon=void 0,this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0,this.bulletListClass=void 0,this.innerBulletConfigs=void 0,this.innerBulletConfigsDeleteOrigin=void 0}handleBulletConfigsChange(t){this.innerBulletConfigs=t.map((t=>Object.assign({},t)))}handleBulletConfigsDeleteOriginChange(t){this.innerBulletConfigsDeleteOrigin=t.map((t=>Object.assign({},t)))}componentWillLoad(){this.handleBulletConfigsChange(this.bulletConfigs)}handleClientStylingChange(t,e){t!=e&&l(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(t,e){t!=e&&s(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(t,e){t!=e&&o(this.stylingContainer,`${this.mbSource}.Style`)}oddsbomBulletToggleHandler(t){const e=t.detail,{matchIdx:i,selectionIdx:l}=this,s=[...this.innerBulletConfigs],o=Object.assign({},s[e]);o.isSelected=!o.isSelected,s[e]=o,this.innerBulletConfigs=s,this.oddsbomBulletGroupToggleEvent.emit({bulletSelctionArr:this.innerBulletConfigs,matchIdx:i,selectionIdx:l})}oddsbomBulletDeleteHandler(t){const e=t.detail,{matchIdx:i,selectionIdx:l}=this,s=[...this.innerBulletConfigsDeleteOrigin],o=Object.assign({},s[e]);o.isSelected=!o.isSelected,s[e]=o,this.innerBulletConfigsDeleteOrigin=s,this.oddsbomBulletGroupToggleEvent.emit({bulletSelctionArr:this.innerBulletConfigsDeleteOrigin,matchIdx:i,selectionIdx:l})}oddsbomBulletAddedByMoreBtnDeleteHandler(t){const e=t.detail,{matchIdx:i,selectionIdx:l}=this;this.oddsbomBulletGroupAddedByMoreBtnDelEvent.emit({delText:e,matchIdx:i,selectionIdx:l})}componentDidLoad(){this.stylingContainer&&(this.mbSource&&o(this.stylingContainer,`${this.mbSource}.Style`),this.clientStyling&&l(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&s(this.stylingContainer,this.clientStylingUrl))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}handleOddsbomBulletCallDialog(){const{matchIdx:t,selectionIdx:e}=this;this.oddsbomBulletCallDialogFromGroupEvent.emit({matchIdx:t,selectionIdx:e})}render(){return i("div",{key:"38102a447cf8fafc8f7a7e5a122c7ccbc2ce8b4a",class:"oddsbomBulletGroup",ref:t=>this.stylingContainer=t},i("div",{key:"59ca1df498575356eb3438b45e9431b1bc7ee2dd",class:`oddsbomBulletGroup-list ${this.bulletListClass||""}`},this.innerBulletConfigs.map((t=>i("lottery-oddsbom-bullet",t.isAddMoreBtn?{text:`${this.addSelectionConfig.maxOverScore}+`,disabled:t.isDisabled,isCallDialogBtn:!0,onOddsbomBulletCallDialog:this.handleOddsbomBulletCallDialog.bind(this)}:{text:t.text,idx:t.idx,isSelected:t.isSelected,disabled:t.isDisabled,isDeleteByIcon:this.isDeleteByIcon,isAddedByMoreBtn:t.isAddedByMoreBtn})))))}static get watchers(){return{bulletConfigs:["handleBulletConfigsChange"],bulletConfigsDeleteOrigin:["handleBulletConfigsDeleteOriginChange"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"]}}};d.style=".oddsbomBulletGroup{width:100%}.oddsbomBulletGroup .oddsbomBulletGroup-list{display:flex;flex-wrap:wrap;align-items:center;gap:12px}.oddsbomBulletGroup .selection-bullet-list{justify-content:flex-end}";export{d as L,s as a,o as b,l as s}