Renamed nullable utils into isDefined and isUndefinedOrNull (#4402)
* Renamed nullable utils into isDefined and isUndefinedOrNull
This commit is contained in:
@ -5,7 +5,7 @@ import { Key } from 'ts-key-enum';
|
||||
|
||||
import { Button } from '@/ui/input/button/components/Button';
|
||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { DialogHotkeyScope } from '../types/DialogHotkeyScope';
|
||||
|
||||
@ -105,7 +105,7 @@ export const Dialog = ({
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if (isNonNullable(confirmButton)) {
|
||||
if (isDefined(confirmButton)) {
|
||||
confirmButton?.onClick?.(event);
|
||||
closeSnackbar();
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import {
|
||||
ProgressBarControls,
|
||||
} from '@/ui/feedback/progress-bar/components/ProgressBar';
|
||||
import { RGBA } from '@/ui/theme/constants/Rgba';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { usePausableTimeout } from '../hooks/usePausableTimeout';
|
||||
|
||||
@ -132,7 +132,7 @@ export const SnackBar = ({
|
||||
);
|
||||
|
||||
const icon = useMemo(() => {
|
||||
if (isNonNullable(iconComponent)) {
|
||||
if (isDefined(iconComponent)) {
|
||||
return iconComponent;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const usePausableTimeout = (callback: () => void, delay: number) => {
|
||||
// eslint-disable-next-line @nx/workspace-no-state-useref
|
||||
@ -13,7 +13,7 @@ export const usePausableTimeout = (callback: () => void, delay: number) => {
|
||||
const timeoutId = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
const tick = () => {
|
||||
if (isNonNullable(savedCallback.current)) {
|
||||
if (isDefined(savedCallback.current)) {
|
||||
savedCallback.current();
|
||||
}
|
||||
};
|
||||
@ -33,7 +33,7 @@ export const usePausableTimeout = (callback: () => void, delay: number) => {
|
||||
if (delay !== null) {
|
||||
startTimeout();
|
||||
return () => {
|
||||
if (isNonNullable(timeoutId.current)) {
|
||||
if (isDefined(timeoutId.current)) {
|
||||
clearTimeout(timeoutId.current);
|
||||
}
|
||||
};
|
||||
@ -41,7 +41,7 @@ export const usePausableTimeout = (callback: () => void, delay: number) => {
|
||||
}, [delay, startTimeout]);
|
||||
|
||||
const pauseTimeout = () => {
|
||||
if (isNonNullable(timeoutId.current)) {
|
||||
if (isDefined(timeoutId.current)) {
|
||||
clearTimeout(timeoutId.current);
|
||||
}
|
||||
const elapsedTime = Date.now() - startTime.current;
|
||||
|
||||
@ -7,7 +7,7 @@ import { SETTINGS_FIELD_CURRENCY_CODES } from '@/settings/data-model/constants/S
|
||||
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
|
||||
import { CurrencyPickerDropdownButton } from '@/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton';
|
||||
import { TEXT_INPUT_STYLE } from '@/ui/theme/constants/TextInputStyle';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const StyledInput = styled.input`
|
||||
margin: 0;
|
||||
@ -118,7 +118,7 @@ export const CurrencyInput = ({
|
||||
|
||||
useEffect(() => {
|
||||
const currency = currencies.find(({ value }) => value === currencyCode);
|
||||
if (isNonNullable(currency)) {
|
||||
if (isDefined(currency)) {
|
||||
setInternalCurrency(currency);
|
||||
}
|
||||
}, [currencies, currencyCode]);
|
||||
|
||||
@ -5,7 +5,7 @@ import { Key } from 'ts-key-enum';
|
||||
import { FieldDoubleText } from '@/object-record/record-field/types/FieldDoubleText';
|
||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { StyledInput } from './TextInput';
|
||||
|
||||
@ -147,7 +147,7 @@ export const DoubleTextInput = ({
|
||||
secondValue: secondInternalValue,
|
||||
});
|
||||
},
|
||||
enabled: isNonNullable(onClickOutside),
|
||||
enabled: isDefined(onClickOutside),
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@ -4,7 +4,7 @@ import styled from '@emotion/styled';
|
||||
|
||||
import { useRegisterInputEvents } from '@/object-record/record-field/meta-types/input/hooks/useRegisterInputEvents';
|
||||
import { TEXT_INPUT_STYLE } from '@/ui/theme/constants/TextInputStyle';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export type TextAreaInputProps = {
|
||||
disabled?: boolean;
|
||||
@ -56,7 +56,7 @@ export const TextAreaInput = ({
|
||||
const wrapperRef = useRef<HTMLTextAreaElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (isNonNullable(wrapperRef.current)) {
|
||||
if (isDefined(wrapperRef.current)) {
|
||||
wrapperRef.current.setSelectionRange(
|
||||
wrapperRef.current.value.length,
|
||||
wrapperRef.current.value.length,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { ButtonPosition, ButtonProps } from './Button';
|
||||
|
||||
@ -41,15 +41,15 @@ export const ButtonGroup = ({
|
||||
|
||||
const additionalProps: any = { position, variant, accent, size };
|
||||
|
||||
if (isNonNullable(variant)) {
|
||||
if (isDefined(variant)) {
|
||||
additionalProps.variant = variant;
|
||||
}
|
||||
|
||||
if (isNonNullable(accent)) {
|
||||
if (isDefined(accent)) {
|
||||
additionalProps.variant = variant;
|
||||
}
|
||||
|
||||
if (isNonNullable(size)) {
|
||||
if (isDefined(size)) {
|
||||
additionalProps.size = size;
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { FloatingButtonPosition, FloatingButtonProps } from './FloatingButton';
|
||||
|
||||
@ -42,7 +42,7 @@ export const FloatingButtonGroup = ({
|
||||
applyBlur: false,
|
||||
};
|
||||
|
||||
if (isNonNullable(size)) {
|
||||
if (isDefined(size)) {
|
||||
additionalProps.size = size;
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
IconX,
|
||||
} from '@/ui/display/icon';
|
||||
import { Button } from '@/ui/input/button/components/Button';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
display: flex;
|
||||
@ -133,10 +133,7 @@ export const ImageInput = ({
|
||||
ref={hiddenFileInput}
|
||||
accept="image/jpeg, image/png, image/gif" // to desired specification
|
||||
onChange={(event) => {
|
||||
if (
|
||||
isNonNullable(onUpload) &&
|
||||
isNonNullable(event.target.files)
|
||||
) {
|
||||
if (isDefined(onUpload) && isDefined(event.target.files)) {
|
||||
onUpload(event.target.files[0]);
|
||||
}
|
||||
}}
|
||||
|
||||
@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import { motion } from 'framer-motion';
|
||||
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export type ToggleSize = 'small' | 'medium';
|
||||
|
||||
@ -58,7 +58,7 @@ export const Toggle = ({
|
||||
const handleChange = () => {
|
||||
setIsOn(!isOn);
|
||||
|
||||
if (isNonNullable(onChange)) {
|
||||
if (isDefined(onChange)) {
|
||||
onChange(!isOn);
|
||||
}
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@ import { CurrencyCode } from '@/object-record/record-field/types/CurrencyCode';
|
||||
import { IconChevronDown } from '@/ui/display/icon';
|
||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { CurrencyPickerHotkeyScope } from '../types/CurrencyPickerHotkeyScope';
|
||||
|
||||
@ -77,7 +77,7 @@ export const CurrencyPickerDropdownButton = ({
|
||||
|
||||
useEffect(() => {
|
||||
const currency = currencies.find(({ value }) => value === valueCode);
|
||||
if (isNonNullable(currency)) {
|
||||
if (isDefined(currency)) {
|
||||
setSelectedCurrency(currency);
|
||||
}
|
||||
}, [valueCode, currencies]);
|
||||
|
||||
@ -9,7 +9,7 @@ import { CountryCallingCode } from 'libphonenumber-js';
|
||||
import { IconChevronDown, IconWorld } from '@/ui/display/icon';
|
||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { CountryPickerHotkeyScope } from '../types/CountryPickerHotkeyScope';
|
||||
|
||||
@ -113,7 +113,7 @@ export const CountryPickerDropdownButton = ({
|
||||
|
||||
useEffect(() => {
|
||||
const country = countries.find(({ countryCode }) => countryCode === value);
|
||||
if (isNonNullable(country)) {
|
||||
if (isDefined(country)) {
|
||||
setSelectedCountry(country);
|
||||
}
|
||||
}, [countries, value]);
|
||||
|
||||
@ -14,7 +14,7 @@ import { HotkeyEffect } from '@/ui/utilities/hotkey/components/HotkeyEffect';
|
||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
|
||||
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { useDropdown } from '../hooks/useDropdown';
|
||||
import { useInternalHotkeyScopeManagement } from '../hooks/useInternalHotkeyScopeManagement';
|
||||
@ -60,11 +60,11 @@ export const Dropdown = ({
|
||||
useDropdown(dropdownId);
|
||||
const offsetMiddlewares = [];
|
||||
|
||||
if (isNonNullable(dropdownOffset.x)) {
|
||||
if (isDefined(dropdownOffset.x)) {
|
||||
offsetMiddlewares.push(offset({ crossAxis: dropdownOffset.x }));
|
||||
}
|
||||
|
||||
if (isNonNullable(dropdownOffset.y)) {
|
||||
if (isDefined(dropdownOffset.y)) {
|
||||
offsetMiddlewares.push(offset({ mainAxis: dropdownOffset.y }));
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { useRecoilState } from 'recoil';
|
||||
import { useDropdownStates } from '@/ui/layout/dropdown/hooks/internal/useDropdownStates';
|
||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||
import { getScopeIdOrUndefinedFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdOrUndefinedFromComponentId';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const useDropdown = (dropdownId?: string) => {
|
||||
const {
|
||||
@ -36,7 +36,7 @@ export const useDropdown = (dropdownId?: string) => {
|
||||
|
||||
const openDropdown = () => {
|
||||
setIsDropdownOpen(true);
|
||||
if (isNonNullable(dropdownHotkeyScope)) {
|
||||
if (isDefined(dropdownHotkeyScope)) {
|
||||
setHotkeyScopeAndMemorizePreviousScope(
|
||||
dropdownHotkeyScope.scope,
|
||||
dropdownHotkeyScope.customScopes,
|
||||
|
||||
@ -10,7 +10,7 @@ import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { useClickOutsideListener } from '@/ui/utilities/pointer-event/hooks/useClickOutsideListener';
|
||||
import { ClickOutsideMode } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
|
||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { useRightDrawer } from '../hooks/useRightDrawer';
|
||||
import { isRightDrawerExpandedState } from '../states/isRightDrawerExpandedState';
|
||||
@ -84,7 +84,7 @@ export const RightDrawer = () => {
|
||||
: theme.rightDrawerWidth
|
||||
: '0';
|
||||
|
||||
if (!isNonNullable(rightDrawerPage)) {
|
||||
if (!isDefined(rightDrawerPage)) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import { useSelectableListHotKeys } from '@/ui/layout/selectable-list/hooks/inte
|
||||
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
|
||||
import { SelectableListScope } from '@/ui/layout/selectable-list/scopes/SelectableListScope';
|
||||
import { arrayToChunks } from '~/utils/array/arrayToChunks';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
type SelectableListProps = {
|
||||
children: ReactNode;
|
||||
@ -40,11 +40,11 @@ export const SelectableList = ({
|
||||
);
|
||||
}
|
||||
|
||||
if (isNonNullable(selectableItemIdMatrix)) {
|
||||
if (isDefined(selectableItemIdMatrix)) {
|
||||
setSelectableItemIds(selectableItemIdMatrix);
|
||||
}
|
||||
|
||||
if (isNonNullable(selectableItemIdArray)) {
|
||||
if (isDefined(selectableItemIdArray)) {
|
||||
setSelectableItemIds(arrayToChunks(selectableItemIdArray, 1));
|
||||
}
|
||||
}, [selectableItemIdArray, selectableItemIdMatrix, setSelectableItemIds]);
|
||||
|
||||
@ -8,7 +8,7 @@ import {
|
||||
beautifyExactDateTime,
|
||||
beautifyPastDateRelativeToNow,
|
||||
} from '~/utils/date-utils';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
type ShowPageSummaryCardProps = {
|
||||
avatarPlaceholder: string;
|
||||
@ -86,7 +86,7 @@ export const ShowPageSummaryCard = ({
|
||||
const inputFileRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const onFileChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
if (isNonNullable(e.target.files)) onUploadPicture?.(e.target.files[0]);
|
||||
if (isDefined(e.target.files)) onUploadPicture?.(e.target.files[0]);
|
||||
};
|
||||
|
||||
const handleAvatarClick = () => {
|
||||
|
||||
@ -8,7 +8,7 @@ import { IconComponent } from '@/ui/display/icon/types/IconComponent';
|
||||
import { isNavigationDrawerOpenState } from '@/ui/navigation/states/isNavigationDrawerOpenState';
|
||||
import { MOBILE_VIEWPORT } from '@/ui/theme/constants/MobileViewport';
|
||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export type NavigationDrawerItemProps = {
|
||||
className?: string;
|
||||
@ -148,7 +148,7 @@ export const NavigationDrawerItem = ({
|
||||
setIsNavigationDrawerOpen(false);
|
||||
}
|
||||
|
||||
if (isNonNullable(onClick)) {
|
||||
if (isDefined(onClick)) {
|
||||
onClick();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import { ColorScheme } from '@/workspace-member/types/WorkspaceMember';
|
||||
import { isNullable } from '~/utils/isNullable';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
export const useSystemColorScheme = (): ColorScheme => {
|
||||
const mediaQuery = useMemo(
|
||||
@ -14,7 +14,7 @@ export const useSystemColorScheme = (): ColorScheme => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (isNullable(window.matchMedia)) {
|
||||
if (isUndefinedOrNull(window.matchMedia)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ReactNode, useLayoutEffect, useRef, useState } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
type ComputeNodeDimensionsProps = {
|
||||
children: (
|
||||
@ -34,7 +34,7 @@ export const ComputeNodeDimensions = ({
|
||||
return;
|
||||
}
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
if (isNonNullable(nodeWrapperRef.current)) {
|
||||
if (isDefined(nodeWrapperRef.current)) {
|
||||
setNodeDimensions({
|
||||
width: nodeWrapperRef.current.offsetWidth,
|
||||
height: nodeWrapperRef.current.offsetHeight,
|
||||
|
||||
@ -2,7 +2,7 @@ import { Options, useHotkeys } from 'react-hotkeys-hook';
|
||||
import { Keys } from 'react-hotkeys-hook/dist/types';
|
||||
import { useRecoilState } from 'recoil';
|
||||
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { pendingHotkeyState } from '../states/internal/pendingHotkeysState';
|
||||
|
||||
@ -58,7 +58,7 @@ export const useSequenceHotkeys = (
|
||||
|
||||
setPendingHotkey(null);
|
||||
|
||||
if (isNonNullable(options.preventDefault)) {
|
||||
if (isDefined(options.preventDefault)) {
|
||||
keyboardEvent.stopImmediatePropagation();
|
||||
keyboardEvent.stopPropagation();
|
||||
keyboardEvent.preventDefault();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { DEFAULT_HOTKEYS_SCOPE_CUSTOM_SCOPES } from '../constants/DefaultHotkeysScopeCustomScopes';
|
||||
import { currentHotkeyScopeState } from '../states/internal/currentHotkeyScopeState';
|
||||
@ -30,7 +30,7 @@ export const useSetHotkeyScope = () =>
|
||||
.getValue();
|
||||
|
||||
if (currentHotkeyScope.scope === hotkeyScopeToSet) {
|
||||
if (!isNonNullable(customScopes)) {
|
||||
if (!isDefined(customScopes)) {
|
||||
if (
|
||||
isCustomScopesEqual(
|
||||
currentHotkeyScope?.customScopes,
|
||||
|
||||
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { fireEvent, render, renderHook } from '@testing-library/react';
|
||||
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import {
|
||||
ClickOutsideMode,
|
||||
@ -48,7 +48,7 @@ describe('useListenClickOutside', () => {
|
||||
);
|
||||
|
||||
act(() => {
|
||||
if (isNonNullable(containerRef.current)) {
|
||||
if (isDefined(containerRef.current)) {
|
||||
fireEvent.mouseDown(containerRef.current);
|
||||
fireEvent.click(containerRef.current);
|
||||
}
|
||||
@ -97,7 +97,7 @@ describe('useListenClickOutsideByClassName', () => {
|
||||
|
||||
act(() => {
|
||||
const notClickableElement = container.querySelector('.will-trigger');
|
||||
if (isNonNullable(notClickableElement)) {
|
||||
if (isDefined(notClickableElement)) {
|
||||
fireEvent.mouseDown(notClickableElement);
|
||||
fireEvent.click(notClickableElement);
|
||||
}
|
||||
@ -124,7 +124,7 @@ describe('useListenClickOutsideByClassName', () => {
|
||||
|
||||
act(() => {
|
||||
const notClickableElement = container.querySelector('.wont-trigger');
|
||||
if (isNonNullable(notClickableElement)) {
|
||||
if (isDefined(notClickableElement)) {
|
||||
fireEvent.mouseDown(notClickableElement);
|
||||
fireEvent.click(notClickableElement);
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import {
|
||||
ClickOutsideMode,
|
||||
useListenClickOutsideV2,
|
||||
} from '@/ui/utilities/pointer-event/hooks/useListenClickOutsideV2';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
const containerRef = React.createRef<HTMLDivElement>();
|
||||
const nullRef = React.createRef<HTMLDivElement>();
|
||||
@ -77,7 +77,7 @@ describe('useListenClickOutsideV2', () => {
|
||||
);
|
||||
|
||||
act(() => {
|
||||
if (isNonNullable(containerRef.current)) {
|
||||
if (isDefined(containerRef.current)) {
|
||||
fireEvent.mouseDown(containerRef.current);
|
||||
fireEvent.click(containerRef.current);
|
||||
}
|
||||
@ -101,7 +101,7 @@ describe('useListenClickOutsideV2', () => {
|
||||
);
|
||||
|
||||
act(() => {
|
||||
if (isNonNullable(containerRef.current)) {
|
||||
if (isDefined(containerRef.current)) {
|
||||
fireEvent.mouseDown(containerRef.current);
|
||||
fireEvent.click(containerRef.current);
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import {
|
||||
} from '@/ui/utilities/pointer-event/hooks/useListenClickOutsideV2';
|
||||
import { ClickOutsideListenerCallback } from '@/ui/utilities/pointer-event/types/ClickOutsideListenerCallback';
|
||||
import { getScopeIdFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdFromComponentId';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const useClickOutsideListener = (componentId: string) => {
|
||||
// TODO: improve typing
|
||||
@ -67,7 +67,7 @@ export const useClickOutsideListener = (componentId: string) => {
|
||||
(callback) => callback.callbackId === callbackId,
|
||||
);
|
||||
|
||||
if (!isNonNullable(existingCallbackWithSameId)) {
|
||||
if (!isDefined(existingCallbackWithSameId)) {
|
||||
const existingCallbacksWithNewCallback = existingCallbacks.concat({
|
||||
callbackId,
|
||||
callbackFunction,
|
||||
|
||||
@ -5,7 +5,7 @@ import { RecoilRoot, useRecoilValue } from 'recoil';
|
||||
|
||||
import { useListenScroll } from '@/ui/utilities/scroll/hooks/useListenScroll';
|
||||
import { isScrollingState } from '@/ui/utilities/scroll/states/isScrollingState';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
const containerRef = React.createRef<HTMLDivElement>();
|
||||
|
||||
@ -40,7 +40,7 @@ describe('useListenScroll', () => {
|
||||
const container = document.querySelector('#container');
|
||||
|
||||
act(() => {
|
||||
if (isNonNullable(container)) fireEvent.scroll(container);
|
||||
if (isDefined(container)) fireEvent.scroll(container);
|
||||
});
|
||||
|
||||
expect(result.current.isScrolling).toBe(true);
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import { useContext } from 'react';
|
||||
|
||||
import { isNullable } from '~/utils/isNullable';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
import { ScrollWrapperContext } from '../components/ScrollWrapper';
|
||||
|
||||
export const useScrollWrapperScopedRef = () => {
|
||||
const scrollWrapperRef = useContext(ScrollWrapperContext);
|
||||
|
||||
if (isNullable(scrollWrapperRef))
|
||||
if (isUndefinedOrNull(scrollWrapperRef))
|
||||
throw new Error(
|
||||
`Using a scroll ref without a ScrollWrapper : verify that you are using a ScrollWrapper if you intended to do so.`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user