@everymatrix/lottery-selection-group 0.0.1

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.
Files changed (59) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-bc355d7d.js +1310 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/lottery-button_4.cjs.entry.js +486 -0
  6. package/dist/cjs/lottery-selection-group-1608b2e2.js +480 -0
  7. package/dist/cjs/lottery-selection-group.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +31 -0
  9. package/dist/collection/components/lottery-selection-group/index.js +1 -0
  10. package/dist/collection/components/lottery-selection-group/lottery-selection-group.css +84 -0
  11. package/dist/collection/components/lottery-selection-group/lottery-selection-group.js +685 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/model/type.js +1 -0
  14. package/dist/collection/utils/locale.utils.js +74 -0
  15. package/dist/collection/utils/utils.js +86 -0
  16. package/dist/esm/app-globals-0f993ce5.js +3 -0
  17. package/dist/esm/index-3a4d6110.js +1282 -0
  18. package/dist/esm/index.js +2 -0
  19. package/dist/esm/loader.js +11 -0
  20. package/dist/esm/lottery-button_4.entry.js +480 -0
  21. package/dist/esm/lottery-selection-group-656d6729.js +475 -0
  22. package/dist/esm/lottery-selection-group.js +20 -0
  23. package/dist/index.cjs.js +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/lottery-selection-group/app-globals-0f993ce5.js +1 -0
  26. package/dist/lottery-selection-group/index-3a4d6110.js +2 -0
  27. package/dist/lottery-selection-group/index.esm.js +1 -0
  28. package/dist/lottery-selection-group/lottery-button_4.entry.js +1 -0
  29. package/dist/lottery-selection-group/lottery-selection-group-656d6729.js +1 -0
  30. package/dist/lottery-selection-group/lottery-selection-group.esm.js +1 -0
  31. package/dist/stencil.config.dev.js +19 -0
  32. package/dist/stencil.config.js +19 -0
  33. package/dist/storybook/main.js +43 -0
  34. package/dist/storybook/preview.js +9 -0
  35. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  36. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/packages/stencil/lottery-selection-group/stencil.config.d.ts +2 -0
  37. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/packages/stencil/lottery-selection-group/stencil.config.dev.d.ts +2 -0
  38. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/packages/stencil/lottery-selection-group/storybook/main.d.ts +3 -0
  39. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/packages/stencil/lottery-selection-group/storybook/preview.d.ts +70 -0
  40. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/index.d.ts +4 -0
  41. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  42. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  43. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  44. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  45. package/dist/types/components/lottery-selection-group/index.d.ts +1 -0
  46. package/dist/types/components/lottery-selection-group/lottery-selection-group.d.ts +122 -0
  47. package/dist/types/components.d.ts +218 -0
  48. package/dist/types/index.d.ts +1 -0
  49. package/dist/types/model/type.d.ts +12 -0
  50. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  51. package/dist/types/utils/locale.utils.d.ts +3 -0
  52. package/dist/types/utils/utils.d.ts +14 -0
  53. package/loader/cdn.js +1 -0
  54. package/loader/index.cjs.js +1 -0
  55. package/loader/index.d.ts +24 -0
  56. package/loader/index.es2017.js +1 -0
  57. package/loader/index.js +2 -0
  58. package/loader/package.json +11 -0
  59. package/package.json +27 -0
