First shlink-frontend-kit iteration

This commit is contained in:
Alejandro Celaya
2023-07-31 21:36:44 +02:00
parent 5ec5396da6
commit 99ce8c9f74
102 changed files with 152 additions and 168 deletions

View File

@@ -4,9 +4,10 @@ import classNames from 'classnames';
import type { FC, ReactNode } from 'react';
import { useEffect } from 'react';
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
import { useToggle } from '../shlink-frontend-kit/src';
import { AsideMenu } from './common/AsideMenu';
import { useFeature } from './utils/features';
import { useSwipeable, useToggle } from './utils/helpers/hooks';
import { useSwipeable } from './utils/helpers/hooks';
import { useRoutesPrefix } from './utils/routesPrefix';
type MainProps = {

View File

@@ -1,4 +1,4 @@
import type { Order } from '../../src/utils/helpers/ordering';
import type { Order } from '../../shlink-frontend-kit/src';
import type { ShortUrl, ShortUrlMeta } from '../short-urls/data';
import type { Visit } from '../visits/types';

View File

@@ -4,8 +4,7 @@ import { isEmpty, pipe } from 'ramda';
import { useEffect } from 'react';
import type { InputProps } from 'reactstrap';
import { Button, DropdownItem, Input, InputGroup, UncontrolledTooltip } from 'reactstrap';
import { DropdownBtn } from '../../src/utils/DropdownBtn';
import { useToggle } from '../utils/helpers/hooks';
import { DropdownBtn, useToggle } from '../../shlink-frontend-kit/src';
import type { DomainsList } from './reducers/domainsList';
import './DomainSelector.scss';

View File

@@ -1,9 +1,6 @@
import type { FC } from 'react';
import { useEffect } from 'react';
import { Message } from '../../src/utils/Message';
import { Result } from '../../src/utils/Result';
import { SearchField } from '../../src/utils/SearchField';
import { SimpleCard } from '../../src/utils/SimpleCard';
import { Message, Result, SearchField, SimpleCard } from '../../shlink-frontend-kit/src';
import { ShlinkApiError } from '../common/ShlinkApiError';
import { DomainRow } from './DomainRow';
import type { EditDomainRedirects } from './reducers/domainRedirects';

View File

@@ -3,9 +3,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { FC } from 'react';
import { Link } from 'react-router-dom';
import { DropdownItem } from 'reactstrap';
import { RowDropdownBtn } from '../../../src/utils/RowDropdownBtn';
import { RowDropdownBtn, useToggle } from '../../../shlink-frontend-kit/src';
import { useFeature } from '../../utils/features';
import { useToggle } from '../../utils/helpers/hooks';
import { useRoutesPrefix } from '../../utils/routesPrefix';
import { DEFAULT_DOMAIN } from '../../visits/reducers/domainVisits';
import type { Domain } from '../data';

View File

@@ -8,7 +8,7 @@ import type { FC } from 'react';
import { useEffect, useState } from 'react';
import { ExternalLink } from 'react-external-link';
import { UncontrolledTooltip } from 'reactstrap';
import { useElementRef } from '../../utils/helpers/hooks';
import { useElementRef } from '../../../shlink-frontend-kit/src';
import type { MediaMatcher } from '../../utils/types';
import type { DomainStatus } from '../data';

View File

@@ -1,8 +1,8 @@
import type { FC } from 'react';
import { useState } from 'react';
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import type { InputFormGroupProps } from '../../../src/utils/forms/InputFormGroup';
import { InputFormGroup } from '../../../src/utils/forms/InputFormGroup';
import type { InputFormGroupProps } from '../../../shlink-frontend-kit/src';
import { InputFormGroup } from '../../../shlink-frontend-kit/src';
import type { ShlinkDomain } from '../../api-contract';
import { InfoTooltip } from '../../utils/components/InfoTooltip';
import { handleEventPreventingDefault, nonEmptyValueOrNull } from '../../utils/helpers';

View File

@@ -3,7 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { FC, PropsWithChildren, ReactNode } from 'react';
import { Link } from 'react-router-dom';
import { Card, CardText, CardTitle, UncontrolledTooltip } from 'reactstrap';
import { useElementRef } from '../../utils/helpers/hooks';
import { useElementRef } from '../../../shlink-frontend-kit/src';
import './HighlightCard.scss';
export type HighlightCardProps = PropsWithChildren<{

View File

@@ -5,8 +5,7 @@ import { useEffect, useMemo } from 'react';
import { ExternalLink } from 'react-external-link';
import { useLocation, useParams } from 'react-router-dom';
import { Button, Card } from 'reactstrap';
import { Message } from '../../src/utils/Message';
import { Result } from '../../src/utils/Result';
import { Message, Result } from '../../shlink-frontend-kit/src';
import { ShlinkApiError } from '../common/ShlinkApiError';
import { useGoBack } from '../utils/helpers/hooks';
import { parseQuery } from '../utils/helpers/query';

View File

@@ -8,8 +8,7 @@ import type { ChangeEvent, FC } from 'react';
import { useEffect, useState } from 'react';
import { Button, FormGroup, Input, Row } from 'reactstrap';
import type { InputType } from 'reactstrap/types/lib/Input';
import { Checkbox } from '../../src/utils/Checkbox';
import { SimpleCard } from '../../src/utils/SimpleCard';
import { Checkbox, SimpleCard } from '../../shlink-frontend-kit/src';
import type { DomainSelectorProps } from '../domains/DomainSelector';
import type { TagsSelectorProps } from '../tags/helpers/TagsSelector';
import { IconInput } from '../utils/components/IconInput';

View File

@@ -4,9 +4,8 @@ import classNames from 'classnames';
import { isEmpty, pipe } from 'ramda';
import type { FC } from 'react';
import { Button, InputGroup, Row, UncontrolledTooltip } from 'reactstrap';
import type { OrderDir } from '../../src/utils/helpers/ordering';
import { OrderingDropdown } from '../../src/utils/OrderingDropdown';
import { SearchField } from '../../src/utils/SearchField';
import type { OrderDir } from '../../shlink-frontend-kit/src';
import { OrderingDropdown, SearchField } from '../../shlink-frontend-kit/src';
import type { TagsSelectorProps } from '../tags/helpers/TagsSelector';
import { DateRangeSelector } from '../utils/dates/DateRangeSelector';
import { formatIsoDate } from '../utils/dates/helpers/date';

View File

@@ -2,9 +2,9 @@ import { pipe } from 'ramda';
import { useEffect, useState } from 'react';
import { useLocation, useParams } from 'react-router-dom';
import { Card } from 'reactstrap';
import type { OrderDir } from '../../shlink-frontend-kit/src';
import { determineOrderDir } from '../../shlink-frontend-kit/src';
import { DEFAULT_SHORT_URLS_ORDERING } from '../../src/settings/reducers/settings';
import type { OrderDir } from '../../src/utils/helpers/ordering';
import { determineOrderDir } from '../../src/utils/helpers/ordering';
import type { ShlinkShortUrlsListParams, ShlinkShortUrlsOrder } from '../api-contract';
import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
import { Topics } from '../mercure/helpers/Topics';

View File

@@ -1,7 +1,7 @@
import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Modal, ModalBody, ModalHeader } from 'reactstrap';
import { useToggle } from '../utils/helpers/hooks';
import { useToggle } from '../../shlink-frontend-kit/src';
import './UseExistingIfFoundInfoIcon.scss';
const InfoModal = ({ isOpen, toggle }: { isOpen: boolean; toggle: () => void }) => (

View File

@@ -1,4 +1,4 @@
import type { Order } from '../../../src/utils/helpers/ordering';
import type { Order } from '../../../shlink-frontend-kit/src';
import type { ShlinkVisitsSummary } from '../../api-contract';
import type { Nullable, OptionalString } from '../../utils/helpers';

View File

@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { useEffect } from 'react';
import CopyToClipboard from 'react-copy-to-clipboard';
import { Tooltip } from 'reactstrap';
import { Result } from '../../../src/utils/Result';
import { Result } from '../../../shlink-frontend-kit/src';
import { ShlinkApiError } from '../../common/ShlinkApiError';
import type { TimeoutToggle } from '../../utils/helpers/hooks';
import type { ShortUrlCreation } from '../reducers/shortUrlCreation';

View File

@@ -1,7 +1,7 @@
import { pipe } from 'ramda';
import { useEffect, useState } from 'react';
import { Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import { Result } from '../../../src/utils/Result';
import { Result } from '../../../shlink-frontend-kit/src';
import { isInvalidDeletionError } from '../../api-contract/utils';
import { ShlinkApiError } from '../../common/ShlinkApiError';
import { handleEventPreventingDefault } from '../../utils/helpers';

View File

@@ -1,8 +1,8 @@
import type { FC } from 'react';
import { useCallback } from 'react';
import { useToggle } from '../../../shlink-frontend-kit/src';
import type { ShlinkApiClient } from '../../api-contract';
import { ExportBtn } from '../../utils/components/ExportBtn';
import { useToggle } from '../../utils/helpers/hooks';
import type { ReportExporter } from '../../utils/services/ReportExporter';
import type { ShortUrl } from '../data';
import { useShortUrlsQuery } from './hooks';

View File

@@ -1,5 +1,5 @@
import type { ChangeEvent, FC, PropsWithChildren } from 'react';
import { Checkbox } from '../../../src/utils/Checkbox';
import { Checkbox } from '../../../shlink-frontend-kit/src';
import { InfoTooltip } from '../../utils/components/InfoTooltip';
type ShortUrlFormCheckboxGroupProps = PropsWithChildren<{

View File

@@ -4,8 +4,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { isBefore } from 'date-fns';
import type { FC, ReactNode } from 'react';
import { UncontrolledTooltip } from 'reactstrap';
import { useElementRef } from '../../../shlink-frontend-kit/src';
import { formatHumanFriendly, now, parseISO } from '../../utils/dates/helpers/date';
import { useElementRef } from '../../utils/helpers/hooks';
import type { ShortUrl } from '../data';
interface ShortUrlStatusProps {

View File

@@ -2,8 +2,8 @@ import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import classNames from 'classnames';
import { UncontrolledTooltip } from 'reactstrap';
import { useElementRef } from '../../../shlink-frontend-kit/src';
import { formatHumanFriendly, parseISO } from '../../utils/dates/helpers/date';
import { useElementRef } from '../../utils/helpers/hooks';
import { prettify } from '../../utils/helpers/numbers';
import type { ShortUrl } from '../data';
import { ShortUrlDetailLink } from './ShortUrlDetailLink';

View File

@@ -1,5 +1,5 @@
import { DropdownItem } from 'reactstrap';
import { DropdownBtn } from '../../../src/utils/DropdownBtn';
import { DropdownBtn } from '../../../shlink-frontend-kit/src';
import { hasValue } from '../../utils/helpers';
import type { ShortUrlsFilter } from '../data';

View File

@@ -7,8 +7,7 @@ import {
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { FC } from 'react';
import { DropdownItem } from 'reactstrap';
import { RowDropdownBtn } from '../../../src/utils/RowDropdownBtn';
import { useToggle } from '../../utils/helpers/hooks';
import { RowDropdownBtn, useToggle } from '../../../shlink-frontend-kit/src';
import type { ShortUrl, ShortUrlModalProps } from '../data';
import { ShortUrlDetailLink } from './ShortUrlDetailLink';

View File

@@ -1,7 +1,7 @@
import { isEmpty, pipe } from 'ramda';
import { useCallback, useMemo } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { orderToString, stringToOrder } from '../../../src/utils/helpers/ordering';
import { orderToString, stringToOrder } from '../../../shlink-frontend-kit/src';
import type { TagsFilteringMode } from '../../api-contract';
import type { BooleanString } from '../../utils/helpers';
import { parseOptionalBooleanToString } from '../../utils/helpers';

View File

@@ -1,6 +1,6 @@
import type { FC } from 'react';
import { DropdownItem } from 'reactstrap';
import { DropdownBtn } from '../../../../src/utils/DropdownBtn';
import { DropdownBtn } from '../../../../shlink-frontend-kit/src';
import type { QrErrorCorrection } from '../../../utils/helpers/qrCodes';
interface QrErrorCorrectionDropdownProps {

View File

@@ -1,6 +1,6 @@
import type { FC } from 'react';
import { DropdownItem } from 'reactstrap';
import { DropdownBtn } from '../../../../src/utils/DropdownBtn';
import { DropdownBtn } from '../../../../shlink-frontend-kit/src';
import type { QrCodeFormat } from '../../../utils/helpers/qrCodes';
interface QrFormatDropdownProps {

View File

@@ -2,11 +2,7 @@ import { pipe } from 'ramda';
import type { FC } from 'react';
import { useEffect, useState } from 'react';
import { Row } from 'reactstrap';
import { determineOrderDir, sortList } from '../../src/utils/helpers/ordering';
import { Message } from '../../src/utils/Message';
import { OrderingDropdown } from '../../src/utils/OrderingDropdown';
import { Result } from '../../src/utils/Result';
import { SearchField } from '../../src/utils/SearchField';
import { determineOrderDir, Message, OrderingDropdown, Result, SearchField, sortList } from '../../shlink-frontend-kit/src';
import { ShlinkApiError } from '../common/ShlinkApiError';
import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
import { Topics } from '../mercure/helpers/Topics';

View File

@@ -2,7 +2,7 @@ import { splitEvery } from 'ramda';
import type { FC } from 'react';
import { useEffect, useRef } from 'react';
import { useLocation } from 'react-router-dom';
import { SimpleCard } from '../../src/utils/SimpleCard';
import { SimpleCard } from '../../shlink-frontend-kit/src';
import { SimplePaginator } from '../utils/components/SimplePaginator';
import { useQueryState } from '../utils/helpers/hooks';
import { parseQuery } from '../utils/helpers/query';

View File

@@ -3,8 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { FC } from 'react';
import { Link } from 'react-router-dom';
import { DropdownItem } from 'reactstrap';
import { RowDropdownBtn } from '../../src/utils/RowDropdownBtn';
import { useToggle } from '../utils/helpers/hooks';
import { RowDropdownBtn, useToggle } from '../../shlink-frontend-kit/src';
import { prettify } from '../utils/helpers/numbers';
import { useRoutesPrefix } from '../utils/routesPrefix';
import type { ColorGenerator } from '../utils/services/ColorGenerator';

View File

@@ -1,4 +1,4 @@
import type { Order } from '../../../src/utils/helpers/ordering';
import type { Order } from '../../../shlink-frontend-kit/src';
import type { SimplifiedTag } from './index';
export const TAGS_ORDERABLE_FIELDS = {

View File

@@ -1,5 +1,5 @@
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import { Result } from '../../../src/utils/Result';
import { Result } from '../../../shlink-frontend-kit/src';
import { ShlinkApiError } from '../../common/ShlinkApiError';
import type { TagModalProps } from '../data';
import type { TagDeletion } from '../reducers/tagDelete';

View File

@@ -4,10 +4,9 @@ import { pipe } from 'ramda';
import { useState } from 'react';
import { HexColorPicker } from 'react-colorful';
import { Button, Input, InputGroup, Modal, ModalBody, ModalFooter, ModalHeader, Popover } from 'reactstrap';
import { Result } from '../../../src/utils/Result';
import { Result, useToggle } from '../../../shlink-frontend-kit/src';
import { ShlinkApiError } from '../../common/ShlinkApiError';
import { handleEventPreventingDefault } from '../../utils/helpers';
import { useToggle } from '../../utils/helpers/hooks';
import type { ColorGenerator } from '../../utils/services/ColorGenerator';
import type { TagModalProps } from '../data';
import type { EditTag, TagEdition } from '../reducers/tagEdit';

View File

@@ -4,7 +4,7 @@ import classNames from 'classnames';
import type { FC } from 'react';
import type { InputProps } from 'reactstrap';
import { Input } from 'reactstrap';
import { useElementRef } from '../../../src/utils/helpers/hooks';
import { useElementRef } from '../../../shlink-frontend-kit/src';
import './IconInput.scss';
type IconInputProps = InputProps & {

View File

@@ -3,7 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { Placement } from '@popperjs/core';
import type { FC, PropsWithChildren } from 'react';
import { UncontrolledTooltip } from 'reactstrap';
import { useElementRef } from '../helpers/hooks';
import { useElementRef } from '../../../shlink-frontend-kit/src';
export type InfoTooltipProps = PropsWithChildren<{
className?: string;

View File

@@ -1,5 +1,5 @@
import type { FC } from 'react';
import { DropdownBtn } from '../../../src/utils/DropdownBtn';
import { DropdownBtn } from '../../../shlink-frontend-kit/src';
import type { DateIntervalDropdownProps } from './DateIntervalDropdownItems';
import { DateIntervalDropdownItems } from './DateIntervalDropdownItems';
import { rangeOrIntervalToString } from './helpers/dateIntervals';

View File

@@ -1,6 +1,6 @@
import { useState } from 'react';
import { DropdownItem } from 'reactstrap';
import { DropdownBtn } from '../../../src/utils/DropdownBtn';
import { DropdownBtn } from '../../../shlink-frontend-kit/src';
import { useEffectExceptFirstTime } from '../helpers/hooks';
import { DateIntervalDropdownItems } from './DateIntervalDropdownItems';
import { DateRangeRow } from './DateRangeRow';

View File

@@ -2,7 +2,6 @@ import type { DependencyList, EffectCallback } from 'react';
import { useEffect, useRef, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useSwipeable as useReactSwipeable } from 'react-swipeable';
import { v4 as uuid } from 'uuid';
import { parseQuery, stringifyQuery } from './query';
const DEFAULT_DELAY = 2000;
@@ -75,17 +74,3 @@ export const useGoBack = () => {
const navigate = useNavigate();
return () => navigate(-1);
};
type ToggleResult = [boolean, () => void, () => void, () => void];
export const useToggle = (initialValue = false): ToggleResult => {
const [flag, setFlag] = useState<boolean>(initialValue);
return [flag, () => setFlag(!flag), () => setFlag(true), () => setFlag(false)];
};
export const useDomId = (): string => {
const { current: id } = useRef(`dom-${uuid()}`);
return id;
};
export const useElementRef = <T>() => useRef<T | null>(null);

View File

@@ -1,6 +1,6 @@
import { faCaretDown as caretDownIcon, faCaretUp as caretUpIcon } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { Order } from '../../../src/utils/helpers/ordering';
import type { Order } from '../../../shlink-frontend-kit/src';
interface TableOrderIconProps<T> {
currentOrder: Order<T>;

View File

@@ -7,9 +7,7 @@ import type { FC, PropsWithChildren } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
import { Button, Progress, Row } from 'reactstrap';
import { Message } from '../../src/utils/Message';
import { NavPillItem, NavPills } from '../../src/utils/NavPills';
import { Result } from '../../src/utils/Result';
import { Message, NavPillItem, NavPills, Result } from '../../shlink-frontend-kit/src';
import { ShlinkApiError } from '../common/ShlinkApiError';
import { ExportBtn } from '../utils/components/ExportBtn';
import { DateRangeSelector } from '../utils/dates/DateRangeSelector';

View File

@@ -4,9 +4,8 @@ import classNames from 'classnames';
import { min, splitEvery } from 'ramda';
import { useEffect, useMemo, useRef, useState } from 'react';
import { UncontrolledTooltip } from 'reactstrap';
import type { Order } from '../../src/utils/helpers/ordering';
import { determineOrderDir, sortList } from '../../src/utils/helpers/ordering';
import { SearchField } from '../../src/utils/SearchField';
import type { Order } from '../../shlink-frontend-kit/src';
import { determineOrderDir, SearchField, sortList } from '../../shlink-frontend-kit/src';
import { SimplePaginator } from '../utils/components/SimplePaginator';
import { Time } from '../utils/dates/Time';
import { prettify } from '../utils/helpers/numbers';

View File

@@ -23,12 +23,11 @@ import {
DropdownToggle,
UncontrolledDropdown,
} from 'reactstrap';
import { ToggleSwitch, useToggle } from '../../../shlink-frontend-kit/src';
import { HIGHLIGHTED_COLOR, MAIN_COLOR } from '../../../src/utils/theme';
import { ToggleSwitch } from '../../../src/utils/ToggleSwitch';
import { formatInternational } from '../../utils/dates/helpers/date';
import { rangeOf } from '../../utils/helpers';
import { pointerOnHover, renderChartLabel } from '../../utils/helpers/charts';
import { useToggle } from '../../utils/helpers/hooks';
import { prettify } from '../../utils/helpers/numbers';
import type { NormalizedVisit, Stats } from '../types';
import { fillTheGaps } from '../utils';

View File

@@ -1,8 +1,8 @@
import { fromPairs, pipe, reverse, sortBy, splitEvery, toLower, toPairs, type, zipObj } from 'ramda';
import type { FC, ReactNode } from 'react';
import { useState } from 'react';
import type { Order } from '../../../src/utils/helpers/ordering';
import { OrderingDropdown } from '../../../src/utils/OrderingDropdown';
import type { Order } from '../../../shlink-frontend-kit/src';
import { OrderingDropdown } from '../../../shlink-frontend-kit/src';
import { PaginationDropdown } from '../../utils/components/PaginationDropdown';
import { SimplePaginator } from '../../utils/components/SimplePaginator';
import { rangeOf } from '../../utils/helpers';

View File

@@ -2,7 +2,7 @@ import { faMapMarkedAlt as mapIcon } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { useState } from 'react';
import { Button, Dropdown, DropdownItem, DropdownMenu, UncontrolledTooltip } from 'reactstrap';
import { useDomId, useToggle } from '../../utils/helpers/hooks';
import { useDomId, useToggle } from '../../../shlink-frontend-kit/src';
import type { CityStats } from '../types';
import { MapModal } from './MapModal';
import './OpenMapModalBtn.scss';

View File

@@ -1,6 +1,6 @@
import type { DropdownItemProps } from 'reactstrap';
import { DropdownItem } from 'reactstrap';
import { DropdownBtn } from '../../../src/utils/DropdownBtn';
import { DropdownBtn } from '../../../shlink-frontend-kit/src';
import { hasValue } from '../../utils/helpers';
import type { OrphanVisitType, VisitsFilter } from '../types';