@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,285 @@
1
+ import { h } from "@stencil/core";
2
+ import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
3
+ import { translate } from "../../utils/locale.utils";
4
+ export class LotteryButton {
5
+ constructor() {
6
+ this.handleClick = (event) => {
7
+ if (this.disabled) {
8
+ return;
9
+ }
10
+ // Get the button element from the shadow root
11
+ const button = this.host.shadowRoot.querySelector('.btn');
12
+ if (!button)
13
+ return;
14
+ const rect = button.getBoundingClientRect();
15
+ const size = Math.max(rect.width, rect.height);
16
+ const top = event.clientY - rect.top - size / 2;
17
+ const left = event.clientX - rect.left - size / 2;
18
+ // Add the new ripple to the state, triggering a re-render
19
+ const newRipple = { top, left, size };
20
+ this.ripples = [...this.ripples, newRipple];
21
+ // Set a timeout to clean up the ripple from the state after the animation ends
22
+ // This prevents the DOM from filling up with old ripple elements
23
+ setTimeout(() => {
24
+ this.ripples = this.ripples.filter((r) => r !== newRipple);
25
+ }, 600); // This duration should match the CSS animation duration
26
+ };
27
+ this.mbSource = undefined;
28
+ this.clientStyling = undefined;
29
+ this.clientStylingUrl = undefined;
30
+ this.variant = 'primary';
31
+ this.size = 'medium';
32
+ this.disabled = false;
33
+ this.loading = false;
34
+ this.text = undefined;
35
+ this.language = 'en';
36
+ this.ripples = [];
37
+ }
38
+ handleClientStylingChange(newValue, oldValue) {
39
+ if (newValue != oldValue) {
40
+ setClientStyling(this.stylingContainer, this.clientStyling);
41
+ }
42
+ }
43
+ handleClientStylingUrlChange(newValue, oldValue) {
44
+ if (newValue != oldValue) {
45
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
46
+ }
47
+ }
48
+ handleMbSourceChange(newValue, oldValue) {
49
+ if (newValue != oldValue) {
50
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
51
+ }
52
+ }
53
+ componentDidLoad() {
54
+ if (this.stylingContainer) {
55
+ if (this.mbSource)
56
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
57
+ if (this.clientStyling)
58
+ setClientStyling(this.stylingContainer, this.clientStyling);
59
+ if (this.clientStylingUrl)
60
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
61
+ }
62
+ }
63
+ disconnectedCallback() {
64
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
65
+ }
66
+ render() {
67
+ const { variant, disabled, size } = this;
68
+ const isDisabled = disabled || this.loading;
69
+ return (h("button", { key: '01f92ec117f679466c30ea86cdc8af7caf8f8e6d', class: {
70
+ btn: true,
71
+ [`btn--${variant}`]: true,
72
+ [`btn--${size}`]: true,
73
+ 'btn--loading': this.loading
74
+ }, disabled: isDisabled, onClick: this.handleClick }, this.loading ? (h("div", { class: "loading-container" }, h("span", { class: "content" }, this.text || translate('loading', this.language)), h("span", { class: "spinner" }))) : (h("span", { class: "content" }, this.text)), h("div", { key: '918ddc7bbcd8aba1f2c194aa73f311b63016d2ec', class: "ripple-container" }, this.ripples.map((ripple, index) => (h("span", { key: index, class: "ripple", style: {
75
+ top: `${ripple.top}px`,
76
+ left: `${ripple.left}px`,
77
+ width: `${ripple.size}px`,
78
+ height: `${ripple.size}px`
79
+ } }))))));
80
+ }
81
+ static get is() { return "lottery-button"; }
82
+ static get encapsulation() { return "shadow"; }
83
+ static get originalStyleUrls() {
84
+ return {
85
+ "$": ["lottery-button.scss"]
86
+ };
87
+ }
88
+ static get styleUrls() {
89
+ return {
90
+ "$": ["lottery-button.css"]
91
+ };
92
+ }
93
+ static get properties() {
94
+ return {
95
+ "mbSource": {
96
+ "type": "string",
97
+ "mutable": false,
98
+ "complexType": {
99
+ "original": "string",
100
+ "resolved": "string",
101
+ "references": {}
102
+ },
103
+ "required": false,
104
+ "optional": false,
105
+ "docs": {
106
+ "tags": [],
107
+ "text": ""
108
+ },
109
+ "attribute": "mb-source",
110
+ "reflect": true
111
+ },
112
+ "clientStyling": {
113
+ "type": "string",
114
+ "mutable": false,
115
+ "complexType": {
116
+ "original": "string",
117
+ "resolved": "string",
118
+ "references": {}
119
+ },
120
+ "required": false,
121
+ "optional": false,
122
+ "docs": {
123
+ "tags": [],
124
+ "text": ""
125
+ },
126
+ "attribute": "client-styling",
127
+ "reflect": true
128
+ },
129
+ "clientStylingUrl": {
130
+ "type": "string",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "string",
134
+ "resolved": "string",
135
+ "references": {}
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": ""
142
+ },
143
+ "attribute": "client-styling-url",
144
+ "reflect": true
145
+ },
146
+ "variant": {
147
+ "type": "string",
148
+ "mutable": false,
149
+ "complexType": {
150
+ "original": "ButtonVariant",
151
+ "resolved": "\"dashed\" | \"outline\" | \"primary\" | \"text\"",
152
+ "references": {
153
+ "ButtonVariant": {
154
+ "location": "local",
155
+ "path": "/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/src/components/lottery-button/lottery-button.tsx",
156
+ "id": "../../../../packages/stencil/lottery-button/src/components/lottery-button/lottery-button.tsx::ButtonVariant"
157
+ }
158
+ }
159
+ },
160
+ "required": false,
161
+ "optional": false,
162
+ "docs": {
163
+ "tags": [],
164
+ "text": "The variant of the button.\nCan be 'primary', 'outline', 'dashed', or 'text'."
165
+ },
166
+ "attribute": "variant",
167
+ "reflect": true,
168
+ "defaultValue": "'primary'"
169
+ },
170
+ "size": {
171
+ "type": "string",
172
+ "mutable": false,
173
+ "complexType": {
174
+ "original": "ButtonSize",
175
+ "resolved": "\"large\" | \"medium\" | \"small\"",
176
+ "references": {
177
+ "ButtonSize": {
178
+ "location": "local",
179
+ "path": "/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-button/src/components/lottery-button/lottery-button.tsx",
180
+ "id": "../../../../packages/stencil/lottery-button/src/components/lottery-button/lottery-button.tsx::ButtonSize"
181
+ }
182
+ }
183
+ },
184
+ "required": false,
185
+ "optional": false,
186
+ "docs": {
187
+ "tags": [],
188
+ "text": "The size of the button.\nCan be 'small', 'medium', or 'large'."
189
+ },
190
+ "attribute": "size",
191
+ "reflect": true,
192
+ "defaultValue": "'medium'"
193
+ },
194
+ "disabled": {
195
+ "type": "boolean",
196
+ "mutable": false,
197
+ "complexType": {
198
+ "original": "boolean",
199
+ "resolved": "boolean",
200
+ "references": {}
201
+ },
202
+ "required": false,
203
+ "optional": false,
204
+ "docs": {
205
+ "tags": [],
206
+ "text": "If `true`, the user cannot interact with the button."
207
+ },
208
+ "attribute": "disabled",
209
+ "reflect": true,
210
+ "defaultValue": "false"
211
+ },
212
+ "loading": {
213
+ "type": "boolean",
214
+ "mutable": false,
215
+ "complexType": {
216
+ "original": "boolean",
217
+ "resolved": "boolean",
218
+ "references": {}
219
+ },
220
+ "required": false,
221
+ "optional": false,
222
+ "docs": {
223
+ "tags": [],
224
+ "text": ""
225
+ },
226
+ "attribute": "loading",
227
+ "reflect": true,
228
+ "defaultValue": "false"
229
+ },
230
+ "text": {
231
+ "type": "string",
232
+ "mutable": false,
233
+ "complexType": {
234
+ "original": "string",
235
+ "resolved": "string",
236
+ "references": {}
237
+ },
238
+ "required": false,
239
+ "optional": false,
240
+ "docs": {
241
+ "tags": [],
242
+ "text": ""
243
+ },
244
+ "attribute": "text",
245
+ "reflect": true
246
+ },
247
+ "language": {
248
+ "type": "string",
249
+ "mutable": false,
250
+ "complexType": {
251
+ "original": "string",
252
+ "resolved": "string",
253
+ "references": {}
254
+ },
255
+ "required": false,
256
+ "optional": false,
257
+ "docs": {
258
+ "tags": [],
259
+ "text": ""
260
+ },
261
+ "attribute": "language",
262
+ "reflect": true,
263
+ "defaultValue": "'en'"
264
+ }
265
+ };
266
+ }
267
+ static get states() {
268
+ return {
269
+ "ripples": {}
270
+ };
271
+ }
272
+ static get elementRef() { return "host"; }
273
+ static get watchers() {
274
+ return [{
275
+ "propName": "clientStyling",
276
+ "methodName": "handleClientStylingChange"
277
+ }, {
278
+ "propName": "clientStylingUrl",
279
+ "methodName": "handleClientStylingUrlChange"
280
+ }, {
281
+ "propName": "mbSource",
282
+ "methodName": "handleMbSourceChange"
283
+ }];
284
+ }
285
+ }
@@ -0,0 +1 @@
1
+ export * from './components/lottery-button';
@@ -0,0 +1,28 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr', 'zh'];
3
+ const TRANSLATIONS = {
4
+ en: {
5
+ loading: 'Loading'
6
+ },
7
+ ro: {},
8
+ fr: {},
9
+ ar: {},
10
+ hr: {}
11
+ };
12
+ export const translate = (key, customLang, replacements) => {
13
+ const lang = customLang;
14
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
15
+ if (replacements) {
16
+ Object.keys(replacements).forEach((placeholder) => {
17
+ translation = translation.replace(`{${placeholder}}`, replacements[placeholder]);
18
+ });
19
+ }
20
+ return translation;
21
+ };
22
+ export const getTranslations = (data) => {
23
+ Object.keys(data).forEach((item) => {
24
+ for (let key in data[item]) {
25
+ TRANSLATIONS[item][key] = data[item][key];
26
+ }
27
+ });
28
+ };
@@ -0,0 +1,3 @@
1
+ export function format(first, middle, last) {
2
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
3
+ }
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };