@lion/ui 0.0.10 → 0.0.12
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/dialog/src/LionDialog.js +0 -28
- package/components/dialog/test/lion-dialog.test.js +10 -5
- package/components/input-datepicker/src/LionInputDatepicker.js +2 -4
- package/components/localize/src/singleton.js +1 -1
- package/components/overlays/src/OverlayController.js +73 -14
- 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/test/OverlayController.test.js +88 -7
- package/components/overlays/types/OverlayConfig.ts +6 -0
- package/components/select-rich/src/LionSelectRich.js +2 -0
- package/components/tooltip/src/LionTooltip.js +18 -91
- package/components/tooltip/test/lion-tooltip.test.js +50 -19
- package/custom-elements.json +307 -220
- 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/input-datepicker/src/LionInputDatepicker.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlayController.d.ts +11 -2
- package/dist-types/components/overlays/src/OverlayController.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/types/OverlayConfig.d.ts +5 -0
- package/dist-types/components/overlays/types/OverlayConfig.d.ts.map +1 -1
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts +32 -0
- package/dist-types/components/select-rich/src/LionSelectRich.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/overlays.d.ts +1 -0
- 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 +1 -1
- 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/validate.md +1 -1
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/configuration.md +2 -2
- package/docs/fundamentals/systems/overlays/overview.md +5 -5
- package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
- 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 +5 -5
- package/docs/guides/how-to/extend-a-native-input.md +2 -2
- 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/overlays.js +1 -0
- package/package.json +1 -1
|
@@ -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
|
*/
|
|
@@ -32,6 +32,10 @@ export class LionTooltip extends ArrowMixin(OverlayMixin(LitElement)) {
|
|
|
32
32
|
:host([hidden]) {
|
|
33
33
|
display: none;
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
::slotted([slot='content']) {
|
|
37
|
+
width: max-content;
|
|
38
|
+
}
|
|
35
39
|
`,
|
|
36
40
|
];
|
|
37
41
|
}
|
|
@@ -49,101 +53,24 @@ export class LionTooltip extends ArrowMixin(OverlayMixin(LitElement)) {
|
|
|
49
53
|
* @type {'label'|'description'}
|
|
50
54
|
*/
|
|
51
55
|
this.invokerRelation = 'description';
|
|
52
|
-
/** @protected */
|
|
53
|
-
this._mouseActive = false;
|
|
54
|
-
/** @protected */
|
|
55
|
-
this._keyActive = false;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/** @protected */
|
|
59
59
|
// eslint-disable-next-line class-methods-use-this
|
|
60
60
|
_defineOverlayConfig() {
|
|
61
|
+
const superCfg = super._defineOverlayConfig();
|
|
62
|
+
const tooltipCfg = withTooltipConfig({ invokerRelation: this.invokerRelation });
|
|
61
63
|
return /** @type {OverlayConfig} */ ({
|
|
62
|
-
...
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
...superCfg,
|
|
65
|
+
...tooltipCfg,
|
|
66
|
+
popperConfig: {
|
|
67
|
+
...(superCfg.popperConfig || {}),
|
|
68
|
+
...(tooltipCfg.popperConfig || {}),
|
|
69
|
+
modifiers: [
|
|
70
|
+
...(superCfg.popperConfig?.modifiers || []),
|
|
71
|
+
...(tooltipCfg.popperConfig?.modifiers || []),
|
|
72
|
+
],
|
|
73
|
+
},
|
|
70
74
|
});
|
|
71
75
|
}
|
|
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
76
|
}
|
|
@@ -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`
|
|
@@ -217,8 +248,9 @@ describe('lion-tooltip', () => {
|
|
|
217
248
|
);
|
|
218
249
|
|
|
219
250
|
el.opened = true;
|
|
220
|
-
|
|
251
|
+
clock.tick(300);
|
|
221
252
|
await el.repositionComplete;
|
|
253
|
+
|
|
222
254
|
// Pretty sure we use flex for this now so that's why it fails
|
|
223
255
|
/* expect(getComputedStyle(el.__arrowElement).getPropertyValue('top')).to.equal(
|
|
224
256
|
'11px',
|
|
@@ -229,8 +261,7 @@ describe('lion-tooltip', () => {
|
|
|
229
261
|
getComputedStyle(/** @type {HTMLElement} */ (el._arrowNode)).getPropertyValue('left'),
|
|
230
262
|
).to.equal(
|
|
231
263
|
'-10px',
|
|
232
|
-
`
|
|
233
|
-
arrow height is 8px so this offset should be taken into account to align the arrow properly,
|
|
264
|
+
`arrow height is 8px so this offset should be taken into account to align the arrow properly,
|
|
234
265
|
as well as half the difference between width and height ((12 - 8) / 2 = 2)
|
|
235
266
|
`,
|
|
236
267
|
);
|