change resolution algo, update eslint, lint and prettier commands

This commit is contained in:
Rene Haas
2022-10-01 02:31:32 +02:00
parent eb99eba55e
commit 64a0d873f4
117 changed files with 900 additions and 508 deletions
+17 -14
View File
@@ -8,7 +8,6 @@ import {
absoluteCoordinates,
offsetSize,
scrollLeft,
XY,
removeAttr,
removeElements,
equalBCRWH,
@@ -18,18 +17,20 @@ import {
createCache,
equalXY,
createEventListenerHub,
EventListener,
} from 'support';
} from '~/support';
import {
classNameEnvironment,
classNameEnvironmentFlexboxGlue,
classNameEnvironmentFlexboxGlueMax,
classNameViewportScrollbarHidden,
} from 'classnames';
import { Options, defaultOptions } from 'options';
import { DeepPartial } from 'typings';
import { Initialization } from 'initialization';
import { getPlugins, ScrollbarsHidingPluginInstance, scrollbarsHidingPluginName } from 'plugins';
} from '~/classnames';
import { defaultOptions } from '~/options';
import { getPlugins, scrollbarsHidingPluginName } from '~/plugins';
import type { XY, EventListener } from '~/support';
import type { Options } from '~/options';
import type { DeepPartial } from '~/typings';
import type { ScrollbarsHidingPluginInstance } from '~/plugins';
import type { Initialization } from '~/initialization';
type EnvironmentEventMap = {
_: [];
@@ -178,15 +179,17 @@ const createEnvironment = (): InternalEnvironment => {
_rtlScrollBehavior: getRtlScrollBehavior(envElm, envChildElm),
_flexboxGlue: getFlexboxGlue(envElm, envChildElm),
_addListener: (listener) => addEvent('_', listener),
_getDefaultInitialization: assignDeep<Initialization, Initialization>.bind(
0,
{} as Initialization,
staticDefaultInitialization
),
_getDefaultInitialization: (
assignDeep as typeof assignDeep<Initialization, Initialization>
).bind(0, {} as Initialization, staticDefaultInitialization),
_setDefaultInitialization(newInitializationStrategy) {
assignDeep(staticDefaultInitialization, newInitializationStrategy);
},
_getDefaultOptions: assignDeep<Options, Options>.bind(0, {} as Options, staticDefaultOptions),
_getDefaultOptions: (assignDeep as typeof assignDeep<Options, Options>).bind(
0,
{} as Options,
staticDefaultOptions
),
_setDefaultOptions(newDefaultOptions) {
assignDeep(staticDefaultOptions, newDefaultOptions);
},
@@ -1,10 +1,10 @@
import type { OverlayScrollbars } from 'overlayscrollbars';
import type { DeepPartial } from 'typings';
import type { Options } from 'options';
import type { OverlayScrollbars } from '~/overlayscrollbars';
import type { DeepPartial } from '~/typings';
import type { Options } from '~/options';
import type {
InitialEventListeners as GeneralInitialEventListeners,
EventListener as GeneralEventListener,
} from 'support/eventListeners';
} from '~/support/eventListeners';
export interface OnUpdatedEventListenerArgs {
updateHints: {
+7 -7
View File
@@ -1,20 +1,20 @@
import 'index.scss';
import '~/index.scss';
export { OverlayScrollbars } from 'overlayscrollbars';
export { ScrollbarsHidingPlugin, SizeObserverPlugin, ClickScrollPlugin } from 'plugins';
export { OverlayScrollbars } from '~/overlayscrollbars';
export { ScrollbarsHidingPlugin, SizeObserverPlugin, ClickScrollPlugin } from '~/plugins';
export type {
Options,
OverflowBehavior,
ScrollbarVisibilityBehavior,
ScrollbarAutoHideBehavior,
} from 'options';
} from '~/options';
export type {
EventListenerMap,
EventListener,
InitialEventListeners,
OnUpdatedEventListenerArgs,
} from 'eventListeners';
} from '~/eventListeners';
export type {
Initialization,
InitializationTarget,
@@ -22,5 +22,5 @@ export type {
InitializationTargetObject,
StaticInitializationElement,
DynamicInitializationElement,
} from 'initialization';
export type { Plugin, PluginInstance } from 'plugins';
} from '~/initialization';
export type { Plugin, PluginInstance } from '~/plugins';
@@ -1,6 +1,6 @@
import { isFunction, isHTMLElement, isNull, isUndefined } from 'support';
import { getEnvironment } from 'environment';
import type { DeepPartial } from 'typings';
import { isFunction, isHTMLElement, isNull, isUndefined } from '~/support';
import { getEnvironment } from '~/environment';
import type { DeepPartial } from '~/typings';
type StaticInitialization = HTMLElement | false | null;
type DynamicInitialization = HTMLElement | boolean | null;
+1 -1
View File
@@ -1,4 +1,4 @@
import { OverlayScrollbars } from 'overlayscrollbars';
import type { OverlayScrollbars } from '~/overlayscrollbars';
const targetInstanceMap: WeakMap<Element, OverlayScrollbars> = new WeakMap();
@@ -13,7 +13,7 @@ import {
push,
from,
runEachAndClear,
} from 'support';
} from '~/support';
type DOMContentObserverCallback = (contentChangedThroughEvent: boolean) => any;
@@ -1,3 +1,3 @@
export * from 'observers/domObserver';
export * from 'observers/sizeObserver';
export * from 'observers/trinsicObserver';
export * from '~/observers/domObserver';
export * from '~/observers/sizeObserver';
export * from '~/observers/trinsicObserver';
@@ -1,5 +1,4 @@
import {
CacheValues,
createCache,
createDOM,
scrollLeft,
@@ -17,15 +16,16 @@ import {
stopPropagation,
appendChildren,
directionIsRTL,
} from 'support';
import { getEnvironment } from 'environment';
} from '~/support';
import { getEnvironment } from '~/environment';
import {
classNameSizeObserver,
classNameSizeObserverAppear,
classNameSizeObserverListener,
} from 'classnames';
import { getPlugins, sizeObserverPluginName } from 'plugins';
import type { SizeObserverPluginInstance } from 'plugins';
} from '~/classnames';
import { getPlugins, sizeObserverPluginName } from '~/plugins';
import type { CacheValues } from '~/support';
import type { SizeObserverPluginInstance } from '~/plugins';
export interface SizeObserverOptions {
_direction?: boolean;
@@ -1,6 +1,4 @@
import {
WH,
CacheValues,
createDiv,
offsetSize,
runEachAndClear,
@@ -9,9 +7,10 @@ import {
push,
IntersectionObserverConstructor,
appendChildren,
} from 'support';
import { createSizeObserver } from 'observers/sizeObserver';
import { classNameTrinsicObserver } from 'classnames';
} from '~/support';
import { createSizeObserver } from '~/observers/sizeObserver';
import { classNameTrinsicObserver } from '~/classnames';
import type { WH, CacheValues } from '~/support';
export type TrinsicObserverCallback = (heightIntrinsic: CacheValues<boolean>) => any;
export type TrinsicObserver = [
+2 -2
View File
@@ -7,8 +7,8 @@ import {
hasOwnProperty,
isFunction,
isEmptyObject,
} from 'support';
import { DeepPartial, DeepReadonly } from 'typings';
} from '~/support';
import type { DeepPartial, DeepReadonly } from '~/typings';
const opsStringify = (value: any) =>
JSON.stringify(value, (_, val) => {
@@ -7,23 +7,23 @@ import {
isHTMLElement,
createEventListenerHub,
isPlainObject,
} from 'support';
import { getOptionsDiff } from 'options';
import { getEnvironment } from 'environment';
import { cancelInitialization } from 'initialization';
import { addInstance, getInstance, removeInstance } from 'instances';
import { createStructureSetup, createScrollbarsSetup } from 'setups';
import { getPlugins, addPlugin, optionsValidationPluginName, PluginInstance } from 'plugins';
import type { XY, TRBL } from 'support';
import type { Options, ReadonlyOptions } from 'options';
import type { Plugin, OptionsValidationPluginInstance } from 'plugins';
import type { InitializationTarget, Initialization } from 'initialization';
import type { DeepPartial, OverflowStyle } from 'typings';
import type { EventListenerMap, EventListener, InitialEventListeners } from 'eventListeners';
} from '~/support';
import { getOptionsDiff } from '~/options';
import { getEnvironment } from '~/environment';
import { cancelInitialization } from '~/initialization';
import { addInstance, getInstance, removeInstance } from '~/instances';
import { createStructureSetup, createScrollbarsSetup } from '~/setups';
import { getPlugins, addPlugin, optionsValidationPluginName } from '~/plugins';
import type { XY, TRBL } from '~/support';
import type { Options, ReadonlyOptions } from '~/options';
import type { Plugin, OptionsValidationPluginInstance, PluginInstance } from '~/plugins';
import type { InitializationTarget, Initialization } from '~/initialization';
import type { DeepPartial, OverflowStyle } from '~/typings';
import type { EventListenerMap, EventListener, InitialEventListeners } from '~/eventListeners';
import type {
ScrollbarsSetupElement,
ScrollbarStructure,
} from 'setups/scrollbarsSetup/scrollbarsSetup.elements';
} from '~/setups/scrollbarsSetup/scrollbarsSetup.elements';
// Notes:
// Height intrinsic detection use "content: true" init strategy - or open ticket for custom height intrinsic observer
@@ -1,5 +1,5 @@
import { animateNumber, noop } from 'support';
import type { Plugin } from 'plugins';
import { animateNumber, noop } from '~/support';
import type { Plugin } from '~/plugins';
export type ClickScrollPluginInstance = {
_: (
@@ -1 +1 @@
export * from 'plugins/clickScrollPlugin/clickScrollPlugin';
export * from '~/plugins/clickScrollPlugin/clickScrollPlugin';
@@ -1,5 +1,5 @@
export * from './plugins';
export * from './optionsValidationPlugin';
export * from './sizeObserverPlugin';
export * from './scrollbarsHidingPlugin';
export * from './clickScrollPlugin';
export * from '~/plugins/plugins';
export * from '~/plugins/optionsValidationPlugin';
export * from '~/plugins/sizeObserverPlugin';
export * from '~/plugins/scrollbarsHidingPlugin';
export * from '~/plugins/clickScrollPlugin';
@@ -1 +1 @@
export * from 'plugins/optionsValidationPlugin/optionsValidationPlugin';
export * from '~/plugins/optionsValidationPlugin/optionsValidationPlugin';
@@ -1,17 +1,19 @@
import {
validateOptions,
optionsTemplateTypes as oTypes,
} from '~/plugins/optionsValidationPlugin/validation';
import type {
Options,
OverflowBehavior,
ScrollbarVisibilityBehavior,
ScrollbarAutoHideBehavior,
} from 'options';
import {
validateOptions,
} from '~/options';
import type {
OptionsTemplate,
OptionsTemplateValue,
optionsTemplateTypes as oTypes,
} from 'plugins/optionsValidationPlugin/validation';
import type { DeepPartial } from 'typings';
import type { Plugin } from 'plugins';
} from '~/plugins/optionsValidationPlugin/validation';
import type { DeepPartial } from '~/typings';
import type { Plugin } from '~/plugins';
const numberAllowedValues: OptionsTemplateValue<number> = oTypes.number;
const booleanAllowedValues: OptionsTemplateValue<boolean> = oTypes.boolean;
@@ -1,13 +1,13 @@
import {
import { isArray } from '~/support/utils/types';
import { each, keys } from '~/support/utils';
import type {
OptionsTemplate,
OptionsObjectType,
OptionsTemplateNativeTypes,
OptionsTemplateTypes,
OptionsTemplateValue,
} from 'plugins/optionsValidationPlugin/validation';
import { PlainObject } from 'typings';
import { isArray } from 'support/utils/types';
import { each, keys } from 'support/utils';
} from '~/plugins/optionsValidationPlugin/validation';
import type { PlainObject } from '~/typings';
export interface OptionsWithOptionsTemplateTransformation<T> {
_template: OptionsTemplate<T>;
@@ -1,6 +1,6 @@
import { each, hasOwnProperty, keys, push, isEmptyObject } from 'support/utils';
import { type, isArray, isUndefined, isPlainObject, isString } from 'support/utils/types';
import { PlainObject, DeepPartial } from 'typings';
import { each, hasOwnProperty, keys, push, isEmptyObject } from '~/support/utils';
import { type, isArray, isUndefined, isPlainObject, isString } from '~/support/utils/types';
import type { PlainObject, DeepPartial } from '~/typings';
export type OptionsObjectType = Record<string, unknown>;
export type OptionsFunctionType = (this: any, ...args: any[]) => any;
@@ -1,5 +1,5 @@
import { each, isArray, keys, push } from 'support';
import { OverlayScrollbars, OverlayScrollbarsStatic } from 'overlayscrollbars';
import { each, isArray, keys, push } from '~/support';
import type { OverlayScrollbars, OverlayScrollbarsStatic } from '~/overlayscrollbars';
export type PluginInstance =
| Record<string, unknown>
@@ -1 +1 @@
export * from 'plugins/scrollbarsHidingPlugin/scrollbarsHidingPlugin';
export * from '~/plugins/scrollbarsHidingPlugin/scrollbarsHidingPlugin';
@@ -1,7 +1,6 @@
import {
keys,
attr,
WH,
style,
addClass,
removeClass,
@@ -9,19 +8,18 @@ import {
each,
assignDeep,
windowSize,
UpdateCache,
XY,
} from 'support';
import { classNameViewportArrange } from 'classnames';
import type { StyleObject } from 'typings';
import type { StructureSetupState } from 'setups/structureSetup';
} from '~/support';
import { classNameViewportArrange } from '~/classnames';
import type { WH, UpdateCache, XY } from '~/support';
import type { StyleObject } from '~/typings';
import type { StructureSetupState } from '~/setups/structureSetup';
import type {
ViewportOverflowState,
GetViewportOverflowState,
HideNativeScrollbars,
} from 'setups/structureSetup/updateSegments/overflowUpdateSegment';
import type { InternalEnvironment } from 'environment';
import type { Plugin } from 'plugins';
} from '~/setups/structureSetup/updateSegments/overflowUpdateSegment';
import type { InternalEnvironment } from '~/environment';
import type { Plugin } from '~/plugins';
export type ArrangeViewport = (
viewportOverflowState: ViewportOverflowState,
@@ -1 +1 @@
export * from 'plugins/sizeObserverPlugin/sizeObserverPlugin';
export * from '~/plugins/sizeObserverPlugin/sizeObserverPlugin';
@@ -12,13 +12,13 @@ import {
cAF,
rAF,
stopPropagation,
} from 'support';
} from '~/support';
import {
classNameSizeObserverListenerScroll,
classNameSizeObserverListenerItem,
classNameSizeObserverListenerItemFinal,
} from 'classnames';
import type { Plugin } from 'plugins';
} from '~/classnames';
import type { Plugin } from '~/plugins';
export type SizeObserverPluginInstance = {
_: (
@@ -1,3 +1,3 @@
export * from 'setups/setups';
export * from 'setups/structureSetup';
export * from 'setups/scrollbarsSetup';
export * from '~/setups/setups';
export * from '~/setups/structureSetup';
export * from '~/setups/scrollbarsSetup';
@@ -1 +1 @@
export * from 'setups/scrollbarsSetup/scrollbarsSetup';
export * from '~/setups/scrollbarsSetup/scrollbarsSetup';
@@ -1,6 +1,6 @@
import { offsetSize } from 'support';
import { getEnvironment } from 'environment';
import type { StructureSetupState } from 'setups';
import { offsetSize } from '~/support';
import { getEnvironment } from '~/environment';
import type { StructureSetupState } from '~/setups';
const { min, max, abs, round } = Math;
@@ -12,7 +12,7 @@ import {
runEachAndClear,
setT,
style,
} from 'support';
} from '~/support';
import {
classNameScrollbar,
classNameScrollbarHorizontal,
@@ -20,22 +20,22 @@ import {
classNameScrollbarTrack,
classNameScrollbarHandle,
classNamesScrollbarTransitionless,
} from 'classnames';
import { getEnvironment } from 'environment';
import { dynamicInitializationElement as generalDynamicInitializationElement } from 'initialization';
} from '~/classnames';
import { getEnvironment } from '~/environment';
import { dynamicInitializationElement as generalDynamicInitializationElement } from '~/initialization';
import {
getScrollbarHandleLengthRatio,
getScrollbarHandleOffsetRatio,
} from 'setups/scrollbarsSetup/scrollbarsSetup.calculations';
} from '~/setups/scrollbarsSetup/scrollbarsSetup.calculations';
import type {
InitializationTarget,
InitializationTargetElement,
InitializationTargetObject,
} from 'initialization';
import type { StructureSetupElementsObj } from 'setups/structureSetup/structureSetup.elements';
import type { ScrollbarsSetupEvents } from 'setups/scrollbarsSetup/scrollbarsSetup.events';
import type { StyleObject } from 'typings';
import type { StructureSetupState } from 'setups';
} from '~/initialization';
import type { StructureSetupElementsObj } from '~/setups/structureSetup/structureSetup.elements';
import type { ScrollbarsSetupEvents } from '~/setups/scrollbarsSetup/scrollbarsSetup.events';
import type { StyleObject } from '~/typings';
import type { StructureSetupState } from '~/setups';
export interface ScrollbarStructure {
_scrollbar: HTMLElement;
@@ -6,26 +6,26 @@ import {
preventDefault,
runEachAndClear,
stopPropagation,
XY,
selfClearTimeout,
parent,
closest,
push,
} from 'support';
import { getPlugins, clickScrollPluginName } from 'plugins';
import { getEnvironment } from 'environment';
} from '~/support';
import { getPlugins, clickScrollPluginName } from '~/plugins';
import { getEnvironment } from '~/environment';
import {
classNameScrollbarHandle,
classNamesScrollbarInteraction,
classNamesScrollbarWheel,
} from 'classnames';
import type { ClickScrollPluginInstance } from 'plugins';
import type { ReadonlyOptions } from 'options';
import type { StructureSetupState } from 'setups';
} from '~/classnames';
import type { XY } from '~/support';
import type { ClickScrollPluginInstance } from '~/plugins';
import type { ReadonlyOptions } from '~/options';
import type { StructureSetupState } from '~/setups';
import type {
ScrollbarsSetupElementsObj,
ScrollbarStructure,
} from 'setups/scrollbarsSetup/scrollbarsSetup.elements';
} from '~/setups/scrollbarsSetup/scrollbarsSetup.elements';
export type ScrollbarsSetupEvents = (
scrollbarStructure: ScrollbarStructure,
@@ -1,11 +1,7 @@
import { on, runEachAndClear, parent, scrollLeft, scrollTop, selfClearTimeout } from 'support';
import { createState, createOptionCheck } from 'setups/setups';
import { createScrollbarsSetupEvents } from 'setups/scrollbarsSetup/scrollbarsSetup.events';
import {
createScrollbarsSetupElements,
ScrollbarsSetupElementsObj,
ScrollbarStructure,
} from 'setups/scrollbarsSetup/scrollbarsSetup.elements';
import { on, runEachAndClear, parent, scrollLeft, scrollTop, selfClearTimeout } from '~/support';
import { createState, createOptionCheck } from '~/setups/setups';
import { createScrollbarsSetupEvents } from '~/setups/scrollbarsSetup/scrollbarsSetup.events';
import { createScrollbarsSetupElements } from '~/setups/scrollbarsSetup/scrollbarsSetup.elements';
import {
classNamesScrollbarVisible,
classNamesScrollbarUnusable,
@@ -14,16 +10,20 @@ import {
classNamesScrollbarHandleInteractive,
classNamesScrollbarTrackInteractive,
classNameScrollbarRtl,
} from 'classnames';
import type { StructureSetupUpdateHints } from 'setups/structureSetup/structureSetup.update';
} from '~/classnames';
import type {
ScrollbarsSetupElementsObj,
ScrollbarStructure,
} from '~/setups/scrollbarsSetup/scrollbarsSetup.elements';
import type { StructureSetupUpdateHints } from '~/setups/structureSetup/structureSetup.update';
import type {
ReadonlyOptions,
ScrollbarVisibilityBehavior,
ScrollbarAutoHideBehavior,
} from 'options';
import type { Setup, StructureSetupState, StructureSetupStaticState } from 'setups';
import type { InitializationTarget } from 'initialization';
import type { DeepPartial, OverflowStyle, StyleObject } from 'typings';
} from '~/options';
import type { Setup, StructureSetupState, StructureSetupStaticState } from '~/setups';
import type { InitializationTarget } from '~/initialization';
import type { DeepPartial, OverflowStyle, StyleObject } from '~/typings';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ScrollbarsSetupState {}
@@ -1,6 +1,6 @@
import { assignDeep, hasOwnProperty } from 'support';
import type { Options, ReadonlyOptions } from 'options';
import type { DeepPartial } from 'typings';
import { assignDeep, hasOwnProperty } from '~/support';
import type { Options, ReadonlyOptions } from '~/options';
import type { DeepPartial } from '~/typings';
export type SetupElements<T extends Record<string, any>> = [elements: T, destroy: () => void];
@@ -44,7 +44,7 @@ export const createOptionCheck =
(path: string) =>
[getPropByPath(options, path), force || getPropByPath(changedOptions, path) !== undefined];
export const createState = <S>(initialState: S): SetupState<S> => {
export const createState = <S extends Record<string, any>>(initialState: S): SetupState<S> => {
let state: S = initialState;
return [
() => state,
@@ -1 +1 @@
export * from 'setups/structureSetup/structureSetup';
export * from '~/setups/structureSetup/structureSetup';
@@ -21,7 +21,7 @@ import {
hasAttrClass,
noop,
on,
} from 'support';
} from '~/support';
import {
dataAttributeHost,
dataAttributeHostOverflowX,
@@ -30,19 +30,19 @@ import {
classNameViewport,
classNameContent,
classNameViewportScrollbarHidden,
} from 'classnames';
import { getEnvironment } from 'environment';
import { getPlugins, scrollbarsHidingPluginName } from 'plugins';
} from '~/classnames';
import { getEnvironment } from '~/environment';
import { getPlugins, scrollbarsHidingPluginName } from '~/plugins';
import {
staticInitializationElement as generalStaticInitializationElement,
dynamicInitializationElement as generalDynamicInitializationElement,
} from 'initialization';
import type { ScrollbarsHidingPluginInstance } from 'plugins/scrollbarsHidingPlugin';
} from '~/initialization';
import type { ScrollbarsHidingPluginInstance } from '~/plugins/scrollbarsHidingPlugin';
import type {
InitializationTarget,
InitializationTargetElement,
InitializationTargetObject,
} from 'initialization';
} from '~/initialization';
export type StructureSetupElements = [
elements: StructureSetupElementsObj,
@@ -7,13 +7,11 @@ import {
isString,
attr,
removeAttr,
CacheValues,
keys,
liesBetween,
scrollSize,
equalWH,
createCache,
WH,
fractionalSize,
isFunction,
ResizeObserverConstructor,
@@ -23,8 +21,8 @@ import {
scrollLeft,
scrollTop,
noop,
} from 'support';
import { getEnvironment } from 'environment';
} from '~/support';
import { getEnvironment } from '~/environment';
import {
dataAttributeHost,
dataValueHostOverflowVisible,
@@ -33,21 +31,17 @@ import {
classNameOverflowVisible,
classNameScrollbar,
classNameViewportArrange,
} from 'classnames';
import {
createSizeObserver,
createTrinsicObserver,
createDOMObserver,
DOMObserver,
SizeObserverCallbackParams,
} from 'observers';
import type { SetupState, SetupUpdateCheckOption } from 'setups';
import type { StructureSetupState } from 'setups/structureSetup';
import type { StructureSetupElementsObj } from 'setups/structureSetup/structureSetup.elements';
} from '~/classnames';
import { createSizeObserver, createTrinsicObserver, createDOMObserver } from '~/observers';
import type { DOMObserver, SizeObserverCallbackParams } from '~/observers';
import type { CacheValues, WH } from '~/support';
import type { SetupState, SetupUpdateCheckOption } from '~/setups';
import type { StructureSetupState } from '~/setups/structureSetup';
import type { StructureSetupElementsObj } from '~/setups/structureSetup/structureSetup.elements';
import type {
StructureSetupUpdate,
StructureSetupUpdateHints,
} from 'setups/structureSetup/structureSetup.update';
} from '~/setups/structureSetup/structureSetup.update';
export type StructureSetupObserversUpdate = (checkOption: SetupUpdateCheckOption) => void;
@@ -1,15 +1,15 @@
import { createEventListenerHub, isEmptyObject, keys, scrollLeft, scrollTop } from 'support';
import { createState, createOptionCheck } from 'setups/setups';
import { createStructureSetupElements } from 'setups/structureSetup/structureSetup.elements';
import { createStructureSetupUpdate } from 'setups/structureSetup/structureSetup.update';
import { createStructureSetupObservers } from 'setups/structureSetup/structureSetup.observers';
import type { StructureSetupUpdateHints } from 'setups/structureSetup/structureSetup.update';
import type { StructureSetupElementsObj } from 'setups/structureSetup/structureSetup.elements';
import type { TRBL, XY, EventListener } from 'support';
import type { Options, ReadonlyOptions } from 'options';
import type { Setup } from 'setups';
import type { InitializationTarget } from 'initialization';
import type { DeepPartial, StyleObject, OverflowStyle } from 'typings';
import { createEventListenerHub, isEmptyObject, keys, scrollLeft, scrollTop } from '~/support';
import { createState, createOptionCheck } from '~/setups/setups';
import { createStructureSetupElements } from '~/setups/structureSetup/structureSetup.elements';
import { createStructureSetupUpdate } from '~/setups/structureSetup/structureSetup.update';
import { createStructureSetupObservers } from '~/setups/structureSetup/structureSetup.observers';
import type { StructureSetupUpdateHints } from '~/setups/structureSetup/structureSetup.update';
import type { StructureSetupElementsObj } from '~/setups/structureSetup/structureSetup.elements';
import type { TRBL, XY, EventListener } from '~/support';
import type { Options, ReadonlyOptions } from '~/options';
import type { Setup } from '~/setups';
import type { InitializationTarget } from '~/initialization';
import type { DeepPartial, StyleObject, OverflowStyle } from '~/typings';
export interface StructureSetupState {
_padding: TRBL;
@@ -1,14 +1,14 @@
import { each, scrollLeft, scrollTop, assignDeep, keys } from 'support';
import { getEnvironment } from 'environment';
import { dataValueHostUpdating } from 'classnames';
import { each, scrollLeft, scrollTop, assignDeep, keys } from '~/support';
import { getEnvironment } from '~/environment';
import { dataValueHostUpdating } from '~/classnames';
import {
createTrinsicUpdateSegment,
createPaddingUpdateSegment,
createOverflowUpdateSegment,
} from 'setups/structureSetup/updateSegments';
import type { SetupState, SetupUpdateSegment, SetupUpdateCheckOption } from 'setups';
import type { StructureSetupState } from 'setups/structureSetup';
import type { StructureSetupElementsObj } from 'setups/structureSetup/structureSetup.elements';
} from '~/setups/structureSetup/updateSegments';
import type { SetupState, SetupUpdateSegment, SetupUpdateCheckOption } from '~/setups';
import type { StructureSetupState } from '~/setups/structureSetup';
import type { StructureSetupElementsObj } from '~/setups/structureSetup/structureSetup.elements';
export type CreateStructureUpdateSegment = (
structureSetupElements: StructureSetupElementsObj,
@@ -1,3 +1,3 @@
export * from 'setups/structureSetup/updateSegments/trinsicUpdateSegment';
export * from 'setups/structureSetup/updateSegments/paddingUpdateSegment';
export * from 'setups/structureSetup/updateSegments/overflowUpdateSegment';
export * from '~/setups/structureSetup/updateSegments/trinsicUpdateSegment';
export * from '~/setups/structureSetup/updateSegments/paddingUpdateSegment';
export * from '~/setups/structureSetup/updateSegments/overflowUpdateSegment';
@@ -1,8 +1,6 @@
import {
createCache,
attr,
WH,
XY,
style,
scrollSize,
fractionalSize,
@@ -13,8 +11,8 @@ import {
equalXY,
attrClass,
noop,
} from 'support';
import { getEnvironment } from 'environment';
} from '~/support';
import { getEnvironment } from '~/environment';
import {
classNameViewportScrollbarHidden,
classNameOverflowVisible,
@@ -23,16 +21,17 @@ import {
dataAttributeHostOverflowY,
dataValueHostScrollbarHidden,
dataValueHostOverflowVisible,
} from 'classnames';
import { getPlugins, scrollbarsHidingPluginName } from 'plugins';
} from '~/classnames';
import { getPlugins, scrollbarsHidingPluginName } from '~/plugins';
import type { WH, XY } from '~/support';
import type {
ScrollbarsHidingPluginInstance,
ArrangeViewport,
UndoArrangeViewport,
} from 'plugins/scrollbarsHidingPlugin';
import type { StyleObject, OverflowStyle } from 'typings';
import type { OverflowBehavior } from 'options';
import type { CreateStructureUpdateSegment } from 'setups/structureSetup/structureSetup.update';
} from '~/plugins/scrollbarsHidingPlugin';
import type { StyleObject, OverflowStyle } from '~/typings';
import type { OverflowBehavior } from '~/options';
import type { CreateStructureUpdateSegment } from '~/setups/structureSetup/structureSetup.update';
export interface ViewportOverflowState {
_scrollbarsHideOffset: XY<number>;
@@ -1,7 +1,7 @@
import { createCache, topRightBottomLeft, equalTRBL, style, assignDeep } from 'support';
import { StyleObject } from 'typings';
import { getEnvironment } from 'environment';
import type { CreateStructureUpdateSegment } from 'setups/structureSetup/structureSetup.update';
import { createCache, topRightBottomLeft, equalTRBL, style, assignDeep } from '~/support';
import { getEnvironment } from '~/environment';
import type { StyleObject } from '~/typings';
import type { CreateStructureUpdateSegment } from '~/setups/structureSetup/structureSetup.update';
/**
* Lifecycle with the responsibility to adjust the padding styling of the padding and viewport element.
@@ -1,6 +1,6 @@
import { style } from 'support';
import { getEnvironment } from 'environment';
import type { CreateStructureUpdateSegment } from 'setups/structureSetup/structureSetup.update';
import { style } from '~/support';
import { getEnvironment } from '~/environment';
import type { CreateStructureUpdateSegment } from '~/setups/structureSetup/structureSetup.update';
/**
* Lifecycle with the responsibility to adjust the trinsic behavior of the content element.
@@ -1,4 +1,4 @@
import { jsAPI } from 'support/compatibility/vendors';
import { jsAPI } from '~/support/compatibility/vendors';
export const MutationObserverConstructor = jsAPI<typeof MutationObserver>('MutationObserver');
export const IntersectionObserverConstructor =
@@ -1,2 +1,2 @@
export * from 'support/compatibility/vendors';
export * from 'support/compatibility/apis';
export * from '~/support/compatibility/vendors';
export * from '~/support/compatibility/apis';
@@ -1,6 +1,6 @@
import { each } from 'support/utils/array';
import { hasOwnProperty } from 'support/utils/object';
import { createDiv } from 'support/dom/create';
import { each } from '~/support/utils/array';
import { hasOwnProperty } from '~/support/utils/object';
import { createDiv } from '~/support/dom/create';
const firstLetterToUpper = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1);
const getDummyStyle = (): CSSStyleDeclaration => createDiv().style;
@@ -1,5 +1,5 @@
import { rAF, cAF } from 'support/compatibility';
import { isFunction } from 'support/utils';
import { rAF, cAF } from '~/support/compatibility';
import { isFunction } from '~/support/utils';
const { max } = Math;
const animationCurrentTime = () => performance.now();
@@ -1,5 +1,5 @@
import { from } from 'support/utils/array';
import { isNumber, isString, isUndefined } from 'support/utils/types';
import { from } from '~/support/utils/array';
import { isNumber, isString, isUndefined } from '~/support/utils/types';
type GetSetPropName = 'scrollLeft' | 'scrollTop' | 'value';
@@ -1,6 +1,6 @@
import { isString } from 'support/utils/types';
import { each } from 'support/utils/array';
import { keys } from 'support/utils/object';
import { isString } from '~/support/utils/types';
import { each } from '~/support/utils/array';
import { keys } from '~/support/utils/object';
type ClassContainingElement = Node | Element | false | null | undefined;
type ClassName = string | false | null | undefined;
@@ -1,7 +1,7 @@
import { each } from 'support/utils/array';
import { attr } from 'support/dom/attribute';
import { contents } from 'support/dom/traversal';
import { removeElements } from 'support/dom/manipulation';
import { each } from '~/support/utils/array';
import { attr } from '~/support/dom/attribute';
import { contents } from '~/support/dom/traversal';
import { removeElements } from '~/support/dom/manipulation';
/**
* Creates a div DOM node.
@@ -1,4 +1,4 @@
import { style } from 'support/dom/style';
import { style } from '~/support/dom/style';
export interface WH<T = number> {
w: T;
@@ -1,5 +1,5 @@
import { isUndefined } from 'support/utils/types';
import { each, push, runEachAndClear } from 'support/utils/array';
import { isUndefined } from '~/support/utils/types';
import { each, push, runEachAndClear } from '~/support/utils/array';
let passiveEventsSupport: boolean;
const supportPassiveEvents = (): boolean => {
@@ -1,10 +1,10 @@
export * from 'support/dom/animation';
export * from 'support/dom/attribute';
export * from 'support/dom/class';
export * from 'support/dom/create';
export * from 'support/dom/dimensions';
export * from 'support/dom/events';
export * from 'support/dom/style';
export * from 'support/dom/manipulation';
export * from 'support/dom/offset';
export * from 'support/dom/traversal';
export * from '~/support/dom/animation';
export * from '~/support/dom/attribute';
export * from '~/support/dom/class';
export * from '~/support/dom/create';
export * from '~/support/dom/dimensions';
export * from '~/support/dom/events';
export * from '~/support/dom/style';
export * from '~/support/dom/manipulation';
export * from '~/support/dom/offset';
export * from '~/support/dom/traversal';
@@ -1,6 +1,6 @@
import { isArrayLike } from 'support/utils/types';
import { each, from } from 'support/utils/array';
import { parent } from 'support/dom/traversal';
import { isArrayLike } from '~/support/utils/types';
import { each, from } from '~/support/utils/array';
import { parent } from '~/support/dom/traversal';
type NodeCollection = ArrayLike<Node> | Node | false | null | undefined;
@@ -1,4 +1,4 @@
import { getBoundingClientRect } from 'support/dom/dimensions';
import { getBoundingClientRect } from '~/support/dom/dimensions';
export interface XY<T = number> {
x: T;
@@ -1,6 +1,6 @@
import { each, keys } from 'support/utils';
import { isString, isNumber, isArray, isUndefined } from 'support/utils/types';
import { PlainObject, StyleObject } from 'typings';
import { each, keys } from '~/support/utils';
import { isString, isNumber, isArray, isUndefined } from '~/support/utils/types';
import type { PlainObject, StyleObject } from '~/typings';
export interface TRBL {
t: number;
@@ -1,5 +1,5 @@
import { isElement } from 'support/utils/types';
import { push, from } from 'support/utils/array';
import { isElement } from '~/support/utils/types';
import { push, from } from '~/support/utils/array';
type InputElementType = Node | Element | Node | false | null | undefined;
type OutputElementType = Node | Element | null;
@@ -1,6 +1,6 @@
import { isArray } from 'support/utils/types';
import { keys } from 'support/utils/object';
import { each, from, isEmptyArray } from 'support/utils/array';
import { isArray } from '~/support/utils/types';
import { keys } from '~/support/utils/object';
import { each, from, isEmptyArray } from '~/support/utils/array';
export type EventListener<EventMap extends Record<string, any[]>, N extends keyof EventMap> = (
...args: EventMap[N]
@@ -1,5 +1,5 @@
export * from 'support/cache';
export * from 'support/compatibility';
export * from 'support/dom';
export * from 'support/utils';
export * from 'support/eventListeners';
export * from '~/support/cache';
export * from '~/support/compatibility';
export * from '~/support/dom';
export * from '~/support/utils';
export * from '~/support/eventListeners';
@@ -1,5 +1,5 @@
import { isArrayLike, isString } from 'support/utils/types';
import { PlainObject } from 'typings';
import { isArrayLike, isString } from '~/support/utils/types';
import type { PlainObject } from '~/typings';
type RunEachItem = ((...args: any) => any | any[]) | null | undefined;
@@ -1,6 +1,6 @@
import { each } from 'support/utils/array';
import { WH, XY, TRBL } from 'support/dom';
import { PlainObject } from 'typings';
import { each } from '~/support/utils/array';
import type { WH, XY, TRBL } from '~/support/dom';
import type { PlainObject } from '~/typings';
/**
* Compares two objects and returns true if all values of the passed prop names are identical, false otherwise or if one of the two object is falsy.
@@ -1,6 +1,6 @@
import { isNumber, isFunction } from 'support/utils/types';
import { from } from 'support/utils/array';
import { rAF, cAF, setT, clearT } from 'support/compatibility/apis';
import { isNumber, isFunction } from '~/support/utils/types';
import { from } from '~/support/utils/array';
import { rAF, cAF, setT, clearT } from '~/support/compatibility/apis';
type DebounceTiming = number | false | null | undefined;
@@ -1,5 +1,5 @@
export * from 'support/utils/array';
export * from 'support/utils/equal';
export * from 'support/utils/function';
export * from 'support/utils/object';
export * from 'support/utils/types';
export * from '~/support/utils/array';
export * from '~/support/utils/equal';
export * from '~/support/utils/function';
export * from '~/support/utils/object';
export * from '~/support/utils/types';
@@ -1,5 +1,5 @@
import { isArray, isFunction, isPlainObject, isNull } from 'support/utils/types';
import { each } from 'support/utils/array';
import { isArray, isFunction, isPlainObject, isNull } from '~/support/utils/types';
import { each } from '~/support/utils/array';
/**
* Determines whether the passed object has a property with the passed name.
@@ -1,4 +1,4 @@
import { PlainObject } from 'typings';
import type { PlainObject } from '~/typings';
const ElementNodeType = Node.ELEMENT_NODE;
const { toString, hasOwnProperty } = Object.prototype;
@@ -1,8 +1,9 @@
import { DeepPartial } from 'typings';
import { defaultOptions, Options } from 'options';
import { Initialization } from 'initialization';
import { getEnvironment } from 'environment';
import { ScrollbarsHidingPlugin, scrollbarsHidingPluginName } from 'plugins';
import type { DeepPartial } from '~/typings';
import type { Options } from '~/options';
import { defaultOptions } from '~/options';
import type { Initialization } from '~/initialization';
import { getEnvironment } from '~/environment';
import { ScrollbarsHidingPlugin, scrollbarsHidingPluginName } from '~/plugins';
const defaultInitialization = {
elements: {
@@ -25,8 +26,8 @@ let getEnv = getEnvironment;
describe('environment', () => {
beforeEach(async () => {
jest.resetModules();
jest.doMock('support', () => {
const originalModule = jest.requireActual('support');
jest.doMock('~/support', () => {
const originalModule = jest.requireActual('~/support');
let i = 0;
return {
...originalModule,
@@ -37,15 +38,15 @@ describe('environment', () => {
clientSize: jest.fn().mockImplementation(() => ({ w: 90, h: 90 })),
};
});
jest.doMock('plugins', () => {
const originalModule = jest.requireActual('plugins');
jest.doMock('~/plugins', () => {
const originalModule = jest.requireActual('~/plugins');
return {
...originalModule,
getPlugins: jest.fn(() => originalModule.getPlugins()),
};
});
({ getEnvironment: getEnv } = await import('environment'));
({ getEnvironment: getEnv } = await import('~/environment'));
});
test('singleton behavior', () => {
@@ -143,7 +144,7 @@ describe('environment', () => {
describe('addListener', () => {
test('with scrollbarsHidingPlugin registered before environment was created', async () => {
const { getPlugins } = await import('plugins');
const { getPlugins } = await import('~/plugins');
(getPlugins as jest.Mock).mockImplementation(() => ({
[scrollbarsHidingPluginName]: ScrollbarsHidingPlugin[scrollbarsHidingPluginName],
}));
@@ -163,7 +164,7 @@ describe('environment', () => {
_addListener(listener);
const { getPlugins } = await import('plugins');
const { getPlugins } = await import('~/plugins');
(getPlugins as jest.Mock).mockImplementation(() => ({
[scrollbarsHidingPluginName]: ScrollbarsHidingPlugin[scrollbarsHidingPluginName],
}));
@@ -1,13 +1,13 @@
import type { Initialization } from '~/initialization';
import {
staticInitializationElement,
dynamicInitializationElement,
cancelInitialization,
Initialization,
} from 'initialization';
import { getEnvironment } from 'environment';
} from '~/initialization';
import { getEnvironment } from '~/environment';
jest.mock('environment', () => ({
getEnvironment: jest.fn(() => jest.requireActual('environment').getEnvironment()),
jest.mock('~/environment', () => ({
getEnvironment: jest.fn(() => jest.requireActual('~/environment').getEnvironment()),
}));
const createDiv = () => document.createElement('div');
@@ -422,7 +422,7 @@ describe('initialization', () => {
},
].forEach((env) => {
(getEnvironment as jest.Mock).mockImplementation(() => ({
...jest.requireActual('environment').getEnvironment(),
...jest.requireActual('~/environment').getEnvironment(),
...env,
}));
const hasOverlaidScrollbars =
@@ -474,7 +474,7 @@ describe('initialization', () => {
},
].forEach((env) => {
(getEnvironment as jest.Mock).mockImplementation(() => ({
...jest.requireActual('environment').getEnvironment(),
...jest.requireActual('~/environment').getEnvironment(),
...env,
}));
const hasOverlaidScrollbars =
@@ -521,7 +521,7 @@ describe('initialization', () => {
(env) => {
[false, true].forEach((isBody) => {
(getEnvironment as jest.Mock).mockImplementation(() => ({
...jest.requireActual('environment').getEnvironment(),
...jest.requireActual('~/environment').getEnvironment(),
...env,
}));
const defaultBody = defaultCancelInitialization.body;
@@ -561,7 +561,7 @@ describe('initialization', () => {
[{ _nativeScrollbarsHiding: false }, { _nativeScrollbarsHiding: true }].forEach((env) => {
[false, true].forEach((isBody) => {
(getEnvironment as jest.Mock).mockImplementation(() => ({
...jest.requireActual('environment').getEnvironment(),
...jest.requireActual('~/environment').getEnvironment(),
...env,
}));
const defaultBody = defaultCancelInitialization.body;
@@ -1,5 +1,5 @@
import { addInstance, removeInstance, getInstance } from 'instances';
import { OverlayScrollbars } from '../../src/overlayscrollbars';
import { addInstance, removeInstance, getInstance } from '~/instances';
import { OverlayScrollbars } from '~/overlayscrollbars';
const testElm = document.body;
const testInstance = OverlayScrollbars(document.body, {});
@@ -1,9 +1,9 @@
import { createDOMObserver } from 'observers';
import { createDOMObserver } from '~/observers';
jest.useFakeTimers();
jest.mock('support/compatibility/apis', () => {
const originalModule = jest.requireActual('support/compatibility/apis');
jest.mock('~/support/compatibility/apis', () => {
const originalModule = jest.requireActual('~/support/compatibility/apis');
const mockRAF = (arg: any) => setTimeout(arg, 0);
return {
...originalModule,
@@ -1,17 +1,17 @@
import { createSizeObserver as originalCreateSizeObserver } from 'observers';
import { SizeObserverPlugin, sizeObserverPluginName } from 'plugins';
import { createSizeObserver as originalCreateSizeObserver } from '~/observers';
import { SizeObserverPlugin, sizeObserverPluginName } from '~/plugins';
let createSizeObserver = originalCreateSizeObserver;
const mockResizeObserverConstructor = async (value: any) => {
jest.resetModules();
jest.unmock('plugins');
jest.doMock('support/compatibility/apis', () => ({
...jest.requireActual('support/compatibility/apis'),
jest.unmock('~/plugins');
jest.doMock('~/support/compatibility/apis', () => ({
...jest.requireActual('~/support/compatibility/apis'),
ResizeObserverConstructor: value,
}));
({ createSizeObserver } = await import('observers'));
({ createSizeObserver } = await import('~/observers'));
};
describe('createSizeObserver', () => {
@@ -64,8 +64,8 @@ describe('createSizeObserver', () => {
beforeEach(() => {
mockResizeObserverConstructor(false);
jest.doMock('plugins', () => ({
...jest.requireActual('plugins'),
jest.doMock('~/plugins', () => ({
...jest.requireActual('~/plugins'),
getPlugins: () => ({
[sizeObserverPluginName]: {
_: mockSizeObserverPlugin,
@@ -1,4 +1,4 @@
import { createTrinsicObserver } from 'observers';
import { createTrinsicObserver } from '~/observers';
describe('createTrinsicObserver', () => {
beforeEach(() => {
@@ -1,4 +1,4 @@
import { defaultOptions, getOptionsDiff } from 'options';
import { defaultOptions, getOptionsDiff } from '~/options';
describe('options', () => {
test('defaultOptions', () => {
@@ -1,8 +1,9 @@
import { DeepPartial } from 'typings';
import { defaultOptions, Options } from 'options';
import { assignDeep } from 'support';
import { OptionsValidationPlugin } from 'plugins';
import { OverlayScrollbars as originalOverlayScrollbars } from '../../src/overlayscrollbars';
import type { DeepPartial } from '~/typings';
import type { Options } from '~/options';
import { defaultOptions } from '~/options';
import { assignDeep } from '~/support';
import { OptionsValidationPlugin } from '~/plugins';
import { OverlayScrollbars as originalOverlayScrollbars } from '~/overlayscrollbars';
const bodyElm = document.body;
const div = document.createElement('div');
@@ -14,7 +15,7 @@ let OverlayScrollbars = originalOverlayScrollbars;
describe('overlayscrollbars', () => {
beforeEach(async () => {
jest.resetModules();
({ OverlayScrollbars } = await import('../../src/overlayscrollbars'));
({ OverlayScrollbars } = await import('~/overlayscrollbars'));
});
afterEach(() => {
@@ -1,8 +1,8 @@
import { defaultOptions } from 'options';
import { defaultOptions } from '~/options';
import {
OptionsValidationPlugin,
optionsValidationPluginName,
} from 'plugins/optionsValidationPlugin';
} from '~/plugins/optionsValidationPlugin';
const getValidationFn = () => {
const name = Object.keys(OptionsValidationPlugin)[0];
@@ -1,12 +1,8 @@
import { PlainObject } from 'typings';
import {
optionsTemplateTypes as oTypes,
OptionsTemplate,
} from 'plugins/optionsValidationPlugin/validation';
import {
transformOptions,
OptionsWithOptionsTemplate,
} from 'plugins/optionsValidationPlugin/transformation';
import type { PlainObject } from '~/typings';
import type { OptionsTemplate } from '~/plugins/optionsValidationPlugin/validation';
import { optionsTemplateTypes as oTypes } from '~/plugins/optionsValidationPlugin/validation';
import type { OptionsWithOptionsTemplate } from '~/plugins/optionsValidationPlugin/transformation';
import { transformOptions } from '~/plugins/optionsValidationPlugin/transformation';
type TestOptionsObj = { propA: 'propA'; null: null };
type TestOptionsEnum = 'A' | 'B' | 'C';
@@ -1,9 +1,9 @@
import type { OptionsTemplate } from '~/plugins/optionsValidationPlugin/validation';
import {
validateOptions,
optionsTemplateTypes as oTypes,
OptionsTemplate,
} from 'plugins/optionsValidationPlugin/validation';
import { assignDeep } from 'support/utils';
} from '~/plugins/optionsValidationPlugin/validation';
import { assignDeep } from '~/support/utils';
type TestOptionsObj = { propA: 'propA'; null: null };
type TestOptionsEnum = 'A' | 'B' | 'C';
@@ -1,4 +1,4 @@
import { addPlugin, getPlugins } from 'plugins';
import { addPlugin, getPlugins } from '~/plugins';
describe('plugins', () => {
test('getPlugins', () => {
@@ -1,13 +1,11 @@
import {
createScrollbarsSetupElements,
import type {
ScrollbarsSetupElement,
ScrollbarsSetupElementsObj,
ScrollbarStructure,
} from 'setups/scrollbarsSetup/scrollbarsSetup.elements';
import {
createStructureSetupElements,
StructureSetupElementsObj,
} from 'setups/structureSetup/structureSetup.elements';
} from '~/setups/scrollbarsSetup/scrollbarsSetup.elements';
import { createScrollbarsSetupElements } from '~/setups/scrollbarsSetup/scrollbarsSetup.elements';
import type { StructureSetupElementsObj } from '~/setups/structureSetup/structureSetup.elements';
import { createStructureSetupElements } from '~/setups/structureSetup/structureSetup.elements';
import {
classNameScrollbar,
classNameScrollbarHorizontal,
@@ -15,13 +13,13 @@ import {
classNameScrollbarTrack,
classNameScrollbarHandle,
classNamesScrollbarTransitionless,
} from 'classnames';
import type { InitializationTarget } from 'initialization';
} from '~/classnames';
import type { InitializationTarget } from '~/initialization';
jest.useFakeTimers();
jest.mock('support/compatibility/apis', () => {
const originalModule = jest.requireActual('support/compatibility/apis');
jest.mock('~/support/compatibility/apis', () => {
const originalModule = jest.requireActual('~/support/compatibility/apis');
return {
...originalModule,
// @ts-ignore
@@ -1,23 +1,22 @@
import { hasClass, is, isFunction, isHTMLElement } from 'support';
import { hasClass, is, isFunction, isHTMLElement } from '~/support';
import {
dataAttributeHost,
classNamePadding,
classNameViewport,
classNameContent,
} from 'classnames';
import { getEnvironment, InternalEnvironment } from 'environment';
import {
createStructureSetupElements,
StructureSetupElementsObj,
} from 'setups/structureSetup/structureSetup.elements';
import { addPlugin, ScrollbarsHidingPlugin } from 'plugins';
} from '~/classnames';
import type { InternalEnvironment } from '~/environment';
import { getEnvironment } from '~/environment';
import type { StructureSetupElementsObj } from '~/setups/structureSetup/structureSetup.elements';
import { createStructureSetupElements } from '~/setups/structureSetup/structureSetup.elements';
import { addPlugin, ScrollbarsHidingPlugin } from '~/plugins';
import type {
Initialization,
InitializationTarget,
InitializationTargetObject,
} from 'initialization';
} from '~/initialization';
jest.mock('environment', () => ({
jest.mock('~/environment', () => ({
getEnvironment: jest.fn(),
}));
@@ -343,7 +342,7 @@ const assertCorrectDestroy = (snapshot: string, destroy: () => void) => {
expect(snapshot).toBe(getSnapshot());
};
const env: InternalEnvironment = jest.requireActual('environment').getEnvironment();
const env: InternalEnvironment = jest.requireActual('~/environment').getEnvironment();
const envDefault = {
name: 'default',
env,
@@ -430,7 +429,7 @@ describe('structureSetup.elements', () => {
beforeEach(() => {
(getEnvironment as jest.Mock).mockImplementation(() =>
jest.requireActual('environment').getEnvironment()
jest.requireActual('~/environment').getEnvironment()
);
});
@@ -1,4 +1,4 @@
import { createCache } from 'support/cache';
import { createCache } from '~/support/cache';
const createUpdater = <T>(updaterReturn: (i: number) => T) => {
let index = 0;
@@ -1,4 +1,4 @@
import { jsAPI, cssProperty, cssPropertyValue } from 'support/compatibility/vendors';
import { jsAPI, cssProperty, cssPropertyValue } from '~/support/compatibility/vendors';
describe('vendors', () => {
describe('jsAPI', () => {
@@ -1,9 +1,9 @@
import { animateNumber } from 'support/dom/animation';
import { animateNumber } from '~/support/dom/animation';
jest.useFakeTimers();
jest.mock('support/compatibility/apis', () => {
const originalModule = jest.requireActual('support/compatibility/apis');
jest.mock('~/support/compatibility/apis', () => {
const originalModule = jest.requireActual('~/support/compatibility/apis');
const mockRAF = (arg: any) => setTimeout(arg, 0);
return {
...originalModule,
@@ -6,7 +6,7 @@ import {
val,
scrollLeft,
scrollTop,
} from 'support/dom/attribute';
} from '~/support/dom/attribute';
const testElm = document.body;
const getAttribute = (name: string) => testElm.getAttribute(name);
@@ -1,4 +1,4 @@
import { addClass, removeClass, hasClass, diffClass } from 'support/dom/class';
import { addClass, removeClass, hasClass, diffClass } from '~/support/dom/class';
const testElm = document.body;
const removeAllClassNames = () => {
@@ -1,5 +1,5 @@
import { each } from 'support/utils';
import { createDiv, createDOM } from 'support/dom/create';
import { each } from '~/support/utils';
import { createDiv, createDOM } from '~/support/dom/create';
const slotElm = document.body;
const testHTML =
@@ -1,5 +1,5 @@
import { isNumber, isPlainObject } from 'support/utils/types';
import { createDiv } from 'support/dom/create';
import { isNumber, isPlainObject } from '~/support/utils/types';
import { createDiv } from '~/support/dom/create';
import {
windowSize,
offsetSize,
@@ -8,7 +8,7 @@ import {
fractionalSize,
getBoundingClientRect,
hasDimensions,
} from 'support/dom/dimensions';
} from '~/support/dom/dimensions';
describe('dom dimensions', () => {
describe('offsetSize', () => {
@@ -1,10 +1,5 @@
import {
off,
preventDefault,
stopPropagation,
stopAndPrevent,
OnOptions,
} from 'support/dom/events';
import type { OnOptions } from '~/support/dom/events';
import { off, preventDefault, stopPropagation, stopAndPrevent } from '~/support/dom/events';
const testElm = document.body;
const mockEventListener = (
@@ -89,7 +84,7 @@ describe('dom events', () => {
};
beforeEach(() =>
import('support/dom/events').then((module) => {
import('~/support/dom/events').then((module) => {
eventsModule = module;
jest.resetModules();
})
@@ -1,5 +1,13 @@
import { createDiv, contents, appendChildren, prependChildren, insertBefore, insertAfter, removeElements } from 'support/dom';
import { each, isArray, isHTMLElement } from 'support/utils';
import {
createDiv,
contents,
appendChildren,
prependChildren,
insertBefore,
insertAfter,
removeElements,
} from '~/support/dom';
import { each, isArray, isHTMLElement } from '~/support/utils';
const slotElm = document.body;
const fillSlotElm = () => {
@@ -19,7 +27,7 @@ const compareToNative = (
method: string,
snapshot: Array<Node>,
elms: Element | Node | Array<Element> | Array<Node>,
compareIds = false,
compareIds = false
) => {
if (!compareIds) {
if (!isArray(elms)) {
@@ -47,7 +55,12 @@ const compareToNative = (
if (isHTMLElement(elm) && child.getAttribute('id') === elm.getAttribute('id')) {
realElms.push(child);
}
if (compareIds && target !== slotElm && isHTMLElement(target) && child.getAttribute('id') === target.getAttribute('id')) {
if (
compareIds &&
target !== slotElm &&
isHTMLElement(target) &&
child.getAttribute('id') === target.getAttribute('id')
) {
target = child;
}
}
@@ -1,5 +1,5 @@
import { isNumber, isPlainObject } from 'support/utils/types';
import { absoluteCoordinates, offsetCoordinates } from 'support/dom/offset';
import { isNumber, isPlainObject } from '~/support/utils/types';
import { absoluteCoordinates, offsetCoordinates } from '~/support/dom/offset';
describe('dom offset', () => {
describe('absoluteCoordinates', () => {
@@ -1,6 +1,6 @@
import { isEmptyObject } from 'support/utils/object';
import { isString, isPlainObject } from 'support/utils/types';
import { style, topRightBottomLeft, directionIsRTL } from 'support/dom/style';
import { isEmptyObject } from '~/support/utils/object';
import { isString, isPlainObject } from '~/support/utils/types';
import { style, topRightBottomLeft, directionIsRTL } from '~/support/dom/style';
describe('dom style', () => {
afterEach(() => {
@@ -8,7 +8,7 @@ import {
createDiv,
liesBetween,
createDOM,
} from 'support/dom';
} from '~/support/dom';
const slotElm = document.body;
const testHTML =
@@ -1,4 +1,4 @@
import { createEventListenerHub } from 'support/eventListeners';
import { createEventListenerHub } from '~/support/eventListeners';
type EventMap = {
onBoolean: [a: boolean, b: string];
@@ -1,4 +1,4 @@
import { push, each, from, indexOf, runEachAndClear, isEmptyArray } from 'support/utils/array';
import { push, each, from, indexOf, runEachAndClear, isEmptyArray } from '~/support/utils/array';
describe('array utilities', () => {
describe('push', () => {
@@ -1,4 +1,4 @@
import { equal, equalTRBL, equalWH, equalXY, equalBCRWH } from 'support/utils/equal';
import { equal, equalTRBL, equalWH, equalXY, equalBCRWH } from '~/support/utils/equal';
describe('equal', () => {
test('equal', () => {
@@ -1,10 +1,10 @@
import { noop, debounce, selfClearTimeout } from 'support/utils/function';
import { rAF, cAF, setT, clearT } from 'support/compatibility/apis';
import { noop, debounce, selfClearTimeout } from '~/support/utils/function';
import { rAF, cAF, setT, clearT } from '~/support/compatibility/apis';
jest.useFakeTimers();
jest.mock('support/compatibility/apis', () => {
const originalModule = jest.requireActual('support/compatibility/apis');
jest.mock('~/support/compatibility/apis', () => {
const originalModule = jest.requireActual('~/support/compatibility/apis');
const mockRAF = (arg: any) => setTimeout(arg, 0);
return {
...originalModule,
@@ -1,5 +1,5 @@
import { assignDeep, keys, hasOwnProperty, isEmptyObject } from 'support/utils/object';
import { isPlainObject } from 'support/utils/types';
import { assignDeep, keys, hasOwnProperty, isEmptyObject } from '~/support/utils/object';
import { isPlainObject } from '~/support/utils/types';
describe('object utilities', () => {
// https://github.com/jquery/jquery/blob/master/test/unit/core.js#L965
@@ -28,7 +28,13 @@ describe('object utilities', () => {
let settings: Settings = { xnumber1: 5, xnumber2: 7, xstring1: 'peter', xstring2: 'pan' };
const options: Settings = { xnumber2: 1, xstring2: 'x', xxx: 'newstring' };
const optionsCopy: Settings = { xnumber2: 1, xstring2: 'x', xxx: 'newstring' };
const merged: Settings = { xnumber1: 5, xnumber2: 1, xstring1: 'peter', xstring2: 'x', xxx: 'newstring' };
const merged: Settings = {
xnumber1: 5,
xnumber2: 1,
xstring1: 'peter',
xstring2: 'x',
xxx: 'newstring',
};
assignDeep(settings, options);
expect(settings).toEqual(merged);
@@ -134,7 +140,13 @@ describe('object utilities', () => {
const options1Copy = { xnumber2: 1, xstring2: 'x' };
const options2 = { xstring2: 'xx', xxx: 'newstringx' };
const options2Copy = { xstring2: 'xx', xxx: 'newstringx' };
const merged2 = { xnumber1: 5, xnumber2: 1, xstring1: 'peter', xstring2: 'xx', xxx: 'newstringx' };
const merged2 = {
xnumber1: 5,
xnumber2: 1,
xstring1: 'peter',
xstring2: 'xx',
xxx: 'newstringx',
};
settings = assignDeep({}, defaults, options1, options2);
expect(settings).toEqual(merged2);
@@ -143,8 +155,14 @@ describe('object utilities', () => {
expect(options2).toEqual(options2Copy);
expect(assignDeep('', { foo: 1 })).toEqual({ foo: 1 });
expect(assignDeep(null, { foo: null, deep: { foo: null } })).toEqual({ foo: null, deep: { foo: null } });
expect(assignDeep(12, { foo: 1, deep: { foo: null, text: '' } })).toEqual({ foo: 1, deep: { foo: null, text: '' } });
expect(assignDeep(null, { foo: null, deep: { foo: null } })).toEqual({
foo: null,
deep: { foo: null },
});
expect(assignDeep(12, { foo: 1, deep: { foo: null, text: '' } })).toEqual({
foo: 1,
deep: { foo: null, text: '' },
});
});
});
@@ -1,4 +1,4 @@
import { createDOM } from 'support/dom/create';
import { createDOM } from '~/support/dom/create';
import {
type,
isNumber,
@@ -13,7 +13,7 @@ import {
isPlainObject,
isElement,
isHTMLElement,
} from 'support/utils/types';
} from '~/support/utils/types';
const testfn = function () {};
const testfnAsync = async function () {};
@@ -5,8 +5,8 @@ import { webpack } from 'webpack';
import { build } from 'esbuild';
import { terser } from 'rollup-plugin-terser';
import pkg from '../../package.json';
import rollupConfig from '../../rollup.config';
import pkg from '~/../package.json';
import rollupConfig from '~/../rollup.config';
const cleanBundle = true;
const cleanFixture = true;
@@ -1,6 +1,6 @@
import 'index.scss';
import { createDOM, appendChildren } from 'support';
import { getEnvironment } from 'environment';
import '~/index.scss';
import { createDOM, appendChildren } from '~/support';
import { getEnvironment } from '~/environment';
const envInstance = getEnvironment();
appendChildren(document.body, createDOM(`<div>${JSON.stringify(envInstance)}</div>`)[0]);
@@ -1,7 +1,7 @@
/*
import { playwrightRollup } from '@~local/playwright-tooling';
import { test } from '@playwright/test';
import { InternalEnvironment } from 'environment';
import { InternalEnvironment } from '~/environment';
playwrightRollup();
@@ -1,4 +1,4 @@
import 'index.scss';
import '~/index.scss';
import './index.scss';
import should from 'should';
import {
@@ -20,9 +20,8 @@ import {
removeClass,
diffClass,
on,
} from 'support';
import { createDOMObserver } from 'observers';
} from '~/support';
import { createDOMObserver } from '~/observers';
type DOMContentObserverResult = {
contentChange: boolean;
@@ -1,4 +1,4 @@
import 'index.scss';
import '~/index.scss';
import './index.scss';
import './handleEnvironment';
import should from 'should';
@@ -10,9 +10,10 @@ import {
setTestResult,
waitForOrFailTest,
} from '@~local/browser-testing';
import { hasDimensions, offsetSize, WH, style } from 'support';
import { addPlugin, SizeObserverPlugin } from 'plugins';
import { createSizeObserver } from 'observers';
import type { WH } from '~/support';
import { hasDimensions, offsetSize, style } from '~/support';
import { addPlugin, SizeObserverPlugin } from '~/plugins';
import { createSizeObserver } from '~/observers';
if (!window.ResizeObserver) {
addPlugin(SizeObserverPlugin);
@@ -1,4 +1,4 @@
import 'index.scss';
import '~/index.scss';
import './index.scss';
import './handleEnvironment';
import should from 'should';
@@ -10,9 +10,9 @@ import {
setTestResult,
waitForOrFailTest,
} from '@~local/browser-testing';
import { offsetSize } from 'support';
import { createTrinsicObserver } from 'observers';
import { addPlugin, SizeObserverPlugin } from 'plugins';
import { offsetSize } from '~/support';
import { createTrinsicObserver } from '~/observers';
import { addPlugin, SizeObserverPlugin } from '~/plugins';
if (!window.ResizeObserver) {
addPlugin(SizeObserverPlugin);
@@ -1,6 +1,6 @@
import '~/index.scss';
import './index.scss';
import 'index.scss';
import { OverlayScrollbars } from 'overlayscrollbars';
import { OverlayScrollbars } from '~/overlayscrollbars';
// test with different cancel values for body

Some files were not shown because too many files have changed in this diff Show More