@everymatrix/lottery-button 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 (57) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-236aaf98.js +1207 -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-18510b14.js +174 -0
  6. package/dist/cjs/lottery-button.cjs.entry.js +10 -0
  7. package/dist/cjs/lottery-button.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +12 -0
  9. package/dist/collection/components/lottery-button/index.js +1 -0
  10. package/dist/collection/components/lottery-button/lottery-button.css +168 -0
  11. package/dist/collection/components/lottery-button/lottery-button.js +285 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/utils/locale.utils.js +28 -0
  14. package/dist/collection/utils/utils.js +3 -0
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/index-b461bf7a.js +1180 -0
  17. package/dist/esm/index.js +2 -0
  18. package/dist/esm/loader.js +11 -0
  19. package/dist/esm/lottery-button-f20aa4a1.js +172 -0
  20. package/dist/esm/lottery-button.entry.js +2 -0
  21. package/dist/esm/lottery-button.js +20 -0
  22. package/dist/index.cjs.js +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/lottery-button/app-globals-0f993ce5.js +1 -0
  25. package/dist/lottery-button/index-b461bf7a.js +2 -0
  26. package/dist/lottery-button/index.esm.js +1 -0
  27. package/dist/lottery-button/lottery-button-f20aa4a1.js +1 -0
  28. package/dist/lottery-button/lottery-button.entry.js +1 -0
  29. package/dist/lottery-button/lottery-button.esm.js +1 -0
  30. package/dist/stencil.config.dev.js +19 -0
  31. package/dist/stencil.config.js +19 -0
  32. package/dist/storybook/main.js +43 -0
  33. package/dist/storybook/preview.js +9 -0
  34. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  35. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/packages/stencil/lottery-button/stencil.config.d.ts +2 -0
  36. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/packages/stencil/lottery-button/stencil.config.dev.d.ts +2 -0
  37. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/packages/stencil/lottery-button/storybook/main.d.ts +3 -0
  38. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/packages/stencil/lottery-button/storybook/preview.d.ts +70 -0
  39. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/tools/plugins/index.d.ts +4 -0
  40. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  41. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  42. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  43. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  44. package/dist/types/components/lottery-button/index.d.ts +1 -0
  45. package/dist/types/components/lottery-button/lottery-button.d.ts +39 -0
  46. package/dist/types/components.d.ts +75 -0
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  49. package/dist/types/utils/locale.utils.d.ts +2 -0
  50. package/dist/types/utils/utils.d.ts +1 -0
  51. package/loader/cdn.js +1 -0
  52. package/loader/index.cjs.js +1 -0
  53. package/loader/index.d.ts +24 -0
  54. package/loader/index.es2017.js +1 -0
  55. package/loader/index.js +2 -0
  56. package/loader/package.json +11 -0
  57. package/package.json +27 -0
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const lotteryButton = require('./lottery-button-18510b14.js');
6
+ require('./index-236aaf98.js');
7
+
8
+
9
+
10
+ exports.LotteryButton = lotteryButton.LotteryButton;
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-236aaf98.js');
6
+ const appGlobals = require('./app-globals-3a1e7e63.js');
7
+
8
+ const defineCustomElements = async (win, options) => {
9
+ if (typeof window === 'undefined') return undefined;
10
+ await appGlobals.globalScripts();
11
+ return index.bootstrapLazy([["lottery-button.cjs",[[1,"lottery-button",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"variant":[513],"size":[513],"disabled":[516],"loading":[516],"text":[513],"language":[513],"ripples":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
12
+ };
13
+
14
+ exports.setNonce = index.setNonce;
15
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,174 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-236aaf98.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
+ const url = new URL(clientStylingUrl);
27
+
28
+ fetch(url.href)
29
+ .then((res) => res.text())
30
+ .then((data) => {
31
+ const cssFile = document.createElement('style');
32
+ cssFile.innerHTML = data;
33
+ if (stylingContainer) {
34
+ stylingContainer.appendChild(cssFile);
35
+ }
36
+ })
37
+ .catch((err) => {
38
+ console.error('There was an error while trying to load client styling from URL', err);
39
+ });
40
+ }
41
+
42
+ /**
43
+ * @name setStreamLibrary
44
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
45
+ * @param {HTMLElement} stylingContainer The highest element of the widget
46
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
47
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
48
+ */
49
+ function setStreamStyling(stylingContainer, domain, subscription) {
50
+ if (window.emMessageBus) {
51
+ const sheet = document.createElement('style');
52
+
53
+ window.emMessageBus.subscribe(domain, (data) => {
54
+ sheet.innerHTML = data;
55
+ if (stylingContainer) {
56
+ stylingContainer.appendChild(sheet);
57
+ }
58
+ });
59
+ }
60
+ }
61
+
62
+ const DEFAULT_LANGUAGE = 'en';
63
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr', 'zh'];
64
+ const TRANSLATIONS = {
65
+ en: {
66
+ loading: 'Loading'
67
+ },
68
+ ro: {},
69
+ fr: {},
70
+ ar: {},
71
+ hr: {}
72
+ };
73
+ const translate = (key, customLang, replacements) => {
74
+ const lang = customLang;
75
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
76
+ if (replacements) {
77
+ Object.keys(replacements).forEach((placeholder) => {
78
+ translation = translation.replace(`{${placeholder}}`, replacements[placeholder]);
79
+ });
80
+ }
81
+ return translation;
82
+ };
83
+
84
+ const lotteryButtonCss = ":host{display:inline-block;font-family:\"PingFang SC\", \"Microsoft YaHei\", \"Helvetica Neue\", Helvetica, Arial, sans-serif}.btn{position:relative;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;font-weight:500;cursor:pointer;outline:none;overflow:hidden;transition:background-color 0.2s, border-color 0.2s, color 0.2s;user-select:none;-webkit-tap-highlight-color:transparent}.btn .content{position:relative}.btn:disabled{cursor:not-allowed;opacity:0.5}.btn .loading-container{display:flex;align-items:center}.btn--loading{position:relative}.btn .spinner{display:inline-block;width:1em;height:1em;border:2px solid rgba(255, 255, 255, 0.3);border-radius:50%;border-top-color:white;animation:spin 1s ease-in-out infinite;margin-left:0.5em;vertical-align:middle}.btn--small .spinner{width:0.8em;height:0.8em}.btn--large .spinner{width:1.2em;height:1.2em}@keyframes spin{to{transform:rotate(360deg)}}.btn--primary{background-color:var(--emw--color-primary, #0d196e);color:var(--emw--color-typography-inverse, #fff)}.btn--primary:hover:not(:disabled){background-color:var(--emw--color-primary-variant, #1367e7)}.btn--primary:active:not(:disabled){background-color:#08104a}.btn--outline .spinner,.btn--dashed .spinner,.btn--text .spinner{border-top-color:currentColor;border-color:rgba(0, 0, 0, 0.2)}.btn--outline{background-color:var(--emw--color-background, #fff);border-color:#dcdcdc;color:var(--emw--color-typography, #000)}.btn--outline:hover:not(:disabled){background-color:var(--emw--color-background-tertiary, #ccc);border-color:#a6a6a6}.btn--outline:active:not(:disabled){background-color:#e6e6e6}.btn--dashed{background-color:transparent;border-style:dashed;border-color:#dcdcdc;color:#333}.btn--dashed:hover:not(:disabled){border-color:#a6a6a6;color:#0052d9}.btn--text{background-color:transparent;color:#0052d9;border-color:transparent}.btn--text:hover:not(:disabled){background-color:#f2f2f2}.btn--text:active:not(:disabled){background-color:#e6e6e6}.btn--small{height:28px;font-size:12px;padding:0 12px}.btn--medium{height:34px;font-size:14px;padding:0 18px}.btn--large{height:40px;font-size:16px;padding:0 24px}.ripple-container{position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;border-radius:inherit}.ripple{position:absolute;border-radius:50%;background-color:rgba(255, 255, 255, 0.3);transform:scale(0);animation:ripple-animation 600ms linear}.btn--outline .ripple,.btn--dashed .ripple,.btn--text .ripple{background-color:rgba(0, 0, 0, 0.1)}@keyframes ripple-animation{to{transform:scale(4);opacity:0}}";
85
+ const LotteryButtonStyle0 = lotteryButtonCss;
86
+
87
+ const LotteryButton = class {
88
+ constructor(hostRef) {
89
+ index.registerInstance(this, hostRef);
90
+ this.handleClick = (event) => {
91
+ if (this.disabled) {
92
+ return;
93
+ }
94
+ // Get the button element from the shadow root
95
+ const button = this.host.shadowRoot.querySelector('.btn');
96
+ if (!button)
97
+ return;
98
+ const rect = button.getBoundingClientRect();
99
+ const size = Math.max(rect.width, rect.height);
100
+ const top = event.clientY - rect.top - size / 2;
101
+ const left = event.clientX - rect.left - size / 2;
102
+ // Add the new ripple to the state, triggering a re-render
103
+ const newRipple = { top, left, size };
104
+ this.ripples = [...this.ripples, newRipple];
105
+ // Set a timeout to clean up the ripple from the state after the animation ends
106
+ // This prevents the DOM from filling up with old ripple elements
107
+ setTimeout(() => {
108
+ this.ripples = this.ripples.filter((r) => r !== newRipple);
109
+ }, 600); // This duration should match the CSS animation duration
110
+ };
111
+ this.mbSource = undefined;
112
+ this.clientStyling = undefined;
113
+ this.clientStylingUrl = undefined;
114
+ this.variant = 'primary';
115
+ this.size = 'medium';
116
+ this.disabled = false;
117
+ this.loading = false;
118
+ this.text = undefined;
119
+ this.language = 'en';
120
+ this.ripples = [];
121
+ }
122
+ handleClientStylingChange(newValue, oldValue) {
123
+ if (newValue != oldValue) {
124
+ setClientStyling(this.stylingContainer, this.clientStyling);
125
+ }
126
+ }
127
+ handleClientStylingUrlChange(newValue, oldValue) {
128
+ if (newValue != oldValue) {
129
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
130
+ }
131
+ }
132
+ handleMbSourceChange(newValue, oldValue) {
133
+ if (newValue != oldValue) {
134
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
135
+ }
136
+ }
137
+ componentDidLoad() {
138
+ if (this.stylingContainer) {
139
+ if (this.mbSource)
140
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
141
+ if (this.clientStyling)
142
+ setClientStyling(this.stylingContainer, this.clientStyling);
143
+ if (this.clientStylingUrl)
144
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
145
+ }
146
+ }
147
+ disconnectedCallback() {
148
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
149
+ }
150
+ render() {
151
+ const { variant, disabled, size } = this;
152
+ const isDisabled = disabled || this.loading;
153
+ return (index.h("button", { key: '01f92ec117f679466c30ea86cdc8af7caf8f8e6d', class: {
154
+ btn: true,
155
+ [`btn--${variant}`]: true,
156
+ [`btn--${size}`]: true,
157
+ 'btn--loading': this.loading
158
+ }, disabled: isDisabled, onClick: this.handleClick }, this.loading ? (index.h("div", { class: "loading-container" }, index.h("span", { class: "content" }, this.text || translate('loading', this.language)), index.h("span", { class: "spinner" }))) : (index.h("span", { class: "content" }, this.text)), index.h("div", { key: '918ddc7bbcd8aba1f2c194aa73f311b63016d2ec', class: "ripple-container" }, this.ripples.map((ripple, index$1) => (index.h("span", { key: index$1, class: "ripple", style: {
159
+ top: `${ripple.top}px`,
160
+ left: `${ripple.left}px`,
161
+ width: `${ripple.size}px`,
162
+ height: `${ripple.size}px`
163
+ } }))))));
164
+ }
165
+ get host() { return index.getElement(this); }
166
+ static get watchers() { return {
167
+ "clientStyling": ["handleClientStylingChange"],
168
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
169
+ "mbSource": ["handleMbSourceChange"]
170
+ }; }
171
+ };
172
+ LotteryButton.style = LotteryButtonStyle0;
173
+
174
+ exports.LotteryButton = LotteryButton;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const lotteryButton = require('./lottery-button-18510b14.js');
6
+ require('./index-236aaf98.js');
7
+
8
+
9
+
10
+ exports.lottery_button = lotteryButton.LotteryButton;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-236aaf98.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-button.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.cjs",[[1,"lottery-button",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"variant":[513],"size":[513],"disabled":[516],"loading":[516],"text":[513],"language":[513],"ripples":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
23
+ });
24
+
25
+ exports.setNonce = index.setNonce;
@@ -0,0 +1,12 @@
1
+ {
2
+ "entries": [
3
+ "components/lottery-button/lottery-button.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "4.19.2",
8
+ "typescriptVersion": "5.4.5"
9
+ },
10
+ "collections": [],
11
+ "bundles": []
12
+ }
@@ -0,0 +1 @@
1
+ export { LotteryButton } from './lottery-button';
@@ -0,0 +1,168 @@
1
+ :host {
2
+ display: inline-block;
3
+ font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
4
+ }
5
+
6
+ .btn {
7
+ position: relative;
8
+ display: inline-flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ border: 1px solid transparent;
12
+ border-radius: 6px;
13
+ font-weight: 500;
14
+ cursor: pointer;
15
+ outline: none;
16
+ overflow: hidden;
17
+ transition: background-color 0.2s, border-color 0.2s, color 0.2s;
18
+ user-select: none;
19
+ -webkit-tap-highlight-color: transparent;
20
+ }
21
+ .btn .content {
22
+ position: relative;
23
+ }
24
+ .btn:disabled {
25
+ cursor: not-allowed;
26
+ opacity: 0.5;
27
+ }
28
+ .btn .loading-container {
29
+ display: flex;
30
+ align-items: center;
31
+ }
32
+ .btn--loading {
33
+ position: relative;
34
+ }
35
+ .btn .spinner {
36
+ display: inline-block;
37
+ width: 1em;
38
+ height: 1em;
39
+ border: 2px solid rgba(255, 255, 255, 0.3);
40
+ border-radius: 50%;
41
+ border-top-color: white;
42
+ animation: spin 1s ease-in-out infinite;
43
+ margin-left: 0.5em;
44
+ vertical-align: middle;
45
+ }
46
+ .btn--small .spinner {
47
+ width: 0.8em;
48
+ height: 0.8em;
49
+ }
50
+ .btn--large .spinner {
51
+ width: 1.2em;
52
+ height: 1.2em;
53
+ }
54
+
55
+ @keyframes spin {
56
+ to {
57
+ transform: rotate(360deg);
58
+ }
59
+ }
60
+ /* Primary Variant */
61
+ .btn--primary {
62
+ background-color: var(--emw--color-primary, #0d196e);
63
+ color: var(--emw--color-typography-inverse, #fff);
64
+ }
65
+ .btn--primary:hover:not(:disabled) {
66
+ background-color: var(--emw--color-primary-variant, #1367e7);
67
+ }
68
+ .btn--primary:active:not(:disabled) {
69
+ background-color: #08104a;
70
+ }
71
+
72
+ .btn--outline .spinner,
73
+ .btn--dashed .spinner,
74
+ .btn--text .spinner {
75
+ border-top-color: currentColor;
76
+ border-color: rgba(0, 0, 0, 0.2);
77
+ }
78
+
79
+ /* Outline Variant */
80
+ .btn--outline {
81
+ background-color: var(--emw--color-background, #fff);
82
+ border-color: #dcdcdc;
83
+ color: var(--emw--color-typography, #000);
84
+ }
85
+ .btn--outline:hover:not(:disabled) {
86
+ background-color: var(--emw--color-background-tertiary, #ccc);
87
+ border-color: #a6a6a6;
88
+ }
89
+ .btn--outline:active:not(:disabled) {
90
+ background-color: #e6e6e6;
91
+ }
92
+
93
+ /* Dashed Variant */
94
+ .btn--dashed {
95
+ background-color: transparent;
96
+ border-style: dashed;
97
+ border-color: #dcdcdc;
98
+ color: #333;
99
+ }
100
+ .btn--dashed:hover:not(:disabled) {
101
+ border-color: #a6a6a6;
102
+ color: #0052d9;
103
+ }
104
+
105
+ /* Text Variant */
106
+ .btn--text {
107
+ background-color: transparent;
108
+ color: #0052d9;
109
+ border-color: transparent;
110
+ }
111
+ .btn--text:hover:not(:disabled) {
112
+ background-color: #f2f2f2;
113
+ }
114
+ .btn--text:active:not(:disabled) {
115
+ background-color: #e6e6e6;
116
+ }
117
+
118
+ /* Size Variants */
119
+ .btn--small {
120
+ height: 28px;
121
+ font-size: 12px;
122
+ padding: 0 12px;
123
+ }
124
+
125
+ .btn--medium {
126
+ height: 34px;
127
+ font-size: 14px;
128
+ padding: 0 18px;
129
+ }
130
+
131
+ .btn--large {
132
+ height: 40px;
133
+ font-size: 16px;
134
+ padding: 0 24px;
135
+ }
136
+
137
+ /* Ripple Effect */
138
+ .ripple-container {
139
+ position: absolute;
140
+ top: 0;
141
+ left: 0;
142
+ width: 100%;
143
+ height: 100%;
144
+ overflow: hidden;
145
+ pointer-events: none;
146
+ border-radius: inherit;
147
+ }
148
+
149
+ .ripple {
150
+ position: absolute;
151
+ border-radius: 50%;
152
+ background-color: rgba(255, 255, 255, 0.3);
153
+ transform: scale(0);
154
+ animation: ripple-animation 600ms linear;
155
+ }
156
+
157
+ .btn--outline .ripple,
158
+ .btn--dashed .ripple,
159
+ .btn--text .ripple {
160
+ background-color: rgba(0, 0, 0, 0.1);
161
+ }
162
+
163
+ @keyframes ripple-animation {
164
+ to {
165
+ transform: scale(4);
166
+ opacity: 0;
167
+ }
168
+ }