@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.
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/index-bc355d7d.js +1310 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/cjs/lottery-button_4.cjs.entry.js +486 -0
- package/dist/cjs/lottery-selection-group-1608b2e2.js +480 -0
- package/dist/cjs/lottery-selection-group.cjs.js +25 -0
- package/dist/collection/collection-manifest.json +31 -0
- package/dist/collection/components/lottery-selection-group/index.js +1 -0
- package/dist/collection/components/lottery-selection-group/lottery-selection-group.css +84 -0
- package/dist/collection/components/lottery-selection-group/lottery-selection-group.js +685 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/model/type.js +1 -0
- package/dist/collection/utils/locale.utils.js +74 -0
- package/dist/collection/utils/utils.js +86 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/index-3a4d6110.js +1282 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/lottery-button_4.entry.js +480 -0
- package/dist/esm/lottery-selection-group-656d6729.js +475 -0
- package/dist/esm/lottery-selection-group.js +20 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/lottery-selection-group/app-globals-0f993ce5.js +1 -0
- package/dist/lottery-selection-group/index-3a4d6110.js +2 -0
- package/dist/lottery-selection-group/index.esm.js +1 -0
- package/dist/lottery-selection-group/lottery-button_4.entry.js +1 -0
- package/dist/lottery-selection-group/lottery-selection-group-656d6729.js +1 -0
- package/dist/lottery-selection-group/lottery-selection-group.esm.js +1 -0
- package/dist/stencil.config.dev.js +19 -0
- package/dist/stencil.config.js +19 -0
- package/dist/storybook/main.js +43 -0
- package/dist/storybook/preview.js +9 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
- 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
- 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
- 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
- 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
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/index.d.ts +4 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-selection-group/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
- package/dist/types/components/lottery-selection-group/index.d.ts +1 -0
- package/dist/types/components/lottery-selection-group/lottery-selection-group.d.ts +122 -0
- package/dist/types/components.d.ts +218 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/model/type.d.ts +12 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/locale.utils.d.ts +3 -0
- package/dist/types/utils/utils.d.ts +14 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +27 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr', 'zh'];
|
|
3
|
+
const TRANSLATIONS = {
|
|
4
|
+
en: {
|
|
5
|
+
noTicketBoard: 'No ticket board available.',
|
|
6
|
+
selectionCleared: 'Your selection has been cleared.',
|
|
7
|
+
clearAll: 'Clear All',
|
|
8
|
+
stopAt: 'Stop at',
|
|
9
|
+
turnover: 'Turnover: ',
|
|
10
|
+
pleaseFillIn: 'Please fill in all the selection input!',
|
|
11
|
+
fillIn: 'Fill in',
|
|
12
|
+
noBets: 'Sorry. No bets have been placed so far. Check back later!',
|
|
13
|
+
search: 'Search',
|
|
14
|
+
clear: 'Clear',
|
|
15
|
+
oddsChart: 'Odds Chart',
|
|
16
|
+
ticketSuccess: 'Ticket purchased successfully.',
|
|
17
|
+
stakePerLine: 'Stake per Line:',
|
|
18
|
+
lowestOdds: 'Lowest Odds:',
|
|
19
|
+
highestOdds: 'Highest Odds:',
|
|
20
|
+
orderSummary: 'ORDER SUMMARY',
|
|
21
|
+
ticket: 'Ticket',
|
|
22
|
+
lines: 'Lines',
|
|
23
|
+
total: 'Total',
|
|
24
|
+
submit: 'Submit',
|
|
25
|
+
loading: 'Loading',
|
|
26
|
+
enterValidNumber: 'Please enter a valid number.',
|
|
27
|
+
enterNumberBetween: 'Please enter a number between {min} and {max}.',
|
|
28
|
+
numberAlreadySelected: 'This number has already been selected.',
|
|
29
|
+
enterScoreUpTo: 'Please enter the score (Up to {maxScore})',
|
|
30
|
+
enterValue: 'Please enter a value',
|
|
31
|
+
myChoices: 'My Choices',
|
|
32
|
+
teams: 'Teams',
|
|
33
|
+
scores: 'Scores',
|
|
34
|
+
euro: 'Euro',
|
|
35
|
+
cancel: 'Cancel',
|
|
36
|
+
confirm: 'Confirm'
|
|
37
|
+
},
|
|
38
|
+
ro: {},
|
|
39
|
+
fr: {},
|
|
40
|
+
ar: {},
|
|
41
|
+
hr: {}
|
|
42
|
+
};
|
|
43
|
+
export const translate = (key, customLang, replacements) => {
|
|
44
|
+
const lang = customLang;
|
|
45
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
46
|
+
if (replacements) {
|
|
47
|
+
Object.keys(replacements).forEach((placeholder) => {
|
|
48
|
+
translation = translation.replace(`{${placeholder}}`, replacements[placeholder]);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return translation;
|
|
52
|
+
};
|
|
53
|
+
export const getTranslations = (data) => {
|
|
54
|
+
Object.keys(data).forEach((item) => {
|
|
55
|
+
for (let key in data[item]) {
|
|
56
|
+
TRANSLATIONS[item][key] = data[item][key];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
export const resolveTranslationUrl = async (translationUrl) => {
|
|
61
|
+
if (translationUrl) {
|
|
62
|
+
try {
|
|
63
|
+
const response = await fetch(translationUrl);
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
66
|
+
}
|
|
67
|
+
const translations = await response.json();
|
|
68
|
+
getTranslations(translations);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error('Failed to fetch or parse translations from URL:', error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { translate } from "./locale.utils";
|
|
2
|
+
export function format(first, middle, last) {
|
|
3
|
+
return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
|
|
4
|
+
}
|
|
5
|
+
export function getBulletTextsSet(bulletTexts, splitToken) {
|
|
6
|
+
return new Set(bulletTexts ? bulletTexts.split(splitToken) : []);
|
|
7
|
+
}
|
|
8
|
+
export function validateInput({ value, selectedSet, maxValue, minValue, language, type = 'integer' }) {
|
|
9
|
+
const trimmedValue = value.trim();
|
|
10
|
+
if (type === 'integer') {
|
|
11
|
+
// Strict integer check
|
|
12
|
+
if (!/^-?\d+$/.test(trimmedValue)) {
|
|
13
|
+
return {
|
|
14
|
+
valid: false,
|
|
15
|
+
errorMessage: translate('enterValidNumber', language),
|
|
16
|
+
value
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const numValue = Number(trimmedValue);
|
|
20
|
+
if (isNaN(numValue)) {
|
|
21
|
+
return {
|
|
22
|
+
valid: false,
|
|
23
|
+
errorMessage: translate('enterValidNumber', language),
|
|
24
|
+
value
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if ((minValue !== undefined && numValue < minValue) || (maxValue !== undefined && numValue > maxValue)) {
|
|
28
|
+
return {
|
|
29
|
+
valid: false,
|
|
30
|
+
errorMessage: translate('enterNumberBetween', language, {
|
|
31
|
+
min: minValue,
|
|
32
|
+
max: maxValue
|
|
33
|
+
}),
|
|
34
|
+
value
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// Normalize value (e.g. "05" -> "5") for set check
|
|
38
|
+
const normalizedValue = String(numValue);
|
|
39
|
+
if (selectedSet.has(normalizedValue)) {
|
|
40
|
+
return {
|
|
41
|
+
valid: false,
|
|
42
|
+
errorMessage: translate('numberAlreadySelected', language),
|
|
43
|
+
value
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// Text mode validation
|
|
49
|
+
if (selectedSet.has(trimmedValue)) {
|
|
50
|
+
return {
|
|
51
|
+
valid: false,
|
|
52
|
+
errorMessage: translate('numberAlreadySelected', language), // Or generic 'alreadySelected' if available, but reusing key for now
|
|
53
|
+
value
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
valid: true,
|
|
59
|
+
errorMessage: '',
|
|
60
|
+
value
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function removeBulletTexts(text, selectedArr) {
|
|
64
|
+
return selectedArr.filter((s) => s !== text);
|
|
65
|
+
}
|
|
66
|
+
export function addSelectedBulletTexts(text, selectedArr) {
|
|
67
|
+
return selectedArr.concat([text]);
|
|
68
|
+
}
|
|
69
|
+
export function removeAndAddSelectedBulletTexts(text, selectedArr, maxSelectedCount) {
|
|
70
|
+
return selectedArr.slice(selectedArr.length - (maxSelectedCount - 1)).concat([text]);
|
|
71
|
+
}
|
|
72
|
+
export function buildSelectedBulletTextsArr(item, selectedArr, maxSelectedCount) {
|
|
73
|
+
if (item.type === 'delete') {
|
|
74
|
+
return removeBulletTexts(item.text, selectedArr);
|
|
75
|
+
}
|
|
76
|
+
if (item.type === 'toggle') {
|
|
77
|
+
if (selectedArr.includes(item.text)) {
|
|
78
|
+
return removeBulletTexts(item.text, selectedArr);
|
|
79
|
+
}
|
|
80
|
+
if (selectedArr.length >= maxSelectedCount) {
|
|
81
|
+
return removeAndAddSelectedBulletTexts(item.text, selectedArr, maxSelectedCount);
|
|
82
|
+
}
|
|
83
|
+
return addSelectedBulletTexts(item.text, selectedArr);
|
|
84
|
+
}
|
|
85
|
+
return [];
|
|
86
|
+
}
|