@@ -0,0 +1,480 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-bc355d7d.js');
4
+
5
+ /**
6
+ * @name setClientStyling
7
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
8
+ * @param {HTMLElement} stylingContainer The reference element of the widget
9
+ * @param {string} clientStyling The style content
10
+ */
11
+ function setClientStyling(stylingContainer, clientStyling) {
12
+ if (stylingContainer) {
13
+ const sheet = document.createElement('style');
14
+ sheet.innerHTML = clientStyling;
15
+ stylingContainer.appendChild(sheet);
16
+ }
17
+ }
18
+
19
+ /**
20
+ * @name setClientStylingURL
21
+ * @description Method used to create and append to the passed element of the widget a style element with the content fetched from a given URL
22
+ * @param {HTMLElement} stylingContainer The reference element of the widget
23
+ * @param {string} clientStylingUrl The URL of the style content
24
+ */
25
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
26
+ if (!stylingContainer || !clientStylingUrl) return;
27
+
28
+ const url = new URL(clientStylingUrl);
29
+
30
+ fetch(url.href)
31
+ .then((res) => res.text())
32
+ .then((data) => {
33
+ const cssFile = document.createElement('style');
34
+ cssFile.innerHTML = data;
35
+ if (stylingContainer) {
36
+ stylingContainer.appendChild(cssFile);
37
+ }
38
+ })
39
+ .catch((err) => {
40
+ console.error('There was an error while trying to load client styling from URL', err);
41
+ });
42
+ }
43
+
44
+ /**
45
+ * @name setStreamLibrary
46
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
47
+ * @param {HTMLElement} stylingContainer The highest element of the widget
48
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
49
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
50
+ */
51
+ function setStreamStyling(stylingContainer, domain, subscription) {
52
+ if (window.emMessageBus) {
53
+ const sheet = document.createElement('style');
54
+
55
+ window.emMessageBus.subscribe(domain, (data) => {
56
+ sheet.innerHTML = data;
57
+ if (stylingContainer) {
58
+ stylingContainer.appendChild(sheet);
59
+ }
60
+ });
61
+ }
62
+ }
63
+
64
+ const DEFAULT_LANGUAGE = 'en';
65
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr', 'zh'];
66
+ const TRANSLATIONS = {
67
+ en: {
68
+ noTicketBoard: 'No ticket board available.',
69
+ selectionCleared: 'Your selection has been cleared.',
70
+ clearAll: 'Clear All',
71
+ stopAt: 'Stop at',
72
+ turnover: 'Turnover: ',
73
+ pleaseFillIn: 'Please fill in all the selection input!',
74
+ fillIn: 'Fill in',
75
+ noBets: 'Sorry. No bets have been placed so far. Check back later!',
76
+ search: 'Search',
77
+ clear: 'Clear',
78
+ oddsChart: 'Odds Chart',
79
+ ticketSuccess: 'Ticket purchased successfully.',
80
+ stakePerLine: 'Stake per Line:',
81
+ lowestOdds: 'Lowest Odds:',
82
+ highestOdds: 'Highest Odds:',
83
+ orderSummary: 'ORDER SUMMARY',
84
+ ticket: 'Ticket',
85
+ lines: 'Lines',
86
+ total: 'Total',
87
+ submit: 'Submit',
88
+ loading: 'Loading',
89
+ enterValidNumber: 'Please enter a valid number.',
90
+ enterNumberBetween: 'Please enter a number between {min} and {max}.',
91
+ numberAlreadySelected: 'This number has already been selected.',
92
+ enterScoreUpTo: 'Please enter the score (Up to {maxScore})',
93
+ enterValue: 'Please enter a value',
94
+ myChoices: 'My Choices',
95
+ teams: 'Teams',
96
+ scores: 'Scores',
97
+ euro: 'Euro',
98
+ cancel: 'Cancel',
99
+ confirm: 'Confirm'
100
+ },
101
+ ro: {},
102
+ fr: {},
103
+ ar: {},
104
+ hr: {}
105
+ };
106
+ const translate = (key, customLang, replacements) => {
107
+ const lang = customLang;
108
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
109
+ if (replacements) {
110
+ Object.keys(replacements).forEach((placeholder) => {
111
+ translation = translation.replace(`{${placeholder}}`, replacements[placeholder]);
112
+ });
113
+ }
114
+ return translation;
115
+ };
116
+ const getTranslations = (data) => {
117
+ Object.keys(data).forEach((item) => {
118
+ for (let key in data[item]) {
119
+ TRANSLATIONS[item][key] = data[item][key];
120
+ }
121
+ });
122
+ };
123
+
124
+ function getBulletTextsSet(bulletTexts, splitToken) {
125
+ return new Set(bulletTexts ? bulletTexts.split(splitToken) : []);
126
+ }
127
+ function validateInput({ value, selectedSet, maxValue, minValue, language, type = 'integer' }) {
128
+ const trimmedValue = value.trim();
129
+ if (type === 'integer') {
130
+ // Strict integer check
131
+ if (!/^-?\d+$/.test(trimmedValue)) {
132
+ return {
133
+ valid: false,
134
+ errorMessage: translate('enterValidNumber', language),
135
+ value
136
+ };
137
+ }
138
+ const numValue = Number(trimmedValue);
139
+ if (isNaN(numValue)) {
140
+ return {
141
+ valid: false,
142
+ errorMessage: translate('enterValidNumber', language),
143
+ value
144
+ };
145
+ }
146
+ if ((minValue !== undefined && numValue < minValue) || (maxValue !== undefined && numValue > maxValue)) {
147
+ return {
148
+ valid: false,
149
+ errorMessage: translate('enterNumberBetween', language, {
150
+ min: minValue,
151
+ max: maxValue
152
+ }),
153
+ value
154
+ };
155
+ }
156
+ // Normalize value (e.g. "05" -> "5") for set check
157
+ const normalizedValue = String(numValue);
158
+ if (selectedSet.has(normalizedValue)) {
159
+ return {
160
+ valid: false,
161
+ errorMessage: translate('numberAlreadySelected', language),
162
+ value
163
+ };
164
+ }
165
+ }
166
+ else {
167
+ // Text mode validation
168
+ if (selectedSet.has(trimmedValue)) {
169
+ return {
170
+ valid: false,
171
+ errorMessage: translate('numberAlreadySelected', language), // Or generic 'alreadySelected' if available, but reusing key for now
172
+ value
173
+ };
174
+ }
175
+ }
176
+ return {
177
+ valid: true,
178
+ errorMessage: '',
179
+ value
180
+ };
181
+ }
182
+ function removeBulletTexts(text, selectedArr) {
183
+ return selectedArr.filter((s) => s !== text);
184
+ }
185
+ function addSelectedBulletTexts(text, selectedArr) {
186
+ return selectedArr.concat([text]);
187
+ }
188
+ function removeAndAddSelectedBulletTexts(text, selectedArr, maxSelectedCount) {
189
+ return selectedArr.slice(selectedArr.length - (maxSelectedCount - 1)).concat([text]);
190
+ }
191
+ function buildSelectedBulletTextsArr(item, selectedArr, maxSelectedCount) {
192
+ if (item.type === 'delete') {
193
+ return removeBulletTexts(item.text, selectedArr);
194
+ }
195
+ if (item.type === 'toggle') {
196
+ if (selectedArr.includes(item.text)) {
197
+ return removeBulletTexts(item.text, selectedArr);
198
+ }
199
+ if (selectedArr.length >= maxSelectedCount) {
200
+ return removeAndAddSelectedBulletTexts(item.text, selectedArr, maxSelectedCount);
201
+ }
202
+ return addSelectedBulletTexts(item.text, selectedArr);
203
+ }
204
+ return [];
205
+ }
206
+
207
+ const lotterySelectionGroupCss = ":host {\n width: 100%;\n}\n\n.lottery-selection-group {\n container-type: inline-size;\n padding: var(--lottery-selection-group-padding, 0);\n background: var(--lottery-selection-group-background, transparent);\n border: var(--lottery-selection-group-border, none);\n border-radius: var(--lottery-selection-group-border-radius, 0);\n}\n.lottery-selection-group__item {\n display: flex;\n flex-direction: var(--lottery-selection-group-flex-direction, row);\n align-items: var(--lottery-selection-group-item-align, center);\n justify-content: var(--lottery-selection-group-item-justify, flex-start);\n gap: var(--lottery-selection-group-item-gap, 16px);\n width: 100%;\n}\n.lottery-selection-group__item--left {\n width: var(--lottery-selection-group-label-width, 130px);\n min-width: var(--lottery-selection-group-label-min-width, auto);\n max-width: var(--lottery-selection-group-label-max-width, none);\n color: var(--lottery-selection-group-label-color, var(--emw--color-typography, #000));\n font-size: var(--lottery-selection-group-label-font-size, 1em);\n font-weight: var(--lottery-selection-group-label-font-weight, bold);\n text-align: var(--lottery-selection-group-label-align, left);\n white-space: var(--lottery-selection-group-label-white-space, normal);\n}\n.lottery-selection-group__item--right {\n flex: 1;\n display: flex;\n flex-wrap: var(--lottery-selection-group-bullets-wrap, wrap); /* Allow items to wrap */\n gap: var(--lottery-selection-group-bullets-gap, 8px); /* Gap between bullets */\n align-items: var(--lottery-selection-group-bullets-align, center);\n justify-content: var(--lottery-selection-group-bullets-justify, flex-start); /* Align bullets to start */\n}\n@container (max-width: 320px) {\n .lottery-selection-group__item--left {\n width: 100px;\n max-width: 100px;\n }\n}\n\n.dialog-input {\n width: 100%;\n padding: var(--lottery-selection-group-input-padding, 8px);\n border: var(--lottery-selection-group-input-border-width, 1px) var(--lottery-selection-group-input-border-style, solid) var(--lottery-selection-group-input-border-color, var(--emw--color-gray-100, #e6e6e6));\n border-radius: var(--lottery-selection-group-input-radius, 4px);\n background-color: var(--lottery-selection-group-input-bg, #fff);\n color: var(--lottery-selection-group-input-color, #000);\n box-sizing: border-box;\n margin-top: var(--lottery-selection-group-input-margin-top, 10px);\n font-size: var(--lottery-selection-group-input-font-size, 1em);\n}\n.dialog-input::placeholder {\n color: var(--lottery-selection-group-input-placeholder-color, #999);\n}\n\n.dialog-input.invalid,\n.dialog-input.invalid:focus {\n border-color: var(--emw--color-error, #ff3d00);\n outline-color: var(--emw--color-error, #ff3d00);\n}\n\n.error-message {\n color: var(--lottery-selection-group-error-color, var(--emw--color-error, #ff3d00));\n font-size: var(--lottery-selection-group-error-font-size, 12px);\n font-weight: var(--lottery-selection-group-error-font-weight, normal);\n margin-top: 4px;\n}\n\n.addSelectionDialog-title {\n color: var(--lottery-selection-group-dialog-title-color, var(--emw--color-typography, #000));\n font-size: var(--lottery-selection-group-dialog-title-font-size, 1.2em);\n font-weight: var(--lottery-selection-group-dialog-title-font-weight, bold);\n margin-bottom: var(--lottery-selection-group-dialog-title-margin-bottom, 0);\n}\n.addSelectionDialog-footer {\n display: flex;\n justify-content: var(--lottery-selection-group-dialog-footer-justify, flex-end);\n gap: var(--lottery-selection-group-dialog-footer-gap, 18px);\n margin-top: var(--lottery-selection-group-dialog-footer-margin-top, 0);\n}";
208
+ const LotterySelectionGroupStyle0 = lotterySelectionGroupCss;
209
+
210
+ const LotterySelectionGroup = class {
211
+ constructor(hostRef) {
212
+ index.registerInstance(this, hostRef);
213
+ this.bulletGroupUpdateSelectedBulletTexts = index.createEvent(this, "bulletGroupUpdateSelection", 7);
214
+ this.mbSource = undefined;
215
+ this.clientStyling = undefined;
216
+ this.clientStylingUrl = undefined;
217
+ this.language = 'en';
218
+ this.translationUrl = '';
219
+ this.splitToken = ',';
220
+ this.selectionGroupId = undefined;
221
+ this.selectionGroupLabel = undefined;
222
+ this.type = 'bet';
223
+ this.selectedBulletTexts = null;
224
+ this.maxSelectedCount = null;
225
+ this.maxDisplayBulletsCount = 11;
226
+ this.bulletTexts = null;
227
+ this.maxIntegerBulletText = null;
228
+ this.minIntegerBulletText = 0;
229
+ this.bulletTextType = 'integer';
230
+ this.hasBorder = true;
231
+ this.hasBackground = true;
232
+ this.dialogTitle = undefined;
233
+ this.dialogInputPlaceholder = undefined;
234
+ this.dialogConfig = {
235
+ width: '400px',
236
+ visible: false,
237
+ onConfirm: () => this.handleFillInAddMore(),
238
+ onCancel: () => this.handleCloseAddMoreDialog()
239
+ };
240
+ this.inputInfo = { valid: true, errorMessage: '', value: '' };
241
+ }
242
+ handleClientStylingChange(newValue, oldValue) {
243
+ if (newValue != oldValue) {
244
+ setClientStyling(this.stylingContainer, this.clientStyling);
245
+ }
246
+ }
247
+ handleClientStylingUrlChange(newValue, oldValue) {
248
+ if (newValue != oldValue) {
249
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
250
+ }
251
+ }
252
+ handleMbSourceChange(newValue, oldValue) {
253
+ if (newValue != oldValue) {
254
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
255
+ }
256
+ }
257
+ componentWillLoad() {
258
+ if (this.translationUrl) {
259
+ getTranslations(JSON.parse(this.translationUrl));
260
+ }
261
+ }
262
+ componentDidLoad() {
263
+ if (this.stylingContainer) {
264
+ if (this.mbSource)
265
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
266
+ if (this.clientStyling)
267
+ setClientStyling(this.stylingContainer, this.clientStyling);
268
+ if (this.clientStylingUrl)
269
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
270
+ }
271
+ }
272
+ disconnectedCallback() {
273
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
274
+ }
275
+ lotteryBulletClickHandler(event) {
276
+ event.stopPropagation();
277
+ // if it's input type, open the dialog
278
+ if (event.detail.type === 'input') {
279
+ this.dialogConfig = Object.assign(Object.assign({}, this.dialogConfig), { visible: true });
280
+ return;
281
+ }
282
+ if (['delete', 'toggle'].includes(event.detail.type)) {
283
+ this.bulletGroupUpdateSelectedBulletTexts.emit({
284
+ newSelectedBulletTexts: buildSelectedBulletTextsArr(event.detail, Array.from(this.selectedSet), this.maxSelectedCount).join(this.splitToken),
285
+ selectionGroupId: this.selectionGroupId
286
+ });
287
+ return;
288
+ }
289
+ }
290
+ get selectedSet() {
291
+ return getBulletTextsSet(this.selectedBulletTexts, this.splitToken);
292
+ }
293
+ get bulletTextsSet() {
294
+ if (this.bulletTexts)
295
+ return getBulletTextsSet(this.bulletTexts, this.splitToken);
296
+ if (this.bulletTextType === 'integer' &&
297
+ this.maxIntegerBulletText !== null &&
298
+ this.maxIntegerBulletText !== undefined) {
299
+ return getBulletTextsSet(Array.from({ length: Number(this.lastDisplayBulletText) - this.minIntegerBulletText + 1 }, (_, index) => this.minIntegerBulletText + index).join(this.splitToken), this.splitToken);
300
+ }
301
+ // If neither bulletTexts nor maxIntegerBulletText are provided,
302
+ return new Set();
303
+ }
304
+ // the last bullet text
305
+ get lastDisplayBulletText() {
306
+ if (this.bulletTextType === 'integer') {
307
+ if (this.maxIntegerBulletText !== null && this.maxIntegerBulletText !== undefined) {
308
+ return Math.min(this.maxIntegerBulletText, this.minIntegerBulletText + this.maxDisplayBulletsCount - 1);
309
+ }
310
+ return this.minIntegerBulletText + this.maxDisplayBulletsCount - 1;
311
+ }
312
+ // Text mode: return the text at the max display index if available
313
+ if (this.bulletTextsSet.size > 0) {
314
+ const texts = Array.from(this.bulletTextsSet);
315
+ if (texts.length >= this.maxDisplayBulletsCount) {
316
+ return texts[this.maxDisplayBulletsCount - 1];
317
+ }
318
+ return texts[texts.length - 1]; // If fewer than maxDisplayBulletsCount, return the last one
319
+ }
320
+ return null;
321
+ }
322
+ get isSingleSelectionMode() {
323
+ return this.maxSelectedCount === 1;
324
+ }
325
+ getBulletToRender() {
326
+ const allBulletTexts = Array.from(this.bulletTextsSet);
327
+ // Determine which bullets to display based on type and limit
328
+ let bulletsToRender = allBulletTexts;
329
+ let showInputButton = false;
330
+ if (this.bulletTextType === 'text') {
331
+ // For text, if we have more items than the limit, we need an input button.
332
+ // The input button takes one slot, so we show (limit - 1) items.
333
+ if (allBulletTexts.length > this.maxDisplayBulletsCount) {
334
+ showInputButton = true;
335
+ bulletsToRender = allBulletTexts.slice(0, this.maxDisplayBulletsCount - 1);
336
+ }
337
+ else {
338
+ bulletsToRender = allBulletTexts;
339
+ }
340
+ }
341
+ else {
342
+ // For integer, logic is based on maxIntegerBulletText vs displayed range
343
+ showInputButton =
344
+ this.maxIntegerBulletText !== null &&
345
+ this.maxIntegerBulletText !== undefined &&
346
+ this.maxIntegerBulletText > Number(this.lastDisplayBulletText);
347
+ // Integer bullets generation already respects the count, no slicing needed on the raw set
348
+ bulletsToRender = allBulletTexts;
349
+ }
350
+ return {
351
+ bulletsToRender,
352
+ showInputButton
353
+ };
354
+ }
355
+ renderBulletGroup() {
356
+ let items = [];
357
+ if (this.type === 'bet') {
358
+ const isMaxSelected = this.maxSelectedCount !== null && this.selectedSet.size >= this.maxSelectedCount;
359
+ const { bulletsToRender, showInputButton } = this.getBulletToRender();
360
+ bulletsToRender.forEach((text, idx) => {
361
+ let bulletType = 'toggle';
362
+ if (!this.selectedSet.has(String(text)) && isMaxSelected && !this.isSingleSelectionMode) {
363
+ bulletType = 'disabled';
364
+ }
365
+ items.push({
366
+ value: this.selectedSet.has(String(text)) ? 1 : 0,
367
+ text: String(text),
368
+ idx,
369
+ type: bulletType
370
+ });
371
+ });
372
+ if (showInputButton) {
373
+ let inputBulletType = 'input';
374
+ if (isMaxSelected && !this.isSingleSelectionMode) {
375
+ inputBulletType = 'disabled';
376
+ }
377
+ const inputButtonText = this.bulletTextType === 'text' ? '...' : `${this.lastDisplayBulletText}+`;
378
+ const inputButtonIdx = this.bulletTextType === 'text' ? -1 : Number(this.lastDisplayBulletText) + 1;
379
+ // Special handling for integer mode:
380
+ // If the generated set is "full" (size == maxDisplayBulletsCount),
381
+ // we need to remove the last item to make room for the "N+" button
382
+ // so the total visual count remains consistent.
383
+ if (this.bulletTextType === 'integer' && items.length >= this.maxDisplayBulletsCount) {
384
+ items.pop();
385
+ }
386
+ items.push({
387
+ value: 0,
388
+ text: inputButtonText,
389
+ idx: inputButtonIdx,
390
+ type: inputBulletType
391
+ });
392
+ }
393
+ }
394
+ else if (['choice', 'preview'].includes(this.type)) {
395
+ // For choice/preview, also respect the visual limit for text mode
396
+ const { bulletsToRender } = this.getBulletToRender();
397
+ bulletsToRender.forEach((text, idx) => {
398
+ let bulletType = 'toggle';
399
+ if (this.type === 'preview') {
400
+ bulletType = 'readonly';
401
+ }
402
+ else if (this.selectedSet.has(String(text))) {
403
+ bulletType = 'delete';
404
+ }
405
+ items.push({
406
+ value: this.selectedSet.has(String(text)) ? 1 : 0,
407
+ text,
408
+ idx,
409
+ type: bulletType
410
+ });
411
+ });
412
+ }
413
+ return (index.h("div", { class: "lottery-selection-group__item--right" }, items.map((item) => {
414
+ return (index.h("lottery-selection", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, mbSource: this.mbSource, text: item.text, idx: item.idx, value: item.value, type: item.type, hasBorder: this.hasBorder, hasBackground: this.hasBackground }));
415
+ })));
416
+ }
417
+ handleCloseAddMoreDialog() {
418
+ this.dialogConfig = Object.assign(Object.assign({}, this.dialogConfig), { visible: false });
419
+ this.inputInfo = { value: '', errorMessage: '', valid: true };
420
+ }
421
+ handleInputChange(e) {
422
+ const inputElement = e.target;
423
+ const value = inputElement.value;
424
+ this.inputInfo = Object.assign(Object.assign({}, this.inputInfo), { value: value });
425
+ this.inputInfo = validateInput({
426
+ value,
427
+ selectedSet: this.selectedSet,
428
+ maxValue: this.maxIntegerBulletText,
429
+ minValue: this.bulletTextType === 'integer' ? Number(this.lastDisplayBulletText) + 1 : undefined,
430
+ language: this.language,
431
+ type: this.bulletTextType
432
+ });
433
+ }
434
+ handleFillInAddMore() {
435
+ if (this.inputInfo.valid) {
436
+ const { value } = this.inputInfo;
437
+ // Normalize the value (e.g., "05" -> "5") to match validation logic
438
+ let normalizedValue = value;
439
+ if (this.bulletTextType === 'integer') {
440
+ normalizedValue = String(Number(value));
441
+ }
442
+ else {
443
+ normalizedValue = value.trim();
444
+ }
445
+ let newSelectedBulletTexts;
446
+ if (this.isSingleSelectionMode) {
447
+ newSelectedBulletTexts = normalizedValue;
448
+ }
449
+ else {
450
+ newSelectedBulletTexts = addSelectedBulletTexts(normalizedValue, Array.from(this.selectedSet)).join(this.splitToken);
451
+ }
452
+ this.bulletGroupUpdateSelectedBulletTexts.emit({
453
+ newSelectedBulletTexts,
454
+ selectionGroupId: this.selectionGroupId
455
+ });
456
+ this.handleCloseAddMoreDialog();
457
+ }
458
+ }
459
+ render() {
460
+ return (index.h("div", { key: '66b8e9c63d948eb2f7eb37adb80892dbedd7df9a', class: "lottery-selection-group", ref: (el) => (this.stylingContainer = el) }, index.h("div", { key: '6562fdcad0f352b5e2d03edcc980a9aeab32277e', class: "lottery-selection-group__item" }, this.selectionGroupLabel && (index.h("div", { key: '43c2132e4904a2b69b970d9b2074f120ed4d0986', class: "lottery-selection-group__item--left" }, this.selectionGroupLabel)), this.renderBulletGroup()), index.h("lottery-tipping-dialog", { key: 'cb693d10e6b499628909571021d8508cdebbe29a', visible: this.dialogConfig.visible, width: this.dialogConfig.width, onCancel: this.dialogConfig.onCancel }, index.h("div", { key: 'dd312634574bbe1b4d3de7e82a9c58f58f846c1a', class: "addSelectionDialog" }, index.h("div", { key: 'b371b1090598f0219a7c652bab51e9d349703c34', class: "addSelectionDialog-title" }, this.dialogTitle || (this.bulletTextType === 'text'
461
+ ? translate('enterValue', this.language)
462
+ : translate('enterScoreUpTo', this.language, {
463
+ maxScore: this.maxIntegerBulletText
464
+ }))), index.h("input", { key: 'b5f1bb74999246dac8dc20f04e3af893deae6654', type: "text", class: {
465
+ 'dialog-input': true,
466
+ invalid: !this.inputInfo.valid
467
+ }, value: this.inputInfo.value, onInput: this.handleInputChange.bind(this), placeholder: this.dialogInputPlaceholder }), index.h("div", { key: 'f33970a6dffdc881ffa9cf2c0bb54b26b27cccd6', class: "error-message" }, this.inputInfo.errorMessage)), index.h("div", { key: '4c580dae14b38aff03e17067b2c0b72d01aa4f42', slot: "footer", class: "addSelectionDialog-footer" }, index.h("lottery-button", { key: '874aa0ffde8fe2d0b08efea0cf951f101ab8dad0', onClick: this.dialogConfig.onCancel, text: translate('cancel', this.language), variant: "outline" }), index.h("lottery-button", { key: '63a556eb5f9ad1cdd357c017756be274d40ef235', onClick: this.dialogConfig.onConfirm, text: translate('confirm', this.language), variant: "primary", disabled: !this.inputInfo.valid || !this.inputInfo.value })))));
468
+ }
469
+ static get watchers() { return {
470
+ "clientStyling": ["handleClientStylingChange"],
471
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
472
+ "mbSource": ["handleMbSourceChange"]
473
+ }; }
474
+ };
475
+ LotterySelectionGroup.style = LotterySelectionGroupStyle0;
476
+
477
+ exports.LotterySelectionGroup = LotterySelectionGroup;
478
+ exports.setClientStyling = setClientStyling;
479
+ exports.setClientStylingURL = setClientStylingURL;
480
+ exports.setStreamStyling = setStreamStyling;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-bc355d7d.js');
6
+ const appGlobals = require('./app-globals-3a1e7e63.js');
7
+
8
+ /*
9
+ Stencil Client Patch Browser v4.19.2 | MIT Licensed | https://stenciljs.com
10
+ */
11
+ var patchBrowser = () => {
12
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('lottery-selection-group.cjs.js', document.baseURI).href));
13
+ const opts = {};
14
+ if (importMeta !== "") {
15
+ opts.resourcesUrl = new URL(".", importMeta).href;
16
+ }
17
+ return index.promiseResolve(opts);
18
+ };
19
+
20
+ patchBrowser().then(async (options) => {
21
+ await appGlobals.globalScripts();
22
+ return index.bootstrapLazy([["lottery-button_4.cjs",[[1,"lottery-selection-group",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"language":[513],"translationUrl":[513,"translation-url"],"splitToken":[513,"split-token"],"selectionGroupId":[513,"selection-group-id"],"selectionGroupLabel":[513,"selection-group-label"],"type":[513],"selectedBulletTexts":[513,"selected-bullet-texts"],"maxSelectedCount":[514,"max-selected-count"],"maxDisplayBulletsCount":[514,"max-display-bullets-count"],"bulletTexts":[513,"bullet-texts"],"maxIntegerBulletText":[514,"max-integer-bullet-text"],"minIntegerBulletText":[514,"min-integer-bullet-text"],"bulletTextType":[513,"bullet-text-type"],"hasBorder":[516,"has-border"],"hasBackground":[516,"has-background"],"dialogTitle":[513,"dialog-title"],"dialogInputPlaceholder":[513,"dialog-input-placeholder"],"dialogConfig":[32],"inputInfo":[32]},[[0,"lotteryBulletClick","lotteryBulletClickHandler"]],{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-button",{"variant":[513],"size":[513],"color":[513],"disabled":[516],"loading":[516],"text":[513],"mbSource":[513,"mb-source"],"language":[513],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"ripples":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-selection",{"value":[520],"text":[513],"idx":[514],"type":[513],"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"hasBorder":[516,"has-border"],"hasBackground":[516,"has-background"],"deleteIconSvg":[513,"delete-icon-svg"],"deleteIconWidth":[513,"delete-icon-width"],"deleteIconHeight":[513,"delete-icon-height"]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-tipping-dialog",{"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"visible":[516],"dialogTitle":[1,"dialog-title"],"width":[1],"closable":[4],"mask":[4],"maskClosable":[4,"mask-closable"],"animationDuration":[2,"animation-duration"],"fullscreen":[4],"showFooter":[4,"show-footer"],"showCancelBtn":[4,"show-cancel-btn"],"language":[513],"translationUrl":[520,"translation-url"]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
23
+ });
24
+
25
+ exports.setNonce = index.setNonce;
@@ -0,0 +1,31 @@
1
+ {
2
+ "entries": [
3
+ "components/lottery-selection-group/lottery-selection-group.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "4.19.2",
8
+ "typescriptVersion": "5.4.5"
9
+ },
10
+ "collections": [
11
+ {
12
+ "name": "@everymatrix/lottery-button",
13
+ "tags": [
14
+ "lottery-button"
15
+ ]
16
+ },
17
+ {
18
+ "name": "@everymatrix/lottery-selection",
19
+ "tags": [
20
+ "lottery-selection"
21
+ ]
22
+ },
23
+ {
24
+ "name": "@everymatrix/lottery-tipping-dialog",
25
+ "tags": [
26
+ "lottery-tipping-dialog"
27
+ ]
28
+ }
29
+ ],
30
+ "bundles": []
31
+ }
@@ -0,0 +1 @@
1
+ export { LotterySelectionGroup } from './lottery-selection-group';
@@ -0,0 +1,84 @@
1
+ :host {
2
+ width: 100%;
3
+ }
4
+
5
+ .lottery-selection-group {
6
+ container-type: inline-size;
7
+ padding: var(--lottery-selection-group-padding, 0);
8
+ background: var(--lottery-selection-group-background, transparent);
9
+ border: var(--lottery-selection-group-border, none);
10
+ border-radius: var(--lottery-selection-group-border-radius, 0);
11
+ }
12
+ .lottery-selection-group__item {
13
+ display: flex;
14
+ flex-direction: var(--lottery-selection-group-flex-direction, row);
15
+ align-items: var(--lottery-selection-group-item-align, center);
16
+ justify-content: var(--lottery-selection-group-item-justify, flex-start);
17
+ gap: var(--lottery-selection-group-item-gap, 16px);
18
+ width: 100%;
19
+ }
20
+ .lottery-selection-group__item--left {
21
+ width: var(--lottery-selection-group-label-width, 130px);
22
+ min-width: var(--lottery-selection-group-label-min-width, auto);
23
+ max-width: var(--lottery-selection-group-label-max-width, none);
24
+ color: var(--lottery-selection-group-label-color, var(--emw--color-typography, #000));
25
+ font-size: var(--lottery-selection-group-label-font-size, 1em);
26
+ font-weight: var(--lottery-selection-group-label-font-weight, bold);
27
+ text-align: var(--lottery-selection-group-label-align, left);
28
+ white-space: var(--lottery-selection-group-label-white-space, normal);
29
+ }
30
+ .lottery-selection-group__item--right {
31
+ flex: 1;
32
+ display: flex;
33
+ flex-wrap: var(--lottery-selection-group-bullets-wrap, wrap); /* Allow items to wrap */
34
+ gap: var(--lottery-selection-group-bullets-gap, 8px); /* Gap between bullets */
35
+ align-items: var(--lottery-selection-group-bullets-align, center);
36
+ justify-content: var(--lottery-selection-group-bullets-justify, flex-start); /* Align bullets to start */
37
+ }
38
+ @container (max-width: 320px) {
39
+ .lottery-selection-group__item--left {
40
+ width: 100px;
41
+ max-width: 100px;
42
+ }
43
+ }
44
+
45
+ .dialog-input {
46
+ width: 100%;
47
+ padding: var(--lottery-selection-group-input-padding, 8px);
48
+ border: var(--lottery-selection-group-input-border-width, 1px) var(--lottery-selection-group-input-border-style, solid) var(--lottery-selection-group-input-border-color, var(--emw--color-gray-100, #e6e6e6));
49
+ border-radius: var(--lottery-selection-group-input-radius, 4px);
50
+ background-color: var(--lottery-selection-group-input-bg, #fff);
51
+ color: var(--lottery-selection-group-input-color, #000);
52
+ box-sizing: border-box;
53
+ margin-top: var(--lottery-selection-group-input-margin-top, 10px);
54
+ font-size: var(--lottery-selection-group-input-font-size, 1em);
55
+ }
56
+ .dialog-input::placeholder {
57
+ color: var(--lottery-selection-group-input-placeholder-color, #999);
58
+ }
59
+
60
+ .dialog-input.invalid,
61
+ .dialog-input.invalid:focus {
62
+ border-color: var(--emw--color-error, #ff3d00);
63
+ outline-color: var(--emw--color-error, #ff3d00);
64
+ }
65
+
66
+ .error-message {
67
+ color: var(--lottery-selection-group-error-color, var(--emw--color-error, #ff3d00));
68
+ font-size: var(--lottery-selection-group-error-font-size, 12px);
69
+ font-weight: var(--lottery-selection-group-error-font-weight, normal);
70
+ margin-top: 4px;
71
+ }
72
+
73
+ .addSelectionDialog-title {
74
+ color: var(--lottery-selection-group-dialog-title-color, var(--emw--color-typography, #000));
75
+ font-size: var(--lottery-selection-group-dialog-title-font-size, 1.2em);
76
+ font-weight: var(--lottery-selection-group-dialog-title-font-weight, bold);
77
+ margin-bottom: var(--lottery-selection-group-dialog-title-margin-bottom, 0);
78
+ }
79
+ .addSelectionDialog-footer {
80
+ display: flex;
81
+ justify-content: var(--lottery-selection-group-dialog-footer-justify, flex-end);
82
+ gap: var(--lottery-selection-group-dialog-footer-gap, 18px);
83
+ margin-top: var(--lottery-selection-group-dialog-footer-margin-top, 0);
84
+ }