@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
|
@@ -27,9 +27,8 @@ export const OverlayMixinImplementation = superclass =>
|
|
|
27
27
|
constructor() {
|
|
28
28
|
super();
|
|
29
29
|
this.opened = false;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/** @type {OverlayConfig} */
|
|
30
|
+
|
|
31
|
+
/** @type {Partial<OverlayConfig>} */
|
|
33
32
|
this.config = {};
|
|
34
33
|
|
|
35
34
|
/** @type {EventListener} */
|
|
@@ -91,10 +90,10 @@ export const OverlayMixinImplementation = superclass =>
|
|
|
91
90
|
...this.config, // user provided (e.g. in template)
|
|
92
91
|
popperConfig: {
|
|
93
92
|
...(overlayConfig.popperConfig || {}),
|
|
94
|
-
...(this.config
|
|
93
|
+
...(this.config?.popperConfig || {}),
|
|
95
94
|
modifiers: [
|
|
96
95
|
...(overlayConfig.popperConfig?.modifiers || []),
|
|
97
|
-
...(this.config
|
|
96
|
+
...(this.config?.popperConfig?.modifiers || []),
|
|
98
97
|
],
|
|
99
98
|
},
|
|
100
99
|
});
|
|
@@ -163,16 +162,13 @@ export const OverlayMixinImplementation = superclass =>
|
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
this.__needsSetup = false;
|
|
175
|
-
});
|
|
165
|
+
/**
|
|
166
|
+
* @param {import('lit-element').PropertyValues } changedProperties
|
|
167
|
+
*/
|
|
168
|
+
firstUpdated(changedProperties) {
|
|
169
|
+
super.firstUpdated(changedProperties);
|
|
170
|
+
|
|
171
|
+
this._setupOverlayCtrl();
|
|
176
172
|
}
|
|
177
173
|
|
|
178
174
|
disconnectedCallback() {
|
|
@@ -197,9 +193,12 @@ export const OverlayMixinImplementation = superclass =>
|
|
|
197
193
|
}
|
|
198
194
|
|
|
199
195
|
get _overlayBackdropNode() {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
if (!this.__cachedOverlayBackdropNode) {
|
|
197
|
+
this.__cachedOverlayBackdropNode = /** @type {HTMLElement | undefined} */ (
|
|
198
|
+
Array.from(this.children).find(child => child.slot === 'backdrop')
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
return this.__cachedOverlayBackdropNode;
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
get _overlayContentNode() {
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* @typedef {import('./OverlayController.js').OverlayController} OverlayController
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { setSiblingsInert, unsetSiblingsInert } from './utils/inert-siblings.js';
|
|
6
|
+
import { overlayDocumentStyle } from './overlayDocumentStyle.js';
|
|
8
7
|
|
|
9
8
|
// Export this as protected var, so that we can easily mock it in tests
|
|
10
9
|
// TODO: combine with browserDetection of core?
|
|
@@ -23,34 +22,14 @@ export const _browserDetection = {
|
|
|
23
22
|
* `OverlaysManager` which manages overlays which are rendered into the body
|
|
24
23
|
*/
|
|
25
24
|
export class OverlaysManager {
|
|
26
|
-
static __createGlobalRootNode() {
|
|
27
|
-
const rootNode = document.createElement('div');
|
|
28
|
-
rootNode.classList.add('global-overlays');
|
|
29
|
-
document.body.appendChild(rootNode);
|
|
30
|
-
return rootNode;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
25
|
static __createGlobalStyleNode() {
|
|
34
26
|
const styleTag = document.createElement('style');
|
|
35
|
-
styleTag.setAttribute('data-
|
|
36
|
-
styleTag.textContent = /** @type {CSSResult} */ (
|
|
27
|
+
styleTag.setAttribute('data-overlays', '');
|
|
28
|
+
styleTag.textContent = /** @type {CSSResult} */ (overlayDocumentStyle).cssText;
|
|
37
29
|
document.head.appendChild(styleTag);
|
|
38
30
|
return styleTag;
|
|
39
31
|
}
|
|
40
32
|
|
|
41
|
-
/**
|
|
42
|
-
* no setter as .list is intended to be read-only
|
|
43
|
-
* You can use .add or .remove to modify it
|
|
44
|
-
*/
|
|
45
|
-
// eslint-disable-next-line class-methods-use-this
|
|
46
|
-
get globalRootNode() {
|
|
47
|
-
if (!OverlaysManager.__globalRootNode) {
|
|
48
|
-
OverlaysManager.__globalRootNode = OverlaysManager.__createGlobalRootNode();
|
|
49
|
-
OverlaysManager.__globalStyleNode = OverlaysManager.__createGlobalStyleNode();
|
|
50
|
-
}
|
|
51
|
-
return OverlaysManager.__globalRootNode;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
33
|
/**
|
|
55
34
|
* no setter as .list is intended to be read-only
|
|
56
35
|
* You can use .add or .remove to modify it
|
|
@@ -85,6 +64,10 @@ export class OverlaysManager {
|
|
|
85
64
|
* @private
|
|
86
65
|
*/
|
|
87
66
|
this.__blockingMap = new WeakMap();
|
|
67
|
+
|
|
68
|
+
if (!OverlaysManager.__globalStyleNode) {
|
|
69
|
+
OverlaysManager.__globalStyleNode = OverlaysManager.__createGlobalStyleNode();
|
|
70
|
+
}
|
|
88
71
|
}
|
|
89
72
|
|
|
90
73
|
/**
|
|
@@ -108,6 +91,7 @@ export class OverlaysManager {
|
|
|
108
91
|
throw new Error('could not find controller to remove');
|
|
109
92
|
}
|
|
110
93
|
this.__list = this.list.filter(ctrl => ctrl !== ctrlToRemove);
|
|
94
|
+
this.__shownList = this.shownList.filter(ctrl => ctrl !== ctrlToRemove);
|
|
111
95
|
}
|
|
112
96
|
|
|
113
97
|
/**
|
|
@@ -147,13 +131,7 @@ export class OverlaysManager {
|
|
|
147
131
|
this.__shownList = [];
|
|
148
132
|
this.__siblingsInert = false;
|
|
149
133
|
|
|
150
|
-
|
|
151
|
-
if (rootNode) {
|
|
152
|
-
if (rootNode.parentElement) {
|
|
153
|
-
rootNode.parentElement.removeChild(rootNode);
|
|
154
|
-
}
|
|
155
|
-
OverlaysManager.__globalRootNode = undefined;
|
|
156
|
-
|
|
134
|
+
if (OverlaysManager.__globalStyleNode) {
|
|
157
135
|
document.head.removeChild(
|
|
158
136
|
/** @type {HTMLStyleElement} */ (OverlaysManager.__globalStyleNode),
|
|
159
137
|
);
|
|
@@ -180,9 +158,6 @@ export class OverlaysManager {
|
|
|
180
158
|
*/
|
|
181
159
|
informTrapsKeyboardFocusGotEnabled(placementMode) {
|
|
182
160
|
if (this.siblingsInert === false && placementMode === 'global') {
|
|
183
|
-
if (OverlaysManager.__globalRootNode) {
|
|
184
|
-
setSiblingsInert(this.globalRootNode);
|
|
185
|
-
}
|
|
186
161
|
this.__siblingsInert = true;
|
|
187
162
|
}
|
|
188
163
|
}
|
|
@@ -199,9 +174,6 @@ export class OverlaysManager {
|
|
|
199
174
|
next.enableTrapsKeyboardFocus();
|
|
200
175
|
}
|
|
201
176
|
} else if (this.siblingsInert === true) {
|
|
202
|
-
if (OverlaysManager.__globalRootNode) {
|
|
203
|
-
unsetSiblingsInert(this.globalRootNode);
|
|
204
|
-
}
|
|
205
177
|
this.__siblingsInert = false;
|
|
206
178
|
}
|
|
207
179
|
}
|
|
@@ -212,27 +184,32 @@ export class OverlaysManager {
|
|
|
212
184
|
requestToPreventScroll() {
|
|
213
185
|
const { isIOS, isMacSafari } = _browserDetection;
|
|
214
186
|
// no check as classList will dedupe it anyways
|
|
215
|
-
document.body.classList.add('
|
|
187
|
+
document.body.classList.add('overlays-scroll-lock');
|
|
216
188
|
if (isIOS || isMacSafari) {
|
|
217
189
|
// iOS and safar for mac have issues with overlays with input fields. This is fixed by applying
|
|
218
190
|
// position: fixed to the body. As a side effect, this will scroll the body to the top.
|
|
219
|
-
document.body.classList.add('
|
|
191
|
+
document.body.classList.add('overlays-scroll-lock-ios-fix');
|
|
220
192
|
}
|
|
221
193
|
if (isIOS) {
|
|
222
|
-
document.documentElement.classList.add('
|
|
194
|
+
document.documentElement.classList.add('overlays-scroll-lock-ios-fix');
|
|
223
195
|
}
|
|
224
196
|
}
|
|
225
197
|
|
|
226
198
|
requestToEnableScroll() {
|
|
199
|
+
const hasOpenSiblingThatPreventsScroll = this.shownList.some(
|
|
200
|
+
ctrl => ctrl.preventsScroll === true,
|
|
201
|
+
);
|
|
202
|
+
if (hasOpenSiblingThatPreventsScroll) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
227
206
|
const { isIOS, isMacSafari } = _browserDetection;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
document.documentElement.classList.remove('global-overlays-scroll-lock-ios-fix');
|
|
235
|
-
}
|
|
207
|
+
document.body.classList.remove('overlays-scroll-lock');
|
|
208
|
+
if (isIOS || isMacSafari) {
|
|
209
|
+
document.body.classList.remove('overlays-scroll-lock-ios-fix');
|
|
210
|
+
}
|
|
211
|
+
if (isIOS) {
|
|
212
|
+
document.documentElement.classList.remove('overlays-scroll-lock-ios-fix');
|
|
236
213
|
}
|
|
237
214
|
}
|
|
238
215
|
|
|
@@ -242,8 +219,7 @@ export class OverlaysManager {
|
|
|
242
219
|
*/
|
|
243
220
|
requestToShowOnly(blockingCtrl) {
|
|
244
221
|
const controllersToHide = this.shownList.filter(ctrl => ctrl !== blockingCtrl);
|
|
245
|
-
|
|
246
|
-
controllersToHide.map(ctrl => ctrl.hide());
|
|
222
|
+
controllersToHide.forEach(ctrl => ctrl.hide());
|
|
247
223
|
this.__blockingMap.set(blockingCtrl, controllersToHide);
|
|
248
224
|
}
|
|
249
225
|
|
|
@@ -255,11 +231,10 @@ export class OverlaysManager {
|
|
|
255
231
|
const controllersWhichGotHidden = /** @type {OverlayController[]} */ (
|
|
256
232
|
this.__blockingMap.get(blockingCtrl)
|
|
257
233
|
);
|
|
258
|
-
controllersWhichGotHidden.
|
|
234
|
+
controllersWhichGotHidden.forEach(ctrl => ctrl.show());
|
|
259
235
|
}
|
|
260
236
|
}
|
|
261
237
|
}
|
|
262
|
-
|
|
263
|
-
OverlaysManager.__globalRootNode = undefined;
|
|
238
|
+
|
|
264
239
|
/** @type {HTMLStyleElement | undefined} */
|
|
265
240
|
OverlaysManager.__globalStyleNode = undefined;
|
package/components/overlays/src/configurations/visibility-trigger-partials/withClickInteraction.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('@lion/ui/types/overlays.js').OverlayConfig} OverlayConfig
|
|
3
|
+
* @typedef {import('@lion/ui/overlays.js').OverlayController} OverlayController
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Use for popovers/dropdowns, (modal) dialogs etc...
|
|
8
|
+
* @returns {Partial<OverlayConfig>}
|
|
9
|
+
*/
|
|
10
|
+
export function withClickInteraction() {
|
|
11
|
+
return {
|
|
12
|
+
visibilityTriggerFunction: (
|
|
13
|
+
/** @type {{ controller: OverlayController }} */ { controller },
|
|
14
|
+
) => {
|
|
15
|
+
function handleOpenClosed() {
|
|
16
|
+
if (controller._hasDisabledInvoker()) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
controller.toggle();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
init: () => {
|
|
24
|
+
controller.invokerNode?.addEventListener('click', handleOpenClosed);
|
|
25
|
+
},
|
|
26
|
+
teardown: () => {
|
|
27
|
+
controller.invokerNode?.removeEventListener('click', handleOpenClosed);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
package/components/overlays/src/configurations/visibility-trigger-partials/withHoverInteraction.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('@lion/ui/types/overlays.js').OverlayConfig} OverlayConfig
|
|
3
|
+
* @typedef {import('@lion/ui/overlays.js').OverlayController} OverlayController
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// N.B. Below logic is tested in LionTooltip
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Use for tooltips and [flyout menus](https://www.w3.org/WAI/tutorials/menus/flyout/).
|
|
10
|
+
* Note that it handles both mouse hover and focus interaction.
|
|
11
|
+
* Provide delayIn and delayOut when the content needs a small delay before being showed
|
|
12
|
+
* @param {{ delayIn?: number, delayOut?: number }} options
|
|
13
|
+
* @returns {Partial<OverlayConfig>}
|
|
14
|
+
*/
|
|
15
|
+
export function withHoverInteraction({ delayIn = 0, delayOut = 300 }) {
|
|
16
|
+
return {
|
|
17
|
+
visibilityTriggerFunction: (
|
|
18
|
+
/** @type {{ controller: OverlayController }} */ { controller },
|
|
19
|
+
) => {
|
|
20
|
+
let isFocused = false;
|
|
21
|
+
let isHovered = false;
|
|
22
|
+
/** @type {NodeJS.Timeout} */
|
|
23
|
+
let delayTimeout;
|
|
24
|
+
|
|
25
|
+
function resetActive() {
|
|
26
|
+
isFocused = false;
|
|
27
|
+
isHovered = false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {Event} event
|
|
32
|
+
*/
|
|
33
|
+
function handleOpenClosed(event) {
|
|
34
|
+
const { type } = event;
|
|
35
|
+
if (controller._hasDisabledInvoker()) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
clearTimeout(delayTimeout);
|
|
39
|
+
isFocused = type === 'focusout' ? false : isFocused || type === 'focusin';
|
|
40
|
+
isHovered = type === 'mouseleave' ? false : isHovered || type === 'mouseenter';
|
|
41
|
+
const shouldOpen = isFocused || isHovered;
|
|
42
|
+
|
|
43
|
+
if (shouldOpen) {
|
|
44
|
+
delayTimeout = setTimeout(() => {
|
|
45
|
+
controller.show();
|
|
46
|
+
}, delayIn);
|
|
47
|
+
} else {
|
|
48
|
+
delayTimeout = setTimeout(() => {
|
|
49
|
+
controller.hide();
|
|
50
|
+
}, delayOut);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
init: () => {
|
|
56
|
+
controller.addEventListener('hide', resetActive);
|
|
57
|
+
controller.contentNode?.addEventListener('mouseenter', handleOpenClosed);
|
|
58
|
+
controller.contentNode?.addEventListener('mouseleave', handleOpenClosed);
|
|
59
|
+
controller.invokerNode?.addEventListener('mouseenter', handleOpenClosed);
|
|
60
|
+
controller.invokerNode?.addEventListener('mouseleave', handleOpenClosed);
|
|
61
|
+
controller.invokerNode?.addEventListener('focusin', handleOpenClosed);
|
|
62
|
+
controller.invokerNode?.addEventListener('focusout', handleOpenClosed);
|
|
63
|
+
},
|
|
64
|
+
teardown: () => {
|
|
65
|
+
controller.removeEventListener('hide', resetActive);
|
|
66
|
+
controller.contentNode?.removeEventListener('mouseenter', handleOpenClosed);
|
|
67
|
+
controller.contentNode?.removeEventListener('mouseleave', handleOpenClosed);
|
|
68
|
+
controller.invokerNode?.removeEventListener('mouseenter', handleOpenClosed);
|
|
69
|
+
controller.invokerNode?.removeEventListener('mouseleave', handleOpenClosed);
|
|
70
|
+
controller.invokerNode?.removeEventListener('focusin', handleOpenClosed);
|
|
71
|
+
controller.invokerNode?.removeEventListener('focusout', handleOpenClosed);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { withClickInteraction } from './visibility-trigger-partials/withClickInteraction.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @typedef {import('../../types/OverlayConfig.js').OverlayConfig} OverlayConfig
|
|
3
5
|
*/
|
|
@@ -13,4 +15,5 @@ export const withBottomSheetConfig = () =>
|
|
|
13
15
|
placement: 'bottom',
|
|
14
16
|
},
|
|
15
17
|
handlesAccessibility: true,
|
|
18
|
+
...withClickInteraction(),
|
|
16
19
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { withClickInteraction } from './visibility-trigger-partials/withClickInteraction.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @typedef {import('../../types/OverlayConfig.js').OverlayConfig} OverlayConfig
|
|
3
5
|
*/
|
|
@@ -19,4 +21,5 @@ export const withDropdownConfig = () =>
|
|
|
19
21
|
],
|
|
20
22
|
},
|
|
21
23
|
handlesAccessibility: true,
|
|
24
|
+
...withClickInteraction(),
|
|
22
25
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { withClickInteraction } from './visibility-trigger-partials/withClickInteraction.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @typedef {import('../../types/OverlayConfig.js').OverlayConfig} OverlayConfig
|
|
3
5
|
*/
|
|
@@ -13,4 +15,5 @@ export const withModalDialogConfig = () =>
|
|
|
13
15
|
trapsKeyboardFocus: true,
|
|
14
16
|
hidesOnEsc: true,
|
|
15
17
|
handlesAccessibility: true,
|
|
18
|
+
...withClickInteraction(),
|
|
16
19
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { withHoverInteraction } from './visibility-trigger-partials/withHoverInteraction.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import('@lion/ui/types/overlays.js').OverlayConfig} OverlayConfig
|
|
5
|
+
* @typedef {import('@lion/ui/overlays.js').OverlayController} OverlayController
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {{invokerRelation?: 'description'| 'label', delayIn?: number, delayOut?: number }} options
|
|
11
|
+
*/
|
|
12
|
+
export const withTooltipConfig = ({
|
|
13
|
+
invokerRelation = 'description',
|
|
14
|
+
delayIn = 300,
|
|
15
|
+
delayOut = 300,
|
|
16
|
+
} = {}) =>
|
|
17
|
+
/** @type {OverlayConfig} */ ({
|
|
18
|
+
placementMode: 'local',
|
|
19
|
+
elementToFocusAfterHide: undefined,
|
|
20
|
+
hidesOnEsc: true,
|
|
21
|
+
hidesOnOutsideEsc: true,
|
|
22
|
+
handlesAccessibility: true,
|
|
23
|
+
isTooltip: true,
|
|
24
|
+
invokerRelation,
|
|
25
|
+
popperConfig: {
|
|
26
|
+
strategy: 'absolute',
|
|
27
|
+
},
|
|
28
|
+
...withHoverInteraction({ delayIn, delayOut }),
|
|
29
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export const overlayDocumentStyle = css`
|
|
4
|
+
body > *[inert] {
|
|
5
|
+
-webkit-user-select: none;
|
|
6
|
+
-moz-user-select: none;
|
|
7
|
+
-ms-user-select: none;
|
|
8
|
+
user-select: none;
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
body.overlays-scroll-lock {
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
body.overlays-scroll-lock-ios-fix {
|
|
17
|
+
position: fixed;
|
|
18
|
+
width: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
html.overlays-scroll-lock-ios-fix {
|
|
22
|
+
height: 100vh;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export const overlayShadowDomStyle = css`
|
|
4
|
+
.overlays {
|
|
5
|
+
position: fixed;
|
|
6
|
+
z-index: 200;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.overlays__overlay-container {
|
|
10
|
+
display: flex;
|
|
11
|
+
position: fixed;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
pointer-events: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.overlays__overlay-container::backdrop {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.overlays__overlay-container--top-left {
|
|
24
|
+
justify-content: flex-start;
|
|
25
|
+
align-items: flex-start;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.overlays__overlay-container--top {
|
|
29
|
+
justify-content: center;
|
|
30
|
+
align-items: flex-start;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.overlays__overlay-container--top-right {
|
|
34
|
+
justify-content: flex-end;
|
|
35
|
+
align-items: flex-start;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.overlays__overlay-container--right {
|
|
39
|
+
justify-content: flex-end;
|
|
40
|
+
align-items: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.overlays__overlay-container--bottom-left {
|
|
44
|
+
justify-content: flex-start;
|
|
45
|
+
align-items: flex-end;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.overlays__overlay-container--bottom {
|
|
49
|
+
justify-content: center;
|
|
50
|
+
align-items: flex-end;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.overlays__overlay-container--bottom-right {
|
|
54
|
+
justify-content: flex-end;
|
|
55
|
+
align-items: flex-end;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.overlays__overlay-container--left {
|
|
59
|
+
justify-content: flex-start;
|
|
60
|
+
align-items: center;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.overlays__overlay-container--center {
|
|
64
|
+
justify-content: center;
|
|
65
|
+
align-items: center;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.overlays__overlay--bottom-sheet {
|
|
69
|
+
width: 100%;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
::slotted(.overlays__overlay),
|
|
73
|
+
.overlays__overlay {
|
|
74
|
+
pointer-events: auto;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.overlays__backdrop {
|
|
78
|
+
content: '';
|
|
79
|
+
position: fixed;
|
|
80
|
+
top: 0;
|
|
81
|
+
left: 0;
|
|
82
|
+
width: 100%;
|
|
83
|
+
height: 100%;
|
|
84
|
+
z-index: -1;
|
|
85
|
+
background-color: #333333;
|
|
86
|
+
display: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.overlays__backdrop--visible {
|
|
90
|
+
display: block;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.overlays__backdrop--animation-in {
|
|
94
|
+
animation: overlays-backdrop-fade-in 300ms;
|
|
95
|
+
opacity: 0.3;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.overlays__backdrop--animation-out {
|
|
99
|
+
animation: overlays-backdrop-fade-out 300ms;
|
|
100
|
+
opacity: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@keyframes overlays-backdrop-fade-in {
|
|
104
|
+
from {
|
|
105
|
+
opacity: 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@keyframes overlays-backdrop-fade-out {
|
|
110
|
+
from {
|
|
111
|
+
opacity: 0.3;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@media screen and (prefers-reduced-motion: reduce) {
|
|
116
|
+
.overlays .overlays__backdrop--animation-in {
|
|
117
|
+
animation: overlays-backdrop-fade-in 1ms;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.overlays .overlays__backdrop--animation-out {
|
|
121
|
+
animation: overlays-backdrop-fade-out 1ms;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
dialog[data-overlay-outer-wrapper] {
|
|
126
|
+
background-image: none;
|
|
127
|
+
border-style: none;
|
|
128
|
+
padding: 0px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* We don't want to use pseudo el ::backdrop.
|
|
133
|
+
* We have our own, that creates more flexibility wrt scrolling etc.
|
|
134
|
+
*/
|
|
135
|
+
dialog[data-overlay-outer-wrapper]::backdrop {
|
|
136
|
+
display: none;
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { singletonManager } from 'singleton-manager';
|
|
2
2
|
import { OverlaysManager } from './OverlaysManager.js';
|
|
3
3
|
|
|
4
|
-
export const overlays =
|
|
4
|
+
export const overlays =
|
|
5
|
+
/** @type {OverlaysManager} */
|
|
6
|
+
(singletonManager.get('@lion/ui::overlays::0.x')) || new OverlaysManager();
|