@lion/ui 0.0.4 → 0.0.6
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/calendar/src/LionCalendar.js +10 -4
- package/components/combobox/src/LionCombobox.js +6 -4
- package/components/core/src/DisabledMixin.js +6 -4
- package/components/core/src/DisabledWithTabIndexMixin.js +6 -4
- package/components/core/src/SlotMixin.js +2 -1
- package/components/core/test/SlotMixin.test.js +11 -0
- package/components/core/types/SlotMixinTypes.ts +1 -1
- package/components/form-core/src/FormatMixin.js +10 -8
- package/components/form-core/src/InteractionStateMixin.js +8 -6
- package/components/form-core/src/choice-group/ChoiceInputMixin.js +6 -4
- package/components/form-core/src/utils/SyncUpdatableMixin.js +9 -4
- package/components/form-core/test/utils/SyncUpdatableMixin.test.js +6 -4
- package/components/form-core/test-suites/ValidateMixin.suite.js +1 -1
- package/components/form-core/test-suites/form-group/FormGroupMixin.suite.js +2 -2
- package/components/input/src/LionInput.js +6 -4
- package/components/input-datepicker/src/LionInputDatepicker.js +6 -4
- package/components/input-tel/src/LionInputTel.js +7 -13
- package/components/input-tel/src/PhoneUtilManager.js +9 -5
- package/components/input-tel/src/formatters.js +8 -10
- package/components/input-tel/src/parsers.js +3 -4
- package/components/input-tel/src/preprocessors.js +2 -4
- package/components/input-tel/src/validators.js +4 -6
- package/components/input-tel/test/validators.test.js +8 -5
- package/components/input-tel-dropdown/src/LionInputTelDropdown.js +14 -8
- package/components/listbox/src/LionOption.js +6 -4
- package/components/overlays/src/OverlayMixin.js +6 -5
- package/components/overlays/src/OverlaysManager.js +21 -4
- package/components/overlays/src/globalOverlaysStyle.js +10 -0
- package/components/overlays/test/OverlaysManager.test.js +76 -0
- package/components/overlays/test-suites/OverlayMixin.suite.js +20 -14
- package/components/select-rich/src/LionSelectRich.js +6 -4
- package/components/switch/src/LionSwitchButton.js +6 -7
- package/custom-elements.json +568 -159
- package/dist-types/components/accordion/src/LionAccordion.d.ts +1 -1
- package/dist-types/components/button/src/LionButton.d.ts +1 -1
- package/dist-types/components/calendar/src/LionCalendar.d.ts +6 -4
- package/dist-types/components/calendar/src/LionCalendar.d.ts.map +1 -1
- package/dist-types/components/checkbox-group/src/LionCheckboxGroup.d.ts +1 -1
- package/dist-types/components/checkbox-group/src/LionCheckboxIndeterminate.d.ts +0 -4
- package/dist-types/components/checkbox-group/src/LionCheckboxIndeterminate.d.ts.map +1 -1
- package/dist-types/components/collapsible/src/LionCollapsible.d.ts +1 -1
- package/dist-types/components/combobox/src/LionCombobox.d.ts +5 -3
- package/dist-types/components/combobox/src/LionCombobox.d.ts.map +1 -1
- package/dist-types/components/core/src/DisabledMixin.d.ts.map +1 -1
- package/dist-types/components/core/src/DisabledWithTabIndexMixin.d.ts.map +1 -1
- package/dist-types/components/core/src/SlotMixin.d.ts +1 -1
- package/dist-types/components/core/src/SlotMixin.d.ts.map +1 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts +1 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts.map +1 -1
- package/dist-types/components/dialog/src/LionDialog.d.ts +1 -1
- package/dist-types/components/fieldset/src/LionFieldset.d.ts +1 -1
- package/dist-types/components/form-core/src/FormatMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/InteractionStateMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/LionField.d.ts +1 -1
- package/dist-types/components/form-core/src/choice-group/ChoiceInputMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/utils/SyncUpdatableMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/validate/LionValidationFeedback.d.ts +1 -1
- package/dist-types/components/form-core/test-suites/FormRegistrationMixins.suite.d.ts +1 -1
- package/dist-types/components/form-integrations/test/helpers/umbrella-form.d.ts +1 -1
- package/dist-types/components/helpers/src/SbActionLogger.d.ts +1 -1
- package/dist-types/components/helpers/src/SbLocaleSwitcher.d.ts +1 -1
- package/dist-types/components/icon/src/LionIcon.d.ts +1 -1
- package/dist-types/components/input/src/LionInput.d.ts +5 -3
- package/dist-types/components/input/src/LionInput.d.ts.map +1 -1
- package/dist-types/components/input-datepicker/src/LionCalendarOverlayFrame.d.ts +1 -1
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts +0 -5
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/LionInputTel.d.ts +3 -22
- package/dist-types/components/input-tel/src/LionInputTel.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/PhoneUtilManager.d.ts +8 -4
- package/dist-types/components/input-tel/src/PhoneUtilManager.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/formatters.d.ts +0 -2
- package/dist-types/components/input-tel/src/formatters.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/parsers.d.ts +0 -2
- package/dist-types/components/input-tel/src/parsers.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/preprocessors.d.ts +0 -2
- package/dist-types/components/input-tel/src/preprocessors.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/validators.d.ts +0 -1
- package/dist-types/components/input-tel/src/validators.d.ts.map +1 -1
- package/dist-types/components/input-tel/test/validators.test.d.ts +1 -1
- package/dist-types/components/input-tel/test/validators.test.d.ts.map +1 -1
- package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts +7 -9
- package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts.map +1 -1
- package/dist-types/components/listbox/src/LionListbox.d.ts +1 -1
- package/dist-types/components/listbox/src/LionOption.d.ts +6 -4
- package/dist-types/components/listbox/src/LionOption.d.ts.map +1 -1
- package/dist-types/components/listbox/src/LionOptions.d.ts +1 -1
- package/dist-types/components/overlays/src/OverlayMixin.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlaysManager.d.ts +4 -0
- package/dist-types/components/overlays/src/OverlaysManager.d.ts.map +1 -1
- package/dist-types/components/overlays/src/globalOverlaysStyle.d.ts.map +1 -1
- package/dist-types/components/overlays/test/OverlaysManager.test.d.ts.map +1 -1
- package/dist-types/components/overlays/test-suites/OverlayMixin.suite.d.ts.map +1 -1
- package/dist-types/components/pagination/src/LionPagination.d.ts +1 -1
- package/dist-types/components/progress-indicator/src/LionProgressIndicator.d.ts +1 -1
- package/dist-types/components/radio-group/src/LionRadioGroup.d.ts +1 -1
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts +5 -3
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts.map +1 -1
- package/dist-types/components/steps/src/LionStep.d.ts +1 -1
- package/dist-types/components/steps/src/LionSteps.d.ts +1 -1
- package/dist-types/components/switch/src/LionSwitchButton.d.ts +6 -7
- package/dist-types/components/switch/src/LionSwitchButton.d.ts.map +1 -1
- package/dist-types/components/tabs/src/LionTabs.d.ts +1 -1
- package/dist-types/components/tooltip/src/LionTooltip.d.ts +1 -1
- package/dist-types/exports/core.d.ts +0 -1
- package/dist-types/exports/core.d.ts.map +1 -1
- package/dist-types/exports/form-core.d.ts +0 -2
- package/dist-types/exports/form-core.d.ts.map +1 -1
- package/dist-types/exports/input-tel-dropdown.d.ts +0 -2
- package/dist-types/exports/input-tel-dropdown.d.ts.map +1 -1
- package/dist-types/exports/input-tel.d.ts +0 -1
- package/dist-types/exports/input-tel.d.ts.map +1 -1
- package/dist-types/exports/localize.d.ts +0 -3
- package/dist-types/exports/localize.d.ts.map +1 -1
- package/dist-types/exports/overlays.d.ts +0 -4
- package/dist-types/exports/overlays.d.ts.map +1 -1
- package/dist-types/exports/types/core.d.ts +2 -0
- package/dist-types/exports/types/core.d.ts.map +1 -0
- package/dist-types/exports/types/form-core.d.ts +3 -0
- package/dist-types/exports/types/form-core.d.ts.map +1 -0
- package/dist-types/exports/types/input-tel-dropdown.d.ts +3 -0
- package/dist-types/exports/types/input-tel-dropdown.d.ts.map +1 -0
- package/dist-types/exports/types/input-tel.d.ts +2 -0
- package/dist-types/exports/types/input-tel.d.ts.map +1 -0
- package/dist-types/exports/types/localize.d.ts +4 -0
- package/dist-types/exports/types/localize.d.ts.map +1 -0
- package/dist-types/exports/types/overlays.d.ts +5 -0
- package/dist-types/exports/types/overlays.d.ts.map +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/core.js +0 -2
- package/exports/form-core.js +0 -3
- package/exports/input-tel-dropdown.js +0 -3
- package/exports/input-tel.js +0 -2
- package/exports/localize.js +0 -4
- package/exports/overlays.js +0 -5
- package/exports/types/core.ts +1 -0
- package/exports/types/form-core.ts +2 -0
- package/exports/types/input-tel-dropdown.ts +2 -0
- package/exports/types/input-tel.ts +1 -0
- package/exports/types/localize.ts +3 -0
- package/exports/types/overlays.ts +4 -0
- package/package.json +6 -4
|
@@ -27,7 +27,6 @@ import { getFlagSymbol } from './getFlagSymbol.js';
|
|
|
27
27
|
* @typedef {import('../types/index.js').OnDropdownChangeEvent} OnDropdownChangeEvent
|
|
28
28
|
* @typedef {import('../types/index.js').DropdownRef} DropdownRef
|
|
29
29
|
* @typedef {import('../types/index.js').RegionMeta} RegionMeta
|
|
30
|
-
* @typedef {* & import('awesome-phonenumber').default} AwesomePhoneNumber
|
|
31
30
|
* @typedef {import('../../select-rich/src/LionSelectRich.js').LionSelectRich} LionSelectRich
|
|
32
31
|
* @typedef {import('../../overlays/src/OverlayController.js').OverlayController} OverlayController
|
|
33
32
|
* @typedef {TemplateDataForDropdownInputTel & {data: {regionMetaList:RegionMeta[]}}} TemplateDataForIntlInputTel
|
|
@@ -178,9 +177,7 @@ export class LionInputTelDropdown extends LionInputTel {
|
|
|
178
177
|
|
|
179
178
|
return {
|
|
180
179
|
template: templates.dropdown(this._templateDataDropdown),
|
|
181
|
-
afterRender:
|
|
182
|
-
this.__syncRegionWithDropdown();
|
|
183
|
-
},
|
|
180
|
+
afterRender: this.__syncRegionWithDropdown,
|
|
184
181
|
};
|
|
185
182
|
},
|
|
186
183
|
};
|
|
@@ -205,8 +202,6 @@ export class LionInputTelDropdown extends LionInputTel {
|
|
|
205
202
|
_onPhoneNumberUtilReady() {
|
|
206
203
|
super._onPhoneNumberUtilReady();
|
|
207
204
|
this.__createRegionMeta();
|
|
208
|
-
// render dropdown (trigger render of prefix slot via SlotMixin)
|
|
209
|
-
this.requestUpdate();
|
|
210
205
|
}
|
|
211
206
|
|
|
212
207
|
/**
|
|
@@ -234,19 +229,27 @@ export class LionInputTelDropdown extends LionInputTel {
|
|
|
234
229
|
/**
|
|
235
230
|
* Contains everything needed for rendering region options:
|
|
236
231
|
* region code, country code, display name according to locale, display name
|
|
232
|
+
* @private
|
|
237
233
|
* @type {RegionMeta[]}
|
|
238
234
|
*/
|
|
239
235
|
this.__regionMetaList = [];
|
|
240
236
|
|
|
241
237
|
/**
|
|
242
238
|
* A filtered `this.__regionMetaList`, containing all regions provided in `preferredRegions`
|
|
239
|
+
* @private
|
|
243
240
|
* @type {RegionMeta[]}
|
|
244
241
|
*/
|
|
245
242
|
this.__regionMetaListPreferred = [];
|
|
246
243
|
|
|
247
|
-
/**
|
|
244
|
+
/**
|
|
245
|
+
* @protected
|
|
246
|
+
* @type {EventListener}
|
|
247
|
+
*/
|
|
248
248
|
this._onDropdownValueChange = this._onDropdownValueChange.bind(this);
|
|
249
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* @private
|
|
251
|
+
* @type {EventListener}
|
|
252
|
+
*/
|
|
250
253
|
this.__syncRegionWithDropdown = this.__syncRegionWithDropdown.bind(this);
|
|
251
254
|
}
|
|
252
255
|
|
|
@@ -285,6 +288,9 @@ export class LionInputTelDropdown extends LionInputTel {
|
|
|
285
288
|
}
|
|
286
289
|
}
|
|
287
290
|
|
|
291
|
+
/**
|
|
292
|
+
* @protected
|
|
293
|
+
*/
|
|
288
294
|
_initModelValueBasedOnDropdown() {
|
|
289
295
|
if (!this._initialModelValue && !this.dirty && this._phoneUtil) {
|
|
290
296
|
const countryCode = this._phoneUtil.getCountryCodeForRegionCode(this.activeRegion);
|
|
@@ -78,11 +78,13 @@ export class LionOption extends DisabledMixin(
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* @param {string} name
|
|
82
|
-
* @param {unknown} oldValue
|
|
81
|
+
* @param {string} [name]
|
|
82
|
+
* @param {unknown} [oldValue]
|
|
83
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
84
|
+
* @returns {void}
|
|
83
85
|
*/
|
|
84
|
-
requestUpdate(name, oldValue) {
|
|
85
|
-
super.requestUpdate(name, oldValue);
|
|
86
|
+
requestUpdate(name, oldValue, options) {
|
|
87
|
+
super.requestUpdate(name, oldValue, options);
|
|
86
88
|
|
|
87
89
|
if (name === 'active' && this.active !== oldValue) {
|
|
88
90
|
this.dispatchEvent(new Event('active-changed', { bubbles: true }));
|
|
@@ -58,12 +58,13 @@ export const OverlayMixinImplementation = superclass =>
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* @
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
61
|
+
* @param {string} [name]
|
|
62
|
+
* @param {unknown} [oldValue]
|
|
63
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
64
|
+
* @returns {void}
|
|
64
65
|
*/
|
|
65
|
-
requestUpdate(name, oldValue) {
|
|
66
|
-
super.requestUpdate(name, oldValue);
|
|
66
|
+
requestUpdate(name, oldValue, options) {
|
|
67
|
+
super.requestUpdate(name, oldValue, options);
|
|
67
68
|
if (name === 'opened' && this.opened !== oldValue) {
|
|
68
69
|
this.dispatchEvent(new Event('opened-changed'));
|
|
69
70
|
}
|
|
@@ -6,7 +6,18 @@
|
|
|
6
6
|
import { globalOverlaysStyle } from './globalOverlaysStyle.js';
|
|
7
7
|
import { setSiblingsInert, unsetSiblingsInert } from './utils/inert-siblings.js';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// Export this as protected var, so that we can easily mock it in tests
|
|
10
|
+
// TODO: combine with browserDetection of core?
|
|
11
|
+
export const _browserDetection = {
|
|
12
|
+
isIOS: /iPhone|iPad|iPod/i.test(navigator.userAgent),
|
|
13
|
+
isMacSafari:
|
|
14
|
+
navigator.vendor &&
|
|
15
|
+
navigator.vendor.indexOf('Apple') > -1 &&
|
|
16
|
+
navigator.userAgent &&
|
|
17
|
+
navigator.userAgent.indexOf('CriOS') === -1 &&
|
|
18
|
+
navigator.userAgent.indexOf('FxiOS') === -1 &&
|
|
19
|
+
navigator.appVersion.indexOf('Mac') !== -1,
|
|
20
|
+
};
|
|
10
21
|
|
|
11
22
|
/**
|
|
12
23
|
* `OverlaysManager` which manages overlays which are rendered into the body
|
|
@@ -199,21 +210,27 @@ export class OverlaysManager {
|
|
|
199
210
|
|
|
200
211
|
// eslint-disable-next-line class-methods-use-this
|
|
201
212
|
requestToPreventScroll() {
|
|
213
|
+
const { isIOS, isMacSafari } = _browserDetection;
|
|
202
214
|
// no check as classList will dedupe it anyways
|
|
203
215
|
document.body.classList.add('global-overlays-scroll-lock');
|
|
204
|
-
if (isIOS) {
|
|
205
|
-
// iOS
|
|
216
|
+
if (isIOS || isMacSafari) {
|
|
217
|
+
// iOS and safar for mac have issues with overlays with input fields. This is fixed by applying
|
|
206
218
|
// position: fixed to the body. As a side effect, this will scroll the body to the top.
|
|
207
219
|
document.body.classList.add('global-overlays-scroll-lock-ios-fix');
|
|
220
|
+
}
|
|
221
|
+
if (isIOS) {
|
|
208
222
|
document.documentElement.classList.add('global-overlays-scroll-lock-ios-fix');
|
|
209
223
|
}
|
|
210
224
|
}
|
|
211
225
|
|
|
212
226
|
requestToEnableScroll() {
|
|
227
|
+
const { isIOS, isMacSafari } = _browserDetection;
|
|
213
228
|
if (!this.shownList.some(ctrl => ctrl.preventsScroll === true)) {
|
|
214
229
|
document.body.classList.remove('global-overlays-scroll-lock');
|
|
215
|
-
if (isIOS) {
|
|
230
|
+
if (isIOS || isMacSafari) {
|
|
216
231
|
document.body.classList.remove('global-overlays-scroll-lock-ios-fix');
|
|
232
|
+
}
|
|
233
|
+
if (isIOS) {
|
|
217
234
|
document.documentElement.classList.remove('global-overlays-scroll-lock-ios-fix');
|
|
218
235
|
}
|
|
219
236
|
}
|
|
@@ -126,4 +126,14 @@ export const globalOverlaysStyle = css`
|
|
|
126
126
|
html.global-overlays-scroll-lock-ios-fix {
|
|
127
127
|
height: 100vh;
|
|
128
128
|
}
|
|
129
|
+
|
|
130
|
+
@media screen and (prefers-reduced-motion: reduce) {
|
|
131
|
+
.global-overlays .global-overlays__backdrop--animation-in {
|
|
132
|
+
animation: global-overlays-backdrop-fade-in 1ms;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.global-overlays .global-overlays__backdrop--animation-out {
|
|
136
|
+
animation: global-overlays-backdrop-fade-out 1ms;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
129
139
|
`;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { expect, fixture } from '@open-wc/testing';
|
|
2
2
|
import { html } from 'lit/static-html.js';
|
|
3
3
|
import { OverlayController, OverlaysManager } from '@lion/ui/overlays.js';
|
|
4
|
+
import { _browserDetection } from '../src/OverlaysManager.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @typedef {import('../types/OverlayConfig.js').OverlayConfig} OverlayConfig
|
|
@@ -97,4 +98,79 @@ describe('OverlaysManager', () => {
|
|
|
97
98
|
await dialog2.hide();
|
|
98
99
|
expect(mngr.shownList).to.deep.equal([]);
|
|
99
100
|
});
|
|
101
|
+
|
|
102
|
+
describe('Browser/device edge cases', () => {
|
|
103
|
+
const isIOSOriginal = _browserDetection.isIOS;
|
|
104
|
+
const isMacSafariOriginal = _browserDetection.isMacSafari;
|
|
105
|
+
|
|
106
|
+
function mockIOS() {
|
|
107
|
+
_browserDetection.isIOS = true;
|
|
108
|
+
_browserDetection.isMacSafari = false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function mockMacSafari() {
|
|
112
|
+
// When we are iOS
|
|
113
|
+
_browserDetection.isIOS = false;
|
|
114
|
+
_browserDetection.isMacSafari = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
afterEach(() => {
|
|
118
|
+
// Restore original values
|
|
119
|
+
_browserDetection.isIOS = isIOSOriginal;
|
|
120
|
+
_browserDetection.isMacSafari = isMacSafariOriginal;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('When initialized with "preventsScroll: true"', () => {
|
|
124
|
+
it('adds class "global-overlays-scroll-lock-ios-fix" to body and html on iOS', async () => {
|
|
125
|
+
mockIOS();
|
|
126
|
+
const dialog = new OverlayController({ ...defaultOptions, preventsScroll: true }, mngr);
|
|
127
|
+
await dialog.show();
|
|
128
|
+
expect(Array.from(document.body.classList)).to.contain(
|
|
129
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
130
|
+
);
|
|
131
|
+
expect(Array.from(document.documentElement.classList)).to.contain(
|
|
132
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
133
|
+
);
|
|
134
|
+
await dialog.hide();
|
|
135
|
+
expect(Array.from(document.body.classList)).to.not.contain(
|
|
136
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
137
|
+
);
|
|
138
|
+
expect(Array.from(document.documentElement.classList)).to.not.contain(
|
|
139
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
// When we are not iOS nor MacSafari
|
|
143
|
+
_browserDetection.isIOS = false;
|
|
144
|
+
_browserDetection.isMacSafari = false;
|
|
145
|
+
|
|
146
|
+
const dialog2 = new OverlayController({ ...defaultOptions, preventsScroll: true }, mngr);
|
|
147
|
+
await dialog2.show();
|
|
148
|
+
expect(Array.from(document.body.classList)).to.not.contain(
|
|
149
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
150
|
+
);
|
|
151
|
+
expect(Array.from(document.documentElement.classList)).to.not.contain(
|
|
152
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('adds class "global-overlays-scroll-lock-ios-fix" to body on MacSafari', async () => {
|
|
157
|
+
mockMacSafari();
|
|
158
|
+
const dialog = new OverlayController({ ...defaultOptions, preventsScroll: true }, mngr);
|
|
159
|
+
await dialog.show();
|
|
160
|
+
expect(Array.from(document.body.classList)).to.contain(
|
|
161
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
162
|
+
);
|
|
163
|
+
expect(Array.from(document.documentElement.classList)).to.not.contain(
|
|
164
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
165
|
+
);
|
|
166
|
+
await dialog.hide();
|
|
167
|
+
expect(Array.from(document.body.classList)).to.not.contain(
|
|
168
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
169
|
+
);
|
|
170
|
+
expect(Array.from(document.documentElement.classList)).to.not.contain(
|
|
171
|
+
'global-overlays-scroll-lock-ios-fix',
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
});
|
|
100
176
|
});
|
|
@@ -4,6 +4,7 @@ import sinon from 'sinon';
|
|
|
4
4
|
import { overlays, OverlayController } from '@lion/ui/overlays.js';
|
|
5
5
|
|
|
6
6
|
import '@lion/ui/define/lion-dialog.js';
|
|
7
|
+
import { _browserDetection } from '../src/OverlaysManager.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @typedef {import('../types/OverlayConfig.js').OverlayConfig} OverlayConfig
|
|
@@ -77,6 +78,7 @@ export function runOverlayMixinSuite({ tagString, tag, suffix = '' }) {
|
|
|
77
78
|
expect(el.opened).to.be.false;
|
|
78
79
|
});
|
|
79
80
|
|
|
81
|
+
// TODO: put this tests in OverlayController.test.js instead?
|
|
80
82
|
it('does not change the body size when opened', async () => {
|
|
81
83
|
const parentNode = document.createElement('div');
|
|
82
84
|
parentNode.setAttribute('style', 'height: 10000px; width: 10000px;');
|
|
@@ -91,24 +93,28 @@ export function runOverlayMixinSuite({ tagString, tag, suffix = '' }) {
|
|
|
91
93
|
{ parentNode },
|
|
92
94
|
)
|
|
93
95
|
);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
|
|
97
|
+
// For now, we skip this test for MacSafari, since the body.global-overlays-scroll-lock-ios-fix
|
|
98
|
+
// class results in a scrollbar when preventsScroll is true.
|
|
99
|
+
// However, fully functioning interacive elements (input fields) in the dialog are more important
|
|
100
|
+
if (_browserDetection.isMacSafari && elWithBigParent._overlayCtrl.preventsScroll) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const elWithBigParentOffsetParent = /** @type {HTMLElement} */ (
|
|
105
|
+
elWithBigParent?.offsetParent
|
|
96
106
|
);
|
|
107
|
+
|
|
108
|
+
const { offsetWidth, offsetHeight } = elWithBigParentOffsetParent;
|
|
109
|
+
|
|
97
110
|
await elWithBigParent._overlayCtrl.show();
|
|
111
|
+
|
|
98
112
|
expect(elWithBigParent.opened).to.be.true;
|
|
99
|
-
expect(
|
|
100
|
-
|
|
101
|
-
);
|
|
102
|
-
expect(/** @type {HTMLElement} */ (elWithBigParent?.offsetParent).offsetHeight).to.equal(
|
|
103
|
-
offsetHeight,
|
|
104
|
-
);
|
|
113
|
+
expect(elWithBigParentOffsetParent.offsetWidth).to.equal(offsetWidth);
|
|
114
|
+
expect(elWithBigParentOffsetParent.offsetHeight).to.equal(offsetHeight);
|
|
105
115
|
await elWithBigParent._overlayCtrl.hide();
|
|
106
|
-
expect(
|
|
107
|
-
|
|
108
|
-
);
|
|
109
|
-
expect(/** @type {HTMLElement} */ (elWithBigParent?.offsetParent).offsetHeight).to.equal(
|
|
110
|
-
offsetHeight,
|
|
111
|
-
);
|
|
116
|
+
expect(elWithBigParentOffsetParent.offsetWidth).to.equal(offsetWidth);
|
|
117
|
+
expect(elWithBigParentOffsetParent.offsetHeight).to.equal(offsetHeight);
|
|
112
118
|
});
|
|
113
119
|
|
|
114
120
|
it('should respond to initially and dynamically setting the config', async () => {
|
|
@@ -156,11 +156,13 @@ export class LionSelectRich extends SlotMixin(ScopedElementsMixin(OverlayMixin(L
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
|
-
* @param {string} name
|
|
160
|
-
* @param {unknown} oldValue
|
|
159
|
+
* @param {string} [name]
|
|
160
|
+
* @param {unknown} [oldValue]
|
|
161
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
162
|
+
* @returns {void}
|
|
161
163
|
*/
|
|
162
|
-
requestUpdate(name, oldValue) {
|
|
163
|
-
super.requestUpdate(name, oldValue);
|
|
164
|
+
requestUpdate(name, oldValue, options) {
|
|
165
|
+
super.requestUpdate(name, oldValue, options);
|
|
164
166
|
if (name === 'interactionMode') {
|
|
165
167
|
if (this.interactionMode === 'auto') {
|
|
166
168
|
this.interactionMode = detectInteractionMode();
|
|
@@ -151,14 +151,13 @@ export class LionSwitchButton extends DisabledWithTabIndexMixin(LitElement) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* @param {
|
|
157
|
-
* @
|
|
158
|
-
* @override
|
|
154
|
+
* @param {string} [name]
|
|
155
|
+
* @param {unknown} [oldValue]
|
|
156
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
157
|
+
* @returns {void}
|
|
159
158
|
*/
|
|
160
|
-
requestUpdate(name, oldValue) {
|
|
161
|
-
super.requestUpdate(name, oldValue);
|
|
159
|
+
requestUpdate(name, oldValue, options) {
|
|
160
|
+
super.requestUpdate(name, oldValue, options);
|
|
162
161
|
if (this.isConnected && name === 'checked' && this.checked !== oldValue && !this.disabled) {
|
|
163
162
|
this.__checkedStateChange();
|
|
164
163
|
}
|