@eturnity/eturnity_reusable_components 8.49.3 → 9.3.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/main.es24.js CHANGED
@@ -1,555 +1,4 @@
1
- import "./main.es3.js";
2
- import _sfc_main$1 from "./main.es15.js";
3
- import styled from "./main.es7.js";
4
- import theme from "./main.es8.js";
5
- import _export_sfc from "./main.es11.js";
6
- import { computed, onMounted, onUnmounted, watch, nextTick, resolveComponent, openBlock, createBlock, withCtx, createElementVNode as createBaseVNode, createVNode, createElementBlock, createTextVNode, createCommentVNode, Fragment, renderSlot, Teleport } from "./main.es6.js";
7
- import { toDisplayString, normalizeStyle } from "./main.es16.js";
8
- import { ref } from "./main.es18.js";
9
- const TextOverlayAttrs = {
10
- appTheme: String,
11
- image: Boolean,
12
- width: Number
13
- };
14
- const TextOverlay = styled("div", TextOverlayAttrs)`
15
- color: ${(props) => props.image ? props.theme.colors.grey1 : props.theme.colors.black};
16
- font-size: ${(props) => props.image ? "12px" : "13px"};
17
- border-radius: 4px;
18
- padding: 10px;
19
- word-wrap: break-word;
20
- overflow-wrap: break-word;
21
- white-space: normal;
22
- width: ${(props) => props.width ? `${props.width}px` : "100%"};
23
- box-shadow: ${(props) => props.image ? "0 2px 10px rgba(0, 0, 0, 0.1)" : "none"};
24
-
25
- a {
26
- color: ${(props) => props.theme.colors.blue};
27
- }
28
-
29
- img + span {
30
- margin-top: 10px;
31
- display: block;
32
- }
33
- `;
34
- const PageContainer = styled("div")`
35
- display: ${(props) => props.type === "dot" ? "unset" : "inline-block"};
36
- position: relative;
37
- `;
38
- const TextWrapper = styled("div")`
39
- z-index: 9999999999;
40
- position: absolute;
41
- `;
42
- const OverlayImage = styled("img")`
43
- width: 100%;
44
- height: auto;
45
- `;
46
- const Dot = styled("div")`
47
- width: 5px;
48
- height: 5px;
49
- background-color: ${(props) => props.color};
50
- border-radius: 50%;
51
- `;
52
- const IconWrapperAttrs = {
53
- backgroundColor: String,
54
- borderRadius: String,
55
- padding: String,
56
- hoveredIcon: Boolean,
57
- isActive: Boolean,
58
- isDisabled: Boolean
59
- };
60
- const IconWrapper = styled("div", IconWrapperAttrs)`
61
- display: flex;
62
- align-items: center;
63
- justify-content: center;
64
- gap: 6px;
65
- white-space: nowrap;
66
- background-color: ${(props) => props.backgroundColor};
67
- border-radius: ${(props) => props.hoveredIcon ? "6px" : props.borderRadius};
68
- padding: ${(props) => props.padding};
69
- width: ${(props) => props.hoveredIcon ? "32px" : ""};
70
- height: ${(props) => props.hoveredIcon ? "32px" : ""};
71
- cursor: pointer;
72
- background-color: ${(props) => props.isActive ? props.theme.colors.transparentWhite2 : ""};
73
- cursor: ${(props) => props.isDisabled ? "not-allowed" : "pointer"};
74
- &:hover {
75
- background-color: ${(props) => props.hoveredIcon ? props.theme.colors.transparentWhite2 : ""};
76
- }
77
- `;
78
- const LabelWrapperAttrs = {
79
- size: String,
80
- color: String
81
- };
82
- const LabelWrapper = styled("div", LabelWrapperAttrs)`
83
- font-size: ${(props) => props.size};
84
- color: ${(props) => props.color};
85
- `;
86
- const _sfc_main = {
87
- name: "InfoText",
88
- components: {
89
- IconComponent: _sfc_main$1,
90
- TextOverlay,
91
- // Arrow,
92
- Dot,
93
- PageContainer,
94
- TextWrapper,
95
- OverlayImage,
96
- IconWrapper,
97
- LabelWrapper
98
- },
99
- props: {
100
- text: {
101
- required: false,
102
- default: "",
103
- type: String
104
- },
105
- isActive: {
106
- required: false,
107
- default: false,
108
- type: Boolean
109
- },
110
- labelText: {
111
- required: false,
112
- default: "",
113
- type: String
114
- },
115
- size: {
116
- type: String,
117
- default: "14px"
118
- },
119
- infoPosition: {
120
- required: false,
121
- default: null,
122
- type: String
123
- },
124
- maxWidth: {
125
- default: "400px",
126
- type: String
127
- },
128
- openTrigger: {
129
- type: String,
130
- default: "onHover",
131
- validator: (value) => ["onHover", "onClick"].includes(value)
132
- },
133
- buttonType: {
134
- type: String,
135
- default: "regular",
136
- validator: (value) => ["regular", "error"].includes(value)
137
- },
138
- image: {
139
- type: String,
140
- default: ""
141
- },
142
- iconName: {
143
- type: String,
144
- default: "info"
145
- },
146
- iconColor: {
147
- type: String,
148
- default: null,
149
- required: false
150
- },
151
- isDisabled: {
152
- type: Boolean,
153
- default: false,
154
- required: false
155
- },
156
- dotColor: {
157
- type: String,
158
- required: false,
159
- default: theme.semanticColors.blue[400]
160
- },
161
- type: {
162
- type: String,
163
- required: false,
164
- default: "info"
165
- // info, dot
166
- },
167
- appTheme: {
168
- type: String,
169
- default: "light",
170
- // light or dark
171
- required: false
172
- },
173
- labelAlign: {
174
- type: String,
175
- default: "right",
176
- required: false
177
- },
178
- backgroundColor: {
179
- type: String,
180
- default: "",
181
- required: false
182
- },
183
- contentBackgroundColor: {
184
- type: String,
185
- default: "",
186
- required: false
187
- },
188
- borderRadius: {
189
- type: String,
190
- default: "",
191
- required: false
192
- },
193
- padding: {
194
- type: String,
195
- default: "",
196
- required: false
197
- },
198
- labelSize: {
199
- type: String,
200
- default: "12px",
201
- required: false
202
- },
203
- noIcon: {
204
- type: Boolean,
205
- default: false,
206
- required: false
207
- },
208
- hoveredIcon: {
209
- type: Boolean,
210
- default: false,
211
- required: false
212
- },
213
- hideInfoText: {
214
- type: Boolean,
215
- default: false,
216
- required: false
217
- },
218
- dataId: {
219
- required: false,
220
- default: "",
221
- type: String
222
- },
223
- dataQaId: {
224
- required: false,
225
- default: "",
226
- type: String
227
- }
228
- },
229
- setup(props) {
230
- const isVisible = ref(false);
231
- const container = ref(null);
232
- const icon = ref(null);
233
- const infoBox = ref(null);
234
- const textContent = ref(null);
235
- const infoImage = ref(null);
236
- const infoBoxWidth = ref(0);
237
- const infoBoxHeight = ref(0);
238
- const boxStyle = ref({});
239
- const arrowStyle = ref({});
240
- const wrapperStyle = ref({});
241
- const isMobile = ref(window.innerWidth <= 768);
242
- const textStyle = computed(() => ({
243
- fontSize: props.image ? "12px" : "13px",
244
- color: props.image ? theme.colors.grey1 : props.appTheme === "dark" ? theme.colors.black : theme.colors.white,
245
- textAlign: props.image ? "right" : "left"
246
- }));
247
- const calculatePosition = (width) => {
248
- if (!icon.value || !width)
249
- return {};
250
- const iconRect = icon.value.getBoundingClientRect();
251
- const windowHeight = window.innerHeight;
252
- const windowWidth = window.innerWidth;
253
- const spaceBelow = windowHeight - iconRect.bottom - 10;
254
- const spaceAbove = iconRect.top - 10;
255
- const spaceRight = windowWidth - iconRect.right - 10;
256
- const spaceLeft = iconRect.left - 10;
257
- const positions = [{
258
- position: "bottom",
259
- space: spaceBelow
260
- }, {
261
- position: "top",
262
- space: spaceAbove
263
- }, {
264
- position: "right",
265
- space: spaceRight
266
- }, {
267
- position: "left",
268
- space: spaceLeft
269
- }].sort((a, b) => b.space - a.space);
270
- const bestPosition = props.infoPosition ? props.infoPosition : positions[0].position;
271
- let top, left, arrowPosition;
272
- switch (bestPosition) {
273
- case "bottom":
274
- top = Math.round(iconRect.bottom + 10);
275
- left = Math.round(Math.min(iconRect.left, windowWidth - width - 10));
276
- arrowPosition = {
277
- left: `${Math.round(Math.min(Math.max(iconRect.left - left + iconRect.width / 2 - 8, 2), width - 18))}px`,
278
- top: "-7px",
279
- bottom: "auto",
280
- transform: "rotate(180deg)"
281
- };
282
- break;
283
- case "top":
284
- top = Math.round(iconRect.top - infoBoxHeight.value - 10);
285
- left = Math.round(Math.min(iconRect.left, windowWidth - width - 10));
286
- arrowPosition = {
287
- left: `${Math.round(Math.min(Math.max(iconRect.left - left + iconRect.width / 2 - 8, 2), width - 18))}px`,
288
- top: "auto",
289
- bottom: "-7px",
290
- transform: "none"
291
- };
292
- break;
293
- case "right":
294
- top = Math.round(Math.max(Math.min(iconRect.top - (infoBoxHeight.value - iconRect.height) / 2, windowHeight - infoBoxHeight.value - 10), 10));
295
- left = Math.round(iconRect.right + 10);
296
- arrowPosition = {
297
- left: "-7px",
298
- top: `${Math.round(Math.min(Math.max(iconRect.top - top + iconRect.height / 2 - 8, 2), infoBoxHeight.value - 18))}px`,
299
- bottom: "auto",
300
- transform: "rotate(90deg)"
301
- };
302
- break;
303
- case "left":
304
- top = Math.round(Math.max(Math.min(iconRect.top - (infoBoxHeight.value - iconRect.height) / 2, windowHeight - infoBoxHeight.value - 10), 10));
305
- left = Math.round(iconRect.left - width - 10);
306
- arrowPosition = {
307
- left: "auto",
308
- right: "-7px",
309
- top: `${Math.round(Math.min(Math.max(iconRect.top - top + iconRect.height / 2 - 8, 2), infoBoxHeight.value - 18))}px`,
310
- bottom: "auto",
311
- transform: "rotate(-90deg)"
312
- };
313
- break;
314
- }
315
- arrowStyle.value = arrowPosition;
316
- wrapperStyle.value = {
317
- position: "fixed",
318
- top: `${top}px`,
319
- left: `${left}px`,
320
- transform: "none",
321
- width: `${width}px`
322
- };
323
- return {
324
- width: "100%",
325
- maxWidth: props.maxWidth,
326
- overflowY: "auto",
327
- backgroundColor: props.contentBackgroundColor ? props.contentBackgroundColor : props.image ? theme.colors.white : props.appTheme === "light" ? theme.colors.black : theme.colors.grey5
328
- };
329
- };
330
- const showInfo = async () => {
331
- isVisible.value = !props.hideInfoText;
332
- await nextTick();
333
- await nextTick();
334
- await updatePosition();
335
- };
336
- const hideInfo = () => {
337
- isVisible.value = false;
338
- infoBoxWidth.value = 0;
339
- };
340
- const toggleInfo = () => {
341
- isVisible.value ? hideInfo() : showInfo();
342
- };
343
- const handleScroll = () => {
344
- if (isVisible.value) {
345
- hideInfo();
346
- }
347
- updatePosition();
348
- };
349
- const isIconInView = () => {
350
- if (!icon.value)
351
- return false;
352
- const rect = icon.value.getBoundingClientRect();
353
- return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
354
- };
355
- const updatePosition = async () => {
356
- if (!infoBox.value || !textContent.value)
357
- return;
358
- if (infoBox.value.$el) {
359
- infoBox.value.$el.style.visibility = "hidden";
360
- infoBox.value.$el.style.display = "block";
361
- }
362
- await nextTick();
363
- if (!isIconInView()) {
364
- if (isVisible.value)
365
- hideInfo();
366
- return;
367
- }
368
- const clone = textContent.value.cloneNode(true);
369
- clone.style.position = "absolute";
370
- clone.style.visibility = "hidden";
371
- clone.style.width = "auto";
372
- clone.style.maxWidth = "none";
373
- clone.style.whiteSpace = "nowrap";
374
- document.body.appendChild(clone);
375
- const contentWidth = clone.offsetWidth;
376
- document.body.removeChild(clone);
377
- const calculatedWidth = Math.min(Math.max(contentWidth, 230), parseInt(props.maxWidth, 10));
378
- infoBoxWidth.value = calculatedWidth;
379
- await nextTick();
380
- infoBoxHeight.value = infoBox.value.$el.offsetHeight;
381
- boxStyle.value = calculatePosition(calculatedWidth);
382
- if (isVisible.value && infoBox.value.$el) {
383
- infoBox.value.$el.style.visibility = "visible";
384
- }
385
- };
386
- const onImageLoad = () => {
387
- if (infoImage.value) {
388
- infoBoxHeight.value = infoBox.value.$el.offsetHeight;
389
- updatePosition();
390
- }
391
- };
392
- const handleClickOutside = (event) => {
393
- if ((props.openTrigger === "onClick" || isMobile.value) && isVisible.value) {
394
- const clickedElement = event.target;
395
- if (infoBox.value && !infoBox.value.$el.contains(clickedElement) && !icon.value.contains(clickedElement)) {
396
- hideInfo();
397
- }
398
- }
399
- };
400
- const handleResize = () => {
401
- isMobile.value = window.innerWidth <= 768;
402
- updatePosition();
403
- };
404
- onMounted(() => {
405
- window.addEventListener("scroll", handleScroll, {
406
- passive: true
407
- });
408
- window.addEventListener("resize", handleResize);
409
- document.addEventListener("scroll", handleScroll, {
410
- passive: true,
411
- capture: true
412
- });
413
- document.addEventListener("click", handleClickOutside);
414
- });
415
- onUnmounted(() => {
416
- window.removeEventListener("scroll", handleScroll);
417
- window.removeEventListener("resize", handleResize);
418
- document.removeEventListener("scroll", handleScroll, {
419
- capture: true
420
- });
421
- document.removeEventListener("click", handleClickOutside);
422
- });
423
- watch(isVisible, (newValue) => {
424
- if (newValue) {
425
- updatePosition();
426
- }
427
- });
428
- return {
429
- isVisible,
430
- boxStyle,
431
- arrowStyle,
432
- showInfo,
433
- hideInfo,
434
- toggleInfo,
435
- container,
436
- icon,
437
- infoBox,
438
- textContent,
439
- infoImage,
440
- infoBoxWidth,
441
- infoBoxHeight,
442
- wrapperStyle,
443
- textStyle,
444
- onImageLoad,
445
- isMobile
446
- };
447
- },
448
- computed: {
449
- computedIconColor() {
450
- return this.buttonType === "error" ? theme.colors.red : theme.colors.mediumGray;
451
- }
452
- }
453
- };
454
- const _hoisted_1 = {
455
- ref: "icon",
456
- "data-test-id": "infoText_trigger"
457
- };
458
- const _hoisted_2 = ["innerHTML"];
459
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
460
- const _component_LabelWrapper = resolveComponent("LabelWrapper");
461
- const _component_Dot = resolveComponent("Dot");
462
- const _component_IconComponent = resolveComponent("IconComponent");
463
- const _component_IconWrapper = resolveComponent("IconWrapper");
464
- const _component_OverlayImage = resolveComponent("OverlayImage");
465
- const _component_TextOverlay = resolveComponent("TextOverlay");
466
- const _component_TextWrapper = resolveComponent("TextWrapper");
467
- const _component_PageContainer = resolveComponent("PageContainer");
468
- return openBlock(), createBlock(_component_PageContainer, {
469
- ref: "container",
470
- "data-id": $props.dataId,
471
- "data-qa-id": $props.dataQaId,
472
- "data-test-id": "infoText_container",
473
- type: $props.type,
474
- onClick: _cache[0] || (_cache[0] = ($event) => {
475
- ($setup.isMobile || $props.openTrigger === "onClick") && $setup.toggleInfo();
476
- }),
477
- onMouseenter: _cache[1] || (_cache[1] = ($event) => !$setup.isMobile && $props.openTrigger === "onHover" && $setup.showInfo()),
478
- onMouseleave: _cache[2] || (_cache[2] = ($event) => !$setup.isMobile && $props.openTrigger === "onHover" && $setup.hideInfo())
479
- }, {
480
- default: withCtx(() => [createBaseVNode("div", _hoisted_1, [createVNode(_component_IconWrapper, {
481
- "background-color": $props.backgroundColor,
482
- "border-radius": $props.borderRadius,
483
- "hovered-icon": $props.hoveredIcon,
484
- "is-active": $props.isActive,
485
- "is-disabled": $props.isDisabled,
486
- padding: $props.padding
487
- }, {
488
- default: withCtx(() => [!_ctx.$slots.trigger ? (openBlock(), createElementBlock(Fragment, {
489
- key: 0
490
- }, [$props.labelText && $props.labelAlign === "left" ? (openBlock(), createBlock(_component_LabelWrapper, {
491
- key: 0,
492
- color: $props.iconColor || $options.computedIconColor,
493
- size: $props.labelSize
494
- }, {
495
- default: withCtx(() => [createTextVNode(toDisplayString($props.labelText), 1)]),
496
- _: 1
497
- }, 8, ["color", "size"])) : createCommentVNode("", true), createTextVNode(), $props.type === "dot" ? (openBlock(), createBlock(_component_Dot, {
498
- key: 1,
499
- color: $props.dotColor,
500
- "data-test-id": "infoText_dot"
501
- }, null, 8, ["color"])) : !$props.noIcon ? (openBlock(), createBlock(_component_IconComponent, {
502
- key: 2,
503
- color: $props.iconColor || $options.computedIconColor,
504
- cursor: $props.isDisabled ? "not-allowed" : "pointer",
505
- disabled: $props.isDisabled,
506
- "hovered-color": $props.iconColor || $options.computedIconColor,
507
- name: $props.iconName,
508
- size: $props.size
509
- }, null, 8, ["color", "cursor", "disabled", "hovered-color", "name", "size"])) : createCommentVNode("", true), createTextVNode(), $props.labelText && $props.labelAlign === "right" ? (openBlock(), createBlock(_component_LabelWrapper, {
510
- key: 3,
511
- color: $props.iconColor || $options.computedIconColor,
512
- size: $props.labelSize
513
- }, {
514
- default: withCtx(() => [createTextVNode(toDisplayString($props.labelText), 1)]),
515
- _: 1
516
- }, 8, ["color", "size"])) : createCommentVNode("", true)], 64)) : createCommentVNode("", true), createTextVNode(), renderSlot(_ctx.$slots, "trigger")]),
517
- _: 3
518
- }, 8, ["background-color", "border-radius", "hovered-icon", "is-active", "is-disabled", "padding"])], 512), createTextVNode(), !$props.hideInfoText && $setup.isVisible && (!!$props.text || _ctx.$slots.default) ? (openBlock(), createBlock(Teleport, {
519
- key: 0,
520
- to: "body"
521
- }, [createVNode(_component_TextWrapper, {
522
- "data-test-id": "info_text_wrapper",
523
- style: normalizeStyle($setup.wrapperStyle)
524
- }, {
525
- default: withCtx(() => [createVNode(_component_TextOverlay, {
526
- ref: "infoBox",
527
- "app-theme": $props.appTheme,
528
- image: $props.image,
529
- style: normalizeStyle($setup.boxStyle),
530
- width: $setup.infoBoxWidth
531
- }, {
532
- default: withCtx(() => [$props.image ? (openBlock(), createBlock(_component_OverlayImage, {
533
- key: 0,
534
- ref: "infoImage",
535
- alt: "Info Image",
536
- src: $props.image,
537
- onLoad: $setup.onImageLoad
538
- }, null, 8, ["src", "onLoad"])) : createCommentVNode("", true), createTextVNode(), !$props.hideInfoText ? (openBlock(), createElementBlock("span", {
539
- key: 1,
540
- ref: "textContent",
541
- style: normalizeStyle($setup.textStyle)
542
- }, [renderSlot(_ctx.$slots, "default", {}, () => [createBaseVNode("span", {
543
- innerHTML: $props.text
544
- }, null, 8, _hoisted_2)])], 4)) : createCommentVNode("", true)]),
545
- _: 3
546
- }, 8, ["app-theme", "image", "style", "width"]), createTextVNode()]),
547
- _: 3
548
- }, 8, ["style"])])) : createCommentVNode("", true)]),
549
- _: 3
550
- }, 8, ["data-id", "data-qa-id", "type"]);
551
- }
552
- const InfoText = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
1
+ const Test_vue_vue_type_style_index_0_lang = "";
553
2
  export {
554
- InfoText as default
3
+ Test_vue_vue_type_style_index_0_lang as default
555
4
  };