This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useRef, useCallback, useEffect, useState, CSSProperties } from 'react' | |
| import { createPortal } from 'react-dom' | |
| import styles from './styles.css' | |
| interface Props { | |
| anchorEl?: HTMLElement | |
| onClick?: () => void | |
| } | |
| export function TextSelectionPopover({ anchorEl, onClick }: Props) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const prevText = usePrevious(editorRef.current?.getEditor().getText()) | |
| useLayoutEffect(() => { | |
| if (!editorRef.current || !value || !prevText || !maxLength || value.length <= maxLength) return | |
| const editor = editorRef.current.getEditor() | |
| const selection = editor.getSelection() || { index: prevText.length, length: 0 } | |
| editor.setText(prevText, 'user') | |
| setTimeout(() => { | |
| const index = selection.index === prevText.length ? selection.index : selection.index - 1 | |
| editor.setSelection(index, selection.length) | |
| }, 16) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createSlice, configureStore, combineReducers } from '@reduxjs/toolkit' | |
| enum LoadingType { | |
| Pending = '/pending', | |
| Fulfilled = '/fulfilled', | |
| Rejected = '/rejected', | |
| } | |
| const loadingTypesRegExp = new RegExp(`(${LoadingType.Pending}|${LoadingType.Fulfilled}|${LoadingType.Rejected})$`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { configureStore, createAction, createSlice, combineReducers } from '@reduxjs/toolkit' | |
| import { Middleware } from 'redux' | |
| const set = createAction<{ type: string; loading: boolean }>('loadings/set') | |
| const slice = createSlice({ | |
| name: 'loadings', | |
| reducers: {}, | |
| initialState: {} as Record<string, boolean | undefined>, | |
| extraReducers: builder => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function useCurrencyFieldHandleChange<V extends string | undefined, E extends { value: V }>( | |
| fieldValue: V, | |
| onChange: OnChangeFn<E> | |
| ) { | |
| const { formatNumber } = useIntl() | |
| const ref = useRef<HTMLInputElement>(null) | |
| const [value, setValue] = useState<number>() | |
| const [selection, setSelection] = useState<[number | null, number | null] | null>(null) | |
| const getDisplayValue = useCallback((_value?: number) => (_value ? formatNumber(_value) : ''), [formatNumber]) | |
| const displayValue = useMemo(() => getDisplayValue(value), [getDisplayValue, value]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { PayloadAction } from '@reduxjs/toolkit' | |
| import { put } from 'redux-saga/effects' | |
| import { ApiError } from '@app/api/errors' | |
| import { createEvent } from '@app/utils/events' | |
| import { eventsActions } from '@app/state/modules/events' | |
| export function safeSaga<T extends PayloadAction<any>>(saga: (action: T) => Generator) { | |
| return function* (action: T) { | |
| try { | |
| yield put({ type: `${action.type}_START`, payload: action.payload }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| var INTERVAL = 10 | |
| // год, месяц (0-11), день | |
| var END_DATE = new Date(2021, 11, 20, 12, 00) | |
| var d, h, m, s, ms | |
| var countdown = document.getElementById('countdown') | |
| function getCountdown() { | |
| var now = new Date().getTime() | |
| var distance = END_DATE - now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const transliterate = (s: string) => { | |
| const map = [ | |
| ['а', 'a'], | |
| ['А', 'A'], | |
| ['б', 'b'], | |
| ['Б', 'B'], | |
| ['в', 'v'], | |
| ['В', 'V'], | |
| ['г', 'g'], | |
| ['Г', 'G'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EmailObfuscator { | |
| encodeEmail(email: string) { | |
| const key = this.getRandomCode(33, 330) | |
| let encodedString = key.toString(16) | |
| Array.from(email).forEach(item => encodedString += (item.charCodeAt(0) ^ key).toString(16)) | |
| return encodedString | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import AOS from 'aos' | |
| import { useRouter } from 'client/scenes/@hooks/router' | |
| import { useCallback, useEffect } from 'react' | |
| export function useAnimation() { | |
| const { location: { pathname } } = useRouter() | |
| const initAnimation = useCallback((cb: () => void) => { | |
| const images = Array.from(document.images).filter(item => item.getAttribute('data-aos-img')) | |
| const imgCount = images.length |
NewerOlder