@lion/ui 0.0.9 → 0.0.11
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/components/accordion/src/LionAccordion.js +2 -2
- package/components/core/src/SlotMixin.js +2 -1
- package/components/dialog/src/LionDialog.js +0 -28
- package/components/dialog/test/lion-dialog.test.js +11 -10
- package/components/form-integrations/test/form-group-methods.test.js +6 -4
- package/components/form-integrations/test/form-integrations.test.js +10 -5
- package/components/form-integrations/test/helpers/umbrella-form.js +10 -0
- package/components/form-integrations/test/model-value-consistency.test.js +29 -20
- package/components/input-datepicker/src/LionInputDatepicker.js +66 -104
- package/components/input-datepicker/src/localizeNamespaceLoader.js +188 -0
- package/components/input-datepicker/test/lion-input-datepicker.test.js +15 -20
- package/components/input-datepicker/test-helpers/DatepickerInputObject.js +3 -3
- package/components/input-tel/src/parsers.js +1 -1
- package/components/listbox/test-suites/ListboxMixin.suite.js +3 -3
- package/components/localize/src/singleton.js +1 -1
- package/components/localize/test/number/formatNumber.test.js +2 -6
- package/components/overlays/src/OverlayController.js +292 -291
- package/components/overlays/src/OverlayMixin.js +17 -18
- package/components/overlays/src/OverlaysManager.js +28 -53
- package/components/overlays/src/configurations/visibility-trigger-partials/withClickInteraction.js +32 -0
- package/components/overlays/src/configurations/visibility-trigger-partials/withHoverInteraction.js +76 -0
- package/components/overlays/src/configurations/withBottomSheetConfig.js +3 -0
- package/components/overlays/src/configurations/withDropdownConfig.js +3 -0
- package/components/overlays/src/configurations/withModalDialogConfig.js +3 -0
- package/components/overlays/src/configurations/withTooltipConfig.js +29 -0
- package/components/overlays/src/overlayDocumentStyle.js +24 -0
- package/components/overlays/src/overlayShadowDomStyle.js +138 -0
- package/components/overlays/src/singleton.js +3 -1
- package/components/overlays/test/ArrowMixin.test.js +0 -1
- package/components/overlays/test/OverlayController.test.js +372 -274
- package/components/overlays/test/OverlaysManager.test.js +23 -32
- package/components/overlays/test/global-positioning.test.js +4 -15
- package/components/overlays/test/local-positioning.test.js +65 -38
- package/components/overlays/test-suites/OverlayMixin.suite.js +18 -26
- package/components/overlays/types/OverlayConfig.ts +38 -11
- package/components/overlays/types/OverlayMixinTypes.ts +2 -2
- package/components/select-rich/src/LionSelectInvoker.js +2 -3
- package/components/select-rich/src/LionSelectRich.js +22 -20
- package/components/select-rich/test/lion-select-rich.test.js +5 -7
- package/components/tooltip/src/LionTooltip.js +3 -90
- package/components/tooltip/test/lion-tooltip.test.js +52 -20
- package/custom-elements.json +535 -503
- package/dist-types/components/core/src/SlotMixin.d.ts.map +1 -1
- package/dist-types/components/dialog/src/LionDialog.d.ts +0 -2
- package/dist-types/components/dialog/src/LionDialog.d.ts.map +1 -1
- package/dist-types/components/form-integrations/test/helpers/umbrella-form.d.ts +4 -0
- package/dist-types/components/form-integrations/test/helpers/umbrella-form.d.ts.map +1 -1
- package/dist-types/components/form-integrations/test/model-value-consistency.test.d.ts.map +1 -1
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts +3 -3
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts.map +1 -1
- package/dist-types/components/input-datepicker/src/localizeNamespaceLoader.d.ts +4 -0
- package/dist-types/components/input-datepicker/src/localizeNamespaceLoader.d.ts.map +1 -0
- package/dist-types/components/overlays/src/OverlayController.d.ts +56 -101
- package/dist-types/components/overlays/src/OverlayController.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlayMixin.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlaysManager.d.ts +0 -7
- package/dist-types/components/overlays/src/OverlaysManager.d.ts.map +1 -1
- package/dist-types/components/overlays/src/configurations/visibility-trigger-partials/withClickInteraction.d.ts +12 -0
- package/dist-types/components/overlays/src/configurations/visibility-trigger-partials/withClickInteraction.d.ts.map +1 -0
- package/dist-types/components/overlays/src/configurations/visibility-trigger-partials/withHoverInteraction.d.ts +18 -0
- package/dist-types/components/overlays/src/configurations/visibility-trigger-partials/withHoverInteraction.d.ts.map +1 -0
- package/dist-types/components/overlays/src/configurations/withBottomSheetConfig.d.ts.map +1 -1
- package/dist-types/components/overlays/src/configurations/withDropdownConfig.d.ts.map +1 -1
- package/dist-types/components/overlays/src/configurations/withModalDialogConfig.d.ts.map +1 -1
- package/dist-types/components/overlays/src/configurations/withTooltipConfig.d.ts +8 -0
- package/dist-types/components/overlays/src/configurations/withTooltipConfig.d.ts.map +1 -0
- package/dist-types/components/overlays/src/overlayDocumentStyle.d.ts +2 -0
- package/dist-types/components/overlays/src/overlayDocumentStyle.d.ts.map +1 -0
- package/dist-types/components/overlays/src/overlayShadowDomStyle.d.ts +2 -0
- package/dist-types/components/overlays/src/overlayShadowDomStyle.d.ts.map +1 -0
- package/dist-types/components/overlays/src/singleton.d.ts +2 -1
- package/dist-types/components/overlays/src/singleton.d.ts.map +1 -1
- package/dist-types/components/overlays/test-suites/OverlayMixin.suite.d.ts.map +1 -1
- package/dist-types/components/overlays/types/OverlayConfig.d.ts +19 -10
- package/dist-types/components/overlays/types/OverlayConfig.d.ts.map +1 -1
- package/dist-types/components/overlays/types/OverlayMixinTypes.d.ts +2 -2
- package/dist-types/components/overlays/types/OverlayMixinTypes.d.ts.map +1 -1
- package/dist-types/components/select-rich/src/LionSelectInvoker.d.ts +3 -27
- package/dist-types/components/select-rich/src/LionSelectInvoker.d.ts.map +1 -1
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts.map +1 -1
- package/dist-types/components/select-rich/test/lion-select-rich.test.d.ts.map +1 -1
- package/dist-types/components/tooltip/src/LionTooltip.d.ts +4 -20
- package/dist-types/components/tooltip/src/LionTooltip.d.ts.map +1 -1
- package/dist-types/components/tooltip/test/lion-tooltip.test.d.ts.map +1 -1
- package/dist-types/exports/input-datepicker.d.ts +0 -1
- package/dist-types/exports/overlays.d.ts +1 -1
- package/dist-types/exports/types/overlays.d.ts +1 -0
- package/dist-types/exports/types/overlays.d.ts.map +1 -1
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/overview.md +1 -1
- package/docs/components/combobox/use-cases.md +1 -1
- package/docs/components/dialog/overview.md +5 -9
- package/docs/components/dialog/use-cases.md +43 -87
- package/docs/components/fieldset/overview.md +5 -5
- package/docs/components/form/overview.md +3 -3
- package/docs/components/icon/use-cases.md +1 -1
- package/docs/components/input/overview.md +1 -1
- package/docs/components/input-amount/overview.md +3 -3
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-datepicker/overview.md +5 -5
- package/docs/components/input-email/overview.md +2 -2
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/overview.md +1 -1
- package/docs/components/input-tel/overview.md +1 -1
- package/docs/components/input-tel/use-cases.md +6 -6
- package/docs/components/input-tel-dropdown/overview.md +1 -1
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/select-rich/use-cases.md +1 -1
- package/docs/components/tabs/examples.md +1 -1
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
- package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
- package/docs/fundamentals/systems/core/overview.md +1 -1
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
- package/docs/fundamentals/systems/form/model-value.md +1 -1
- package/docs/fundamentals/systems/form/overview.md +28 -28
- package/docs/fundamentals/systems/form/use-cases.md +4 -0
- package/docs/fundamentals/systems/form/validate.md +1 -1
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/assets/{applyDemoOverlayStyles.js → applyDemoOverlayStyles.mjs} +2 -1
- package/docs/fundamentals/systems/overlays/assets/demo-el-using-overlaymixin.mjs +119 -0
- package/docs/fundamentals/systems/overlays/assets/{demo-overlay-backdrop.js → demo-overlay-backdrop.mjs} +3 -4
- package/docs/fundamentals/systems/overlays/assets/demo-overlay-positioning.mjs +537 -0
- package/docs/fundamentals/systems/overlays/assets/umbrella-form.js +9 -2
- package/docs/fundamentals/systems/overlays/configuration.md +56 -54
- package/docs/fundamentals/systems/overlays/overview.md +5 -5
- package/docs/fundamentals/systems/overlays/use-cases.md +83 -77
- package/docs/fundamentals/tools/helpers/overview.md +1 -1
- package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
- package/docs/guides/how-to/create-a-custom-field.md +6 -6
- package/docs/guides/how-to/extend-a-native-input.md +3 -3
- package/docs/guides/index.md +8 -8
- package/docs/guides/principles/index.md +5 -5
- package/docs/guides/principles/styling.md +1 -1
- package/exports/input-datepicker.js +0 -1
- package/exports/overlays.js +1 -1
- package/exports/types/overlays.ts +1 -0
- package/package.json +2 -1
- package/components/input-datepicker/src/LionCalendarOverlayFrame.js +0 -125
- package/components/overlays/src/globalOverlaysStyle.js +0 -139
- package/dist-types/components/input-datepicker/src/LionCalendarOverlayFrame.d.ts +0 -10
- package/dist-types/components/input-datepicker/src/LionCalendarOverlayFrame.d.ts.map +0 -1
- package/dist-types/components/overlays/src/globalOverlaysStyle.d.ts +0 -2
- package/dist-types/components/overlays/src/globalOverlaysStyle.d.ts.map +0 -1
- package/dist-types/exports/define/lion-calendar-overlay-frame.d.ts +0 -2
- package/dist-types/exports/define/lion-calendar-overlay-frame.d.ts.map +0 -1
- package/docs/fundamentals/systems/overlays/assets/demo-overlay-system.js +0 -42
- package/docs/fundamentals/systems/overlays/form-integration.md +0 -65
- package/docs/fundamentals/systems/overlays/scope.md +0 -176
- package/exports/define/lion-calendar-overlay-frame.js +0 -3
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
import { renderLitAsNode } from '@lion/ui/helpers.js';
|
|
3
2
|
import { LionOption } from '@lion/ui/listbox.js';
|
|
4
3
|
import { getListboxMembers } from '@lion/ui/listbox-test-helpers.js';
|
|
5
4
|
import { OverlayController } from '@lion/ui/overlays.js';
|
|
@@ -152,7 +151,7 @@ describe('lion-select-rich', () => {
|
|
|
152
151
|
});
|
|
153
152
|
|
|
154
153
|
it('updates the invoker when the selected element is the same but the modelValue was updated asynchronously', async () => {
|
|
155
|
-
const
|
|
154
|
+
const tagString = defineCE(
|
|
156
155
|
class LionCustomOption extends LionOption {
|
|
157
156
|
render() {
|
|
158
157
|
return html`${this.modelValue.value}`;
|
|
@@ -163,27 +162,26 @@ describe('lion-select-rich', () => {
|
|
|
163
162
|
}
|
|
164
163
|
},
|
|
165
164
|
);
|
|
166
|
-
const
|
|
167
|
-
|
|
165
|
+
const tag = unsafeStatic(tagString);
|
|
168
166
|
const firstOption = /** @type {LionOption} */ (
|
|
169
|
-
|
|
167
|
+
await _fixture(html`<${tag} checked .choiceValue=${10}></${tag}>`)
|
|
170
168
|
);
|
|
171
169
|
|
|
172
170
|
const el = await fixture(html`
|
|
173
171
|
<lion-select-rich>
|
|
174
172
|
${firstOption}
|
|
175
|
-
<${
|
|
173
|
+
<${tag} .choiceValue=${20}></${tag}>
|
|
176
174
|
</lion-select-rich>
|
|
177
175
|
`);
|
|
178
176
|
|
|
179
177
|
const { _invokerNode } = getSelectRichMembers(el);
|
|
178
|
+
|
|
180
179
|
const firstChild = /** @type {HTMLElement} */ (
|
|
181
180
|
/** @type {ShadowRoot} */ (_invokerNode.shadowRoot).firstElementChild
|
|
182
181
|
);
|
|
183
182
|
expect(firstChild.textContent).to.equal('10');
|
|
184
183
|
|
|
185
184
|
firstOption.modelValue = { value: 30, checked: true };
|
|
186
|
-
await firstOption.updateComplete;
|
|
187
185
|
await el.updateComplete;
|
|
188
186
|
expect(firstChild.textContent).to.equal('30');
|
|
189
187
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { css, LitElement } from 'lit';
|
|
2
|
-
import { ArrowMixin, OverlayMixin } from '@lion/ui/overlays.js';
|
|
2
|
+
import { ArrowMixin, OverlayMixin, withTooltipConfig } from '@lion/ui/overlays.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @typedef {import('
|
|
5
|
+
* @typedef {import('@lion/ui/types/overlays.js').OverlayConfig} OverlayConfig
|
|
6
6
|
* @typedef {import('lit').CSSResult} CSSResult
|
|
7
7
|
* @typedef {import('lit').CSSResultArray} CSSResultArray
|
|
8
8
|
*/
|
|
@@ -49,10 +49,6 @@ export class LionTooltip extends ArrowMixin(OverlayMixin(LitElement)) {
|
|
|
49
49
|
* @type {'label'|'description'}
|
|
50
50
|
*/
|
|
51
51
|
this.invokerRelation = 'description';
|
|
52
|
-
/** @protected */
|
|
53
|
-
this._mouseActive = false;
|
|
54
|
-
/** @protected */
|
|
55
|
-
this._keyActive = false;
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
/** @protected */
|
|
@@ -60,90 +56,7 @@ export class LionTooltip extends ArrowMixin(OverlayMixin(LitElement)) {
|
|
|
60
56
|
_defineOverlayConfig() {
|
|
61
57
|
return /** @type {OverlayConfig} */ ({
|
|
62
58
|
...super._defineOverlayConfig(),
|
|
63
|
-
|
|
64
|
-
elementToFocusAfterHide: undefined,
|
|
65
|
-
hidesOnEsc: true,
|
|
66
|
-
hidesOnOutsideEsc: true,
|
|
67
|
-
handlesAccessibility: true,
|
|
68
|
-
isTooltip: true,
|
|
69
|
-
invokerRelation: this.invokerRelation,
|
|
59
|
+
...withTooltipConfig({ invokerRelation: this.invokerRelation }),
|
|
70
60
|
});
|
|
71
61
|
}
|
|
72
|
-
|
|
73
|
-
/** @protected */
|
|
74
|
-
_hasDisabledInvoker() {
|
|
75
|
-
if (this._overlayCtrl && this._overlayCtrl.invoker) {
|
|
76
|
-
return (
|
|
77
|
-
/** @type {HTMLElement & { disabled: boolean }} */ (this._overlayCtrl.invoker).disabled ||
|
|
78
|
-
this._overlayCtrl.invoker.getAttribute('aria-disabled') === 'true'
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** @protected */
|
|
85
|
-
_setupOpenCloseListeners() {
|
|
86
|
-
super._setupOpenCloseListeners();
|
|
87
|
-
this.__resetActive = this.__resetActive.bind(this);
|
|
88
|
-
this._overlayCtrl.addEventListener('hide', this.__resetActive);
|
|
89
|
-
|
|
90
|
-
this.addEventListener('mouseenter', this._showMouse);
|
|
91
|
-
this.addEventListener('mouseleave', this._hideMouse);
|
|
92
|
-
|
|
93
|
-
this._showKey = this._showKey.bind(this);
|
|
94
|
-
this._overlayInvokerNode.addEventListener('focusin', this._showKey);
|
|
95
|
-
|
|
96
|
-
this._hideKey = this._hideKey.bind(this);
|
|
97
|
-
this._overlayInvokerNode.addEventListener('focusout', this._hideKey);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** @protected */
|
|
101
|
-
_teardownOpenCloseListeners() {
|
|
102
|
-
super._teardownOpenCloseListeners();
|
|
103
|
-
this._overlayCtrl.removeEventListener('hide', this.__resetActive);
|
|
104
|
-
this.removeEventListener('mouseenter', this._showMouse);
|
|
105
|
-
this.removeEventListener('mouseleave', this._hideMouse);
|
|
106
|
-
this._overlayInvokerNode.removeEventListener('focusin', this._showKey);
|
|
107
|
-
this._overlayInvokerNode.removeEventListener('focusout', this._hideKey);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** @private */
|
|
111
|
-
__resetActive() {
|
|
112
|
-
this._mouseActive = false;
|
|
113
|
-
this._keyActive = false;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** @protected */
|
|
117
|
-
_showMouse() {
|
|
118
|
-
if (!this._keyActive) {
|
|
119
|
-
this._mouseActive = true;
|
|
120
|
-
if (!this._hasDisabledInvoker()) {
|
|
121
|
-
this.opened = true;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** @protected */
|
|
127
|
-
_hideMouse() {
|
|
128
|
-
if (!this._keyActive) {
|
|
129
|
-
this.opened = false;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** @protected */
|
|
134
|
-
_showKey() {
|
|
135
|
-
if (!this._mouseActive) {
|
|
136
|
-
this._keyActive = true;
|
|
137
|
-
if (!this._hasDisabledInvoker()) {
|
|
138
|
-
this.opened = true;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/** @protected */
|
|
144
|
-
_hideKey() {
|
|
145
|
-
if (!this._mouseActive) {
|
|
146
|
-
this.opened = false;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
62
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import '@lion/ui/define/lion-tooltip.js';
|
|
2
2
|
import { aTimeout, expect, fixture, html, unsafeStatic } from '@open-wc/testing';
|
|
3
3
|
import { runOverlayMixinSuite } from '@lion/ui/overlays-test-suites.js';
|
|
4
|
+
import sinon from 'sinon';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @typedef {import('../src/LionTooltip.js').LionTooltip} LionTooltip
|
|
@@ -20,6 +21,15 @@ describe('lion-tooltip', () => {
|
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
describe('Basic', () => {
|
|
24
|
+
/** @type {sinon.SinonFakeTimers} */
|
|
25
|
+
let clock;
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
clock = sinon.useFakeTimers();
|
|
28
|
+
});
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
clock.restore();
|
|
31
|
+
});
|
|
32
|
+
|
|
23
33
|
it('shows content on mouseenter and hide on mouseleave', async () => {
|
|
24
34
|
const el = /** @type {LionTooltip} */ (
|
|
25
35
|
await fixture(html`
|
|
@@ -30,15 +40,19 @@ describe('lion-tooltip', () => {
|
|
|
30
40
|
`)
|
|
31
41
|
);
|
|
32
42
|
const eventMouseEnter = new Event('mouseenter');
|
|
33
|
-
|
|
43
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
44
|
+
el._overlayInvokerNode.dispatchEvent(eventMouseEnter);
|
|
34
45
|
await el.updateComplete;
|
|
35
|
-
|
|
46
|
+
clock.tick(300);
|
|
47
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
36
48
|
expect(el._overlayCtrl.isShown).to.equal(true);
|
|
37
49
|
const eventMouseLeave = new Event('mouseleave');
|
|
38
|
-
|
|
50
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
51
|
+
el._overlayInvokerNode.dispatchEvent(eventMouseLeave);
|
|
52
|
+
clock.tick(300);
|
|
39
53
|
await el.updateComplete;
|
|
40
54
|
await el.updateComplete; // webkit needs longer
|
|
41
|
-
// @ts-expect-error allow
|
|
55
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
42
56
|
expect(el._overlayCtrl.isShown).to.equal(false);
|
|
43
57
|
});
|
|
44
58
|
|
|
@@ -52,14 +66,18 @@ describe('lion-tooltip', () => {
|
|
|
52
66
|
`)
|
|
53
67
|
);
|
|
54
68
|
const eventMouseEnter = new Event('mouseenter');
|
|
55
|
-
|
|
69
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
70
|
+
el._overlayInvokerNode.dispatchEvent(eventMouseEnter);
|
|
71
|
+
clock.tick(300);
|
|
56
72
|
await el.updateComplete;
|
|
57
|
-
// @ts-expect-error allow
|
|
73
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
58
74
|
expect(el._overlayCtrl.isShown).to.equal(true);
|
|
59
75
|
const eventFocusOut = new Event('focusout');
|
|
60
|
-
|
|
76
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
77
|
+
el._overlayContentNode.dispatchEvent(eventFocusOut);
|
|
78
|
+
clock.tick(300);
|
|
61
79
|
await el.updateComplete;
|
|
62
|
-
// @ts-expect-error allow
|
|
80
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
63
81
|
expect(el._overlayCtrl.isShown).to.equal(true);
|
|
64
82
|
});
|
|
65
83
|
|
|
@@ -77,14 +95,16 @@ describe('lion-tooltip', () => {
|
|
|
77
95
|
);
|
|
78
96
|
const eventFocusIn = new Event('focusin');
|
|
79
97
|
invoker.dispatchEvent(eventFocusIn);
|
|
98
|
+
clock.tick(300);
|
|
80
99
|
await el.updateComplete;
|
|
81
|
-
// @ts-expect-error allow
|
|
100
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
82
101
|
expect(el._overlayCtrl.isShown).to.equal(true);
|
|
83
102
|
const eventFocusOut = new Event('focusout');
|
|
84
103
|
invoker.dispatchEvent(eventFocusOut);
|
|
104
|
+
clock.tick(300);
|
|
85
105
|
await el.updateComplete;
|
|
86
106
|
await el.updateComplete; // webkit needs longer
|
|
87
|
-
// @ts-expect-error allow
|
|
107
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
88
108
|
expect(el._overlayCtrl.isShown).to.equal(false);
|
|
89
109
|
});
|
|
90
110
|
|
|
@@ -102,13 +122,15 @@ describe('lion-tooltip', () => {
|
|
|
102
122
|
);
|
|
103
123
|
const eventFocusIn = new Event('focusin');
|
|
104
124
|
invoker.dispatchEvent(eventFocusIn);
|
|
125
|
+
clock.tick(300);
|
|
105
126
|
await el.updateComplete;
|
|
106
|
-
// @ts-expect-error allow
|
|
127
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
107
128
|
expect(el._overlayCtrl.isShown).to.equal(true);
|
|
108
129
|
const eventMouseLeave = new Event('mouseleave');
|
|
109
130
|
invoker.dispatchEvent(eventMouseLeave);
|
|
131
|
+
clock.tick(300);
|
|
110
132
|
await el.updateComplete;
|
|
111
|
-
// @ts-expect-error allow
|
|
133
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
112
134
|
expect(el._overlayCtrl.isShown).to.equal(true);
|
|
113
135
|
});
|
|
114
136
|
|
|
@@ -127,12 +149,12 @@ describe('lion-tooltip', () => {
|
|
|
127
149
|
const eventMouseEnter = new Event('mouseenter');
|
|
128
150
|
el.dispatchEvent(eventMouseEnter);
|
|
129
151
|
await el.updateComplete;
|
|
130
|
-
// @ts-expect-error allow
|
|
152
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
131
153
|
expect(el._overlayCtrl.isShown).to.equal(false);
|
|
132
154
|
const eventFocusIn = new Event('focusin');
|
|
133
155
|
invoker.dispatchEvent(eventFocusIn);
|
|
134
156
|
await el.updateComplete;
|
|
135
|
-
// @ts-expect-error allow
|
|
157
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
136
158
|
expect(el._overlayCtrl.isShown).to.equal(false);
|
|
137
159
|
});
|
|
138
160
|
|
|
@@ -151,12 +173,12 @@ describe('lion-tooltip', () => {
|
|
|
151
173
|
const eventMouseEnter = new Event('mouseenter');
|
|
152
174
|
el.dispatchEvent(eventMouseEnter);
|
|
153
175
|
await el.updateComplete;
|
|
154
|
-
// @ts-expect-error allow
|
|
176
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
155
177
|
expect(el._overlayCtrl.isShown).to.equal(false);
|
|
156
178
|
const eventFocusIn = new Event('focusin');
|
|
157
179
|
invoker.dispatchEvent(eventFocusIn);
|
|
158
180
|
await el.updateComplete;
|
|
159
|
-
// @ts-expect-error allow
|
|
181
|
+
// @ts-expect-error [allow-protected-in-tests]
|
|
160
182
|
expect(el._overlayCtrl.isShown).to.equal(false);
|
|
161
183
|
});
|
|
162
184
|
|
|
@@ -182,6 +204,15 @@ describe('lion-tooltip', () => {
|
|
|
182
204
|
});
|
|
183
205
|
|
|
184
206
|
describe('Arrow', () => {
|
|
207
|
+
/** @type {sinon.SinonFakeTimers} */
|
|
208
|
+
let clock;
|
|
209
|
+
beforeEach(() => {
|
|
210
|
+
clock = sinon.useFakeTimers();
|
|
211
|
+
});
|
|
212
|
+
afterEach(() => {
|
|
213
|
+
clock.restore();
|
|
214
|
+
});
|
|
215
|
+
|
|
185
216
|
it('shows when "has-arrow" is configured', async () => {
|
|
186
217
|
const el = /** @type {LionTooltip} */ (
|
|
187
218
|
await fixture(html`
|
|
@@ -196,7 +227,8 @@ describe('lion-tooltip', () => {
|
|
|
196
227
|
expect(el._arrowNode).to.be.displayed;
|
|
197
228
|
});
|
|
198
229
|
|
|
199
|
-
|
|
230
|
+
// TODO: promise for dynamic import popper does not resolve?
|
|
231
|
+
it.skip('makes sure positioning of the arrow is correct', async () => {
|
|
200
232
|
const el = /** @type {LionTooltip} */ (
|
|
201
233
|
await fixture(html`
|
|
202
234
|
<lion-tooltip
|
|
@@ -217,8 +249,9 @@ describe('lion-tooltip', () => {
|
|
|
217
249
|
);
|
|
218
250
|
|
|
219
251
|
el.opened = true;
|
|
220
|
-
|
|
252
|
+
clock.tick(300);
|
|
221
253
|
await el.repositionComplete;
|
|
254
|
+
|
|
222
255
|
// Pretty sure we use flex for this now so that's why it fails
|
|
223
256
|
/* expect(getComputedStyle(el.__arrowElement).getPropertyValue('top')).to.equal(
|
|
224
257
|
'11px',
|
|
@@ -229,8 +262,7 @@ describe('lion-tooltip', () => {
|
|
|
229
262
|
getComputedStyle(/** @type {HTMLElement} */ (el._arrowNode)).getPropertyValue('left'),
|
|
230
263
|
).to.equal(
|
|
231
264
|
'-10px',
|
|
232
|
-
`
|
|
233
|
-
arrow height is 8px so this offset should be taken into account to align the arrow properly,
|
|
265
|
+
`arrow height is 8px so this offset should be taken into account to align the arrow properly,
|
|
234
266
|
as well as half the difference between width and height ((12 - 8) / 2 = 2)
|
|
235
267
|
`,
|
|
236
268
|
);
|