@eturnity/eturnity_reusable_components 9.28.3-EXP-11.0 → 9.28.3-EXP-11.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/package.json
CHANGED
|
@@ -244,6 +244,18 @@
|
|
|
244
244
|
default: '400px',
|
|
245
245
|
type: String,
|
|
246
246
|
},
|
|
247
|
+
// Floor for the measured popup width; lower it (e.g. '0') for short
|
|
248
|
+
// tooltip-style content.
|
|
249
|
+
minWidth: {
|
|
250
|
+
default: '230px',
|
|
251
|
+
type: String,
|
|
252
|
+
},
|
|
253
|
+
// Padding of the popup box; tighten (e.g. '6px 10px') for
|
|
254
|
+
// tooltip-style content.
|
|
255
|
+
contentPadding: {
|
|
256
|
+
default: '',
|
|
257
|
+
type: String,
|
|
258
|
+
},
|
|
247
259
|
openTrigger: {
|
|
248
260
|
type: String,
|
|
249
261
|
default: 'onHover',
|
|
@@ -494,6 +506,7 @@
|
|
|
494
506
|
width: '100%',
|
|
495
507
|
maxWidth: props.maxWidth,
|
|
496
508
|
overflowY: 'auto',
|
|
509
|
+
...(props.contentPadding ? { padding: props.contentPadding } : {}),
|
|
497
510
|
backgroundColor: props.contentBackgroundColor
|
|
498
511
|
? props.contentBackgroundColor
|
|
499
512
|
: props.image
|
|
@@ -566,13 +579,21 @@
|
|
|
566
579
|
clone.style.whiteSpace = 'nowrap' // Prevent text wrapping during measurement
|
|
567
580
|
document.body.appendChild(clone)
|
|
568
581
|
|
|
569
|
-
// Get fresh content width from clone
|
|
570
|
-
|
|
582
|
+
// Get fresh content width from clone. offsetWidth rounds to an
|
|
583
|
+
// integer, which can under-measure by <1px and wrap an exact-fit
|
|
584
|
+
// line — use the subpixel rect width, ceiled.
|
|
585
|
+
const contentWidth = Math.ceil(clone.getBoundingClientRect().width)
|
|
571
586
|
document.body.removeChild(clone)
|
|
572
587
|
|
|
573
|
-
// Calculate new width
|
|
588
|
+
// Calculate new width. The measured clone is the bare text span, but
|
|
589
|
+
// TextOverlay wraps it with 10px horizontal padding each side under
|
|
590
|
+
// border-box sizing — compensate or exact-fit content wraps.
|
|
591
|
+
const TEXT_OVERLAY_HORIZONTAL_PADDING_PX = 20
|
|
574
592
|
const calculatedWidth = Math.min(
|
|
575
|
-
Math.max(
|
|
593
|
+
Math.max(
|
|
594
|
+
contentWidth + TEXT_OVERLAY_HORIZONTAL_PADDING_PX,
|
|
595
|
+
parseInt(props.minWidth, 10) || 0
|
|
596
|
+
),
|
|
576
597
|
parseInt(props.maxWidth, 10)
|
|
577
598
|
)
|
|
578
599
|
|
|
@@ -79,6 +79,49 @@ describe('InfoText Component', () => {
|
|
|
79
79
|
expect(wrapper.find('[data-test-id="infoText_dot"]').exists()).toBe(true)
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
+
describe("popup width floor (minWidth)", () => {
|
|
83
|
+
const showPopup = async (w) => {
|
|
84
|
+
w.vm.isMobile = false
|
|
85
|
+
await w.vm.$nextTick()
|
|
86
|
+
// the hover listener sits on the component root
|
|
87
|
+
await w.trigger("mouseenter")
|
|
88
|
+
// updatePosition awaits two ticks before measuring
|
|
89
|
+
await new Promise((resolve) => setTimeout(resolve))
|
|
90
|
+
await w.vm.$nextTick()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
it("keeps the 230px width floor by default", async () => {
|
|
94
|
+
const roomy = mount(InfoText, {
|
|
95
|
+
props: { ...defaultProps, maxWidth: "400px" },
|
|
96
|
+
global: { stubs: { teleport: true } },
|
|
97
|
+
})
|
|
98
|
+
await showPopup(roomy)
|
|
99
|
+
// jsdom measures content at 0px, so the floor is what remains
|
|
100
|
+
expect(roomy.vm.infoBoxWidth).toBe(230)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it("applies contentPadding to the popup box", async () => {
|
|
104
|
+
const padded = mount(InfoText, {
|
|
105
|
+
props: { ...defaultProps, contentPadding: "6px 10px" },
|
|
106
|
+
global: { stubs: { teleport: true } },
|
|
107
|
+
})
|
|
108
|
+
await showPopup(padded)
|
|
109
|
+
const box = padded.find('[data-test-id="info_text_wrapper"]')
|
|
110
|
+
.element.firstElementChild
|
|
111
|
+
expect(box.style.padding).toBe("6px 10px")
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it("allows a lower minWidth for tooltip-style content", async () => {
|
|
115
|
+
const small = mount(InfoText, {
|
|
116
|
+
props: { ...defaultProps, minWidth: "0" },
|
|
117
|
+
global: { stubs: { teleport: true } },
|
|
118
|
+
})
|
|
119
|
+
await showPopup(small)
|
|
120
|
+
// jsdom content measures 0px; only the padding compensation remains
|
|
121
|
+
expect(small.vm.infoBoxWidth).toBe(20)
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
|
|
82
125
|
test('iconTextContent slot is correctly rendered', async () => {
|
|
83
126
|
// override
|
|
84
127
|
const props = defaultProps.iconTextContent
|