diff --git a/src/utils/Message.tsx b/shlink-frontend-kit/src/block/Message.tsx similarity index 100% rename from src/utils/Message.tsx rename to shlink-frontend-kit/src/block/Message.tsx diff --git a/src/utils/Result.tsx b/shlink-frontend-kit/src/block/Result.tsx similarity index 100% rename from src/utils/Result.tsx rename to shlink-frontend-kit/src/block/Result.tsx diff --git a/src/utils/SimpleCard.tsx b/shlink-frontend-kit/src/block/SimpleCard.tsx similarity index 100% rename from src/utils/SimpleCard.tsx rename to shlink-frontend-kit/src/block/SimpleCard.tsx diff --git a/shlink-frontend-kit/src/block/index.ts b/shlink-frontend-kit/src/block/index.ts new file mode 100644 index 00000000..b075331a --- /dev/null +++ b/shlink-frontend-kit/src/block/index.ts @@ -0,0 +1,3 @@ +export * from './Message'; +export * from './Result'; +export * from './SimpleCard'; diff --git a/src/utils/BooleanControl.tsx b/shlink-frontend-kit/src/form/BooleanControl.tsx similarity index 96% rename from src/utils/BooleanControl.tsx rename to shlink-frontend-kit/src/form/BooleanControl.tsx index e99dfbe1..f5f12f4e 100644 --- a/src/utils/BooleanControl.tsx +++ b/shlink-frontend-kit/src/form/BooleanControl.tsx @@ -1,7 +1,7 @@ import classNames from 'classnames'; import { identity } from 'ramda'; import type { ChangeEvent, FC, PropsWithChildren } from 'react'; -import { useDomId } from './helpers/hooks'; +import { useDomId } from '../hooks'; export type BooleanControlProps = PropsWithChildren<{ checked?: boolean; diff --git a/src/utils/Checkbox.tsx b/shlink-frontend-kit/src/form/Checkbox.tsx similarity index 100% rename from src/utils/Checkbox.tsx rename to shlink-frontend-kit/src/form/Checkbox.tsx diff --git a/src/utils/forms/InputFormGroup.tsx b/shlink-frontend-kit/src/form/InputFormGroup.tsx similarity index 95% rename from src/utils/forms/InputFormGroup.tsx rename to shlink-frontend-kit/src/form/InputFormGroup.tsx index 97e6ccdf..e4e1ffe4 100644 --- a/src/utils/forms/InputFormGroup.tsx +++ b/shlink-frontend-kit/src/form/InputFormGroup.tsx @@ -1,6 +1,6 @@ import type { FC, PropsWithChildren } from 'react'; import type { InputType } from 'reactstrap/types/lib/Input'; -import { useDomId } from '../helpers/hooks'; +import { useDomId } from '../hooks'; import { LabeledFormGroup } from './LabeledFormGroup'; export type InputFormGroupProps = PropsWithChildren<{ diff --git a/src/utils/forms/LabeledFormGroup.tsx b/shlink-frontend-kit/src/form/LabeledFormGroup.tsx similarity index 100% rename from src/utils/forms/LabeledFormGroup.tsx rename to shlink-frontend-kit/src/form/LabeledFormGroup.tsx diff --git a/src/utils/SearchField.scss b/shlink-frontend-kit/src/form/SearchField.scss similarity index 89% rename from src/utils/SearchField.scss rename to shlink-frontend-kit/src/form/SearchField.scss index 3d8d2849..0d5fc6ff 100644 --- a/src/utils/SearchField.scss +++ b/shlink-frontend-kit/src/form/SearchField.scss @@ -1,4 +1,4 @@ -@import '../utils/mixins/vertical-align'; +@import '../../../src/utils/mixins/vertical-align'; .search-field { position: relative; diff --git a/src/utils/SearchField.tsx b/shlink-frontend-kit/src/form/SearchField.tsx similarity index 100% rename from src/utils/SearchField.tsx rename to shlink-frontend-kit/src/form/SearchField.tsx diff --git a/src/utils/ToggleSwitch.tsx b/shlink-frontend-kit/src/form/ToggleSwitch.tsx similarity index 100% rename from src/utils/ToggleSwitch.tsx rename to shlink-frontend-kit/src/form/ToggleSwitch.tsx diff --git a/shlink-frontend-kit/src/form/index.ts b/shlink-frontend-kit/src/form/index.ts new file mode 100644 index 00000000..160f856d --- /dev/null +++ b/shlink-frontend-kit/src/form/index.ts @@ -0,0 +1,5 @@ +export * from './Checkbox'; +export * from './ToggleSwitch'; +export * from './InputFormGroup'; +export * from './LabeledFormGroup'; +export * from './SearchField'; diff --git a/shlink-frontend-kit/src/hooks/index.ts b/shlink-frontend-kit/src/hooks/index.ts new file mode 100644 index 00000000..0e62687a --- /dev/null +++ b/shlink-frontend-kit/src/hooks/index.ts @@ -0,0 +1,16 @@ +import { useRef, useState } from 'react'; +import { v4 as uuid } from 'uuid'; + +type ToggleResult = [boolean, () => void, () => void, () => void]; + +export const useToggle = (initialValue = false): ToggleResult => { + const [flag, setFlag] = useState(initialValue); + return [flag, () => setFlag(!flag), () => setFlag(true), () => setFlag(false)]; +}; + +export const useDomId = (): string => { + const { current: id } = useRef(`dom-${uuid()}`); + return id; +}; + +export const useElementRef = () => useRef(null); diff --git a/shlink-frontend-kit/src/index.ts b/shlink-frontend-kit/src/index.ts new file mode 100644 index 00000000..4211c0fe --- /dev/null +++ b/shlink-frontend-kit/src/index.ts @@ -0,0 +1,5 @@ +export * from './block'; +export * from './form'; +export * from './hooks'; +export * from './navigation'; +export * from './ordering'; diff --git a/src/utils/DropdownBtn.scss b/shlink-frontend-kit/src/navigation/DropdownBtn.scss similarity index 96% rename from src/utils/DropdownBtn.scss rename to shlink-frontend-kit/src/navigation/DropdownBtn.scss index 86395a84..aca28b54 100644 --- a/src/utils/DropdownBtn.scss +++ b/shlink-frontend-kit/src/navigation/DropdownBtn.scss @@ -1,6 +1,6 @@ /* stylelint-disable no-descending-specificity */ -@import '../utils/mixins/vertical-align'; +@import '../../../src/utils/mixins/vertical-align'; .dropdown-btn__toggle.dropdown-btn__toggle { text-align: left; diff --git a/src/utils/DropdownBtn.tsx b/shlink-frontend-kit/src/navigation/DropdownBtn.tsx similarity index 96% rename from src/utils/DropdownBtn.tsx rename to shlink-frontend-kit/src/navigation/DropdownBtn.tsx index c6076a86..43f0056c 100644 --- a/src/utils/DropdownBtn.tsx +++ b/shlink-frontend-kit/src/navigation/DropdownBtn.tsx @@ -2,7 +2,7 @@ import classNames from 'classnames'; import type { FC, PropsWithChildren, ReactNode } from 'react'; import { Dropdown, DropdownMenu, DropdownToggle } from 'reactstrap'; import type { DropdownToggleProps } from 'reactstrap/types/lib/DropdownToggle'; -import { useToggle } from './helpers/hooks'; +import { useToggle } from '../hooks'; import './DropdownBtn.scss'; export type DropdownBtnProps = PropsWithChildren & { diff --git a/src/utils/NavPills.scss b/shlink-frontend-kit/src/navigation/NavPills.scss similarity index 94% rename from src/utils/NavPills.scss rename to shlink-frontend-kit/src/navigation/NavPills.scss index 95fedcd0..0ff08c18 100644 --- a/src/utils/NavPills.scss +++ b/shlink-frontend-kit/src/navigation/NavPills.scss @@ -1,4 +1,4 @@ -@import './base'; +@import '../../../src/utils/base'; .nav-pills__nav { position: sticky !important; diff --git a/src/utils/NavPills.tsx b/shlink-frontend-kit/src/navigation/NavPills.tsx similarity index 100% rename from src/utils/NavPills.tsx rename to shlink-frontend-kit/src/navigation/NavPills.tsx diff --git a/src/utils/RowDropdownBtn.tsx b/shlink-frontend-kit/src/navigation/RowDropdownBtn.tsx similarity index 100% rename from src/utils/RowDropdownBtn.tsx rename to shlink-frontend-kit/src/navigation/RowDropdownBtn.tsx diff --git a/shlink-frontend-kit/src/navigation/index.ts b/shlink-frontend-kit/src/navigation/index.ts new file mode 100644 index 00000000..5dabcc11 --- /dev/null +++ b/shlink-frontend-kit/src/navigation/index.ts @@ -0,0 +1,3 @@ +export * from './DropdownBtn'; +export * from './RowDropdownBtn'; +export * from './NavPills'; diff --git a/src/utils/OrderingDropdown.scss b/shlink-frontend-kit/src/ordering/OrderingDropdown.scss similarity index 100% rename from src/utils/OrderingDropdown.scss rename to shlink-frontend-kit/src/ordering/OrderingDropdown.scss diff --git a/src/utils/OrderingDropdown.tsx b/shlink-frontend-kit/src/ordering/OrderingDropdown.tsx similarity index 95% rename from src/utils/OrderingDropdown.tsx rename to shlink-frontend-kit/src/ordering/OrderingDropdown.tsx index f2d73d2e..f60b3a05 100644 --- a/src/utils/OrderingDropdown.tsx +++ b/shlink-frontend-kit/src/ordering/OrderingDropdown.tsx @@ -3,8 +3,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import classNames from 'classnames'; import { toPairs } from 'ramda'; import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from 'reactstrap'; -import type { Order, OrderDir } from './helpers/ordering'; -import { determineOrderDir } from './helpers/ordering'; +import type { Order, OrderDir } from './ordering'; +import { determineOrderDir } from './ordering'; import './OrderingDropdown.scss'; export interface OrderingDropdownProps { diff --git a/shlink-frontend-kit/src/ordering/index.ts b/shlink-frontend-kit/src/ordering/index.ts new file mode 100644 index 00000000..dcc4f1a1 --- /dev/null +++ b/shlink-frontend-kit/src/ordering/index.ts @@ -0,0 +1,2 @@ +export * from './ordering'; +export * from './OrderingDropdown'; diff --git a/src/utils/helpers/ordering.ts b/shlink-frontend-kit/src/ordering/ordering.ts similarity index 100% rename from src/utils/helpers/ordering.ts rename to shlink-frontend-kit/src/ordering/ordering.ts diff --git a/shlink-web-component/Main.tsx b/shlink-web-component/Main.tsx index b624e9a2..5a6238c2 100644 --- a/shlink-web-component/Main.tsx +++ b/shlink-web-component/Main.tsx @@ -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 = { diff --git a/shlink-web-component/api-contract/types.ts b/shlink-web-component/api-contract/types.ts index 7381c3e1..19946622 100644 --- a/shlink-web-component/api-contract/types.ts +++ b/shlink-web-component/api-contract/types.ts @@ -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'; diff --git a/shlink-web-component/domains/DomainSelector.tsx b/shlink-web-component/domains/DomainSelector.tsx index e84104a1..02658c8f 100644 --- a/shlink-web-component/domains/DomainSelector.tsx +++ b/shlink-web-component/domains/DomainSelector.tsx @@ -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'; diff --git a/shlink-web-component/domains/ManageDomains.tsx b/shlink-web-component/domains/ManageDomains.tsx index 1cd68352..859bf95b 100644 --- a/shlink-web-component/domains/ManageDomains.tsx +++ b/shlink-web-component/domains/ManageDomains.tsx @@ -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'; diff --git a/shlink-web-component/domains/helpers/DomainDropdown.tsx b/shlink-web-component/domains/helpers/DomainDropdown.tsx index 0db99ee8..7202c2b6 100644 --- a/shlink-web-component/domains/helpers/DomainDropdown.tsx +++ b/shlink-web-component/domains/helpers/DomainDropdown.tsx @@ -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'; diff --git a/shlink-web-component/domains/helpers/DomainStatusIcon.tsx b/shlink-web-component/domains/helpers/DomainStatusIcon.tsx index 9d7c071c..0ac700f1 100644 --- a/shlink-web-component/domains/helpers/DomainStatusIcon.tsx +++ b/shlink-web-component/domains/helpers/DomainStatusIcon.tsx @@ -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'; diff --git a/shlink-web-component/domains/helpers/EditDomainRedirectsModal.tsx b/shlink-web-component/domains/helpers/EditDomainRedirectsModal.tsx index acf1ddf4..7a9500e7 100644 --- a/shlink-web-component/domains/helpers/EditDomainRedirectsModal.tsx +++ b/shlink-web-component/domains/helpers/EditDomainRedirectsModal.tsx @@ -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'; diff --git a/shlink-web-component/overview/helpers/HighlightCard.tsx b/shlink-web-component/overview/helpers/HighlightCard.tsx index a5d391c0..32eab2bd 100644 --- a/shlink-web-component/overview/helpers/HighlightCard.tsx +++ b/shlink-web-component/overview/helpers/HighlightCard.tsx @@ -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<{ diff --git a/shlink-web-component/short-urls/EditShortUrl.tsx b/shlink-web-component/short-urls/EditShortUrl.tsx index d8271cd9..2f717a50 100644 --- a/shlink-web-component/short-urls/EditShortUrl.tsx +++ b/shlink-web-component/short-urls/EditShortUrl.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/ShortUrlForm.tsx b/shlink-web-component/short-urls/ShortUrlForm.tsx index be6021ee..430ec22e 100644 --- a/shlink-web-component/short-urls/ShortUrlForm.tsx +++ b/shlink-web-component/short-urls/ShortUrlForm.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/ShortUrlsFilteringBar.tsx b/shlink-web-component/short-urls/ShortUrlsFilteringBar.tsx index 4bd769ab..8ed5e9e8 100644 --- a/shlink-web-component/short-urls/ShortUrlsFilteringBar.tsx +++ b/shlink-web-component/short-urls/ShortUrlsFilteringBar.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/ShortUrlsList.tsx b/shlink-web-component/short-urls/ShortUrlsList.tsx index e4052a21..7073c966 100644 --- a/shlink-web-component/short-urls/ShortUrlsList.tsx +++ b/shlink-web-component/short-urls/ShortUrlsList.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/UseExistingIfFoundInfoIcon.tsx b/shlink-web-component/short-urls/UseExistingIfFoundInfoIcon.tsx index 32c8d130..5247af47 100644 --- a/shlink-web-component/short-urls/UseExistingIfFoundInfoIcon.tsx +++ b/shlink-web-component/short-urls/UseExistingIfFoundInfoIcon.tsx @@ -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 }) => ( diff --git a/shlink-web-component/short-urls/data/index.ts b/shlink-web-component/short-urls/data/index.ts index f1654a07..3bb4ce53 100644 --- a/shlink-web-component/short-urls/data/index.ts +++ b/shlink-web-component/short-urls/data/index.ts @@ -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'; diff --git a/shlink-web-component/short-urls/helpers/CreateShortUrlResult.tsx b/shlink-web-component/short-urls/helpers/CreateShortUrlResult.tsx index 4518bf61..9ee067bd 100644 --- a/shlink-web-component/short-urls/helpers/CreateShortUrlResult.tsx +++ b/shlink-web-component/short-urls/helpers/CreateShortUrlResult.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/helpers/DeleteShortUrlModal.tsx b/shlink-web-component/short-urls/helpers/DeleteShortUrlModal.tsx index 8e9ee720..22c9d447 100644 --- a/shlink-web-component/short-urls/helpers/DeleteShortUrlModal.tsx +++ b/shlink-web-component/short-urls/helpers/DeleteShortUrlModal.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/helpers/ExportShortUrlsBtn.tsx b/shlink-web-component/short-urls/helpers/ExportShortUrlsBtn.tsx index 7f5193c1..9c844729 100644 --- a/shlink-web-component/short-urls/helpers/ExportShortUrlsBtn.tsx +++ b/shlink-web-component/short-urls/helpers/ExportShortUrlsBtn.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/helpers/ShortUrlFormCheckboxGroup.tsx b/shlink-web-component/short-urls/helpers/ShortUrlFormCheckboxGroup.tsx index cb3b6e86..e13afbbb 100644 --- a/shlink-web-component/short-urls/helpers/ShortUrlFormCheckboxGroup.tsx +++ b/shlink-web-component/short-urls/helpers/ShortUrlFormCheckboxGroup.tsx @@ -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<{ diff --git a/shlink-web-component/short-urls/helpers/ShortUrlStatus.tsx b/shlink-web-component/short-urls/helpers/ShortUrlStatus.tsx index 8b8a88f0..594ef376 100644 --- a/shlink-web-component/short-urls/helpers/ShortUrlStatus.tsx +++ b/shlink-web-component/short-urls/helpers/ShortUrlStatus.tsx @@ -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 { diff --git a/shlink-web-component/short-urls/helpers/ShortUrlVisitsCount.tsx b/shlink-web-component/short-urls/helpers/ShortUrlVisitsCount.tsx index 084ca14d..3b3ad7ba 100644 --- a/shlink-web-component/short-urls/helpers/ShortUrlVisitsCount.tsx +++ b/shlink-web-component/short-urls/helpers/ShortUrlVisitsCount.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/helpers/ShortUrlsFilterDropdown.tsx b/shlink-web-component/short-urls/helpers/ShortUrlsFilterDropdown.tsx index 2a2b7d8c..5ae96c11 100644 --- a/shlink-web-component/short-urls/helpers/ShortUrlsFilterDropdown.tsx +++ b/shlink-web-component/short-urls/helpers/ShortUrlsFilterDropdown.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/helpers/ShortUrlsRowMenu.tsx b/shlink-web-component/short-urls/helpers/ShortUrlsRowMenu.tsx index 33057e3b..089e34ec 100644 --- a/shlink-web-component/short-urls/helpers/ShortUrlsRowMenu.tsx +++ b/shlink-web-component/short-urls/helpers/ShortUrlsRowMenu.tsx @@ -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'; diff --git a/shlink-web-component/short-urls/helpers/hooks.ts b/shlink-web-component/short-urls/helpers/hooks.ts index 9cf21ad8..1b766cf3 100644 --- a/shlink-web-component/short-urls/helpers/hooks.ts +++ b/shlink-web-component/short-urls/helpers/hooks.ts @@ -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'; diff --git a/shlink-web-component/short-urls/helpers/qr-codes/QrErrorCorrectionDropdown.tsx b/shlink-web-component/short-urls/helpers/qr-codes/QrErrorCorrectionDropdown.tsx index 0eb73d9a..ac3c487c 100644 --- a/shlink-web-component/short-urls/helpers/qr-codes/QrErrorCorrectionDropdown.tsx +++ b/shlink-web-component/short-urls/helpers/qr-codes/QrErrorCorrectionDropdown.tsx @@ -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 { diff --git a/shlink-web-component/short-urls/helpers/qr-codes/QrFormatDropdown.tsx b/shlink-web-component/short-urls/helpers/qr-codes/QrFormatDropdown.tsx index 526940dc..77842bff 100644 --- a/shlink-web-component/short-urls/helpers/qr-codes/QrFormatDropdown.tsx +++ b/shlink-web-component/short-urls/helpers/qr-codes/QrFormatDropdown.tsx @@ -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 { diff --git a/shlink-web-component/tags/TagsList.tsx b/shlink-web-component/tags/TagsList.tsx index 4e7c5bc1..203c8941 100644 --- a/shlink-web-component/tags/TagsList.tsx +++ b/shlink-web-component/tags/TagsList.tsx @@ -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'; diff --git a/shlink-web-component/tags/TagsTable.tsx b/shlink-web-component/tags/TagsTable.tsx index 30d33a7a..57537a07 100644 --- a/shlink-web-component/tags/TagsTable.tsx +++ b/shlink-web-component/tags/TagsTable.tsx @@ -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'; diff --git a/shlink-web-component/tags/TagsTableRow.tsx b/shlink-web-component/tags/TagsTableRow.tsx index 5c84ea7b..16e0af75 100644 --- a/shlink-web-component/tags/TagsTableRow.tsx +++ b/shlink-web-component/tags/TagsTableRow.tsx @@ -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'; diff --git a/shlink-web-component/tags/data/TagsListChildrenProps.ts b/shlink-web-component/tags/data/TagsListChildrenProps.ts index a3658887..5cf5f960 100644 --- a/shlink-web-component/tags/data/TagsListChildrenProps.ts +++ b/shlink-web-component/tags/data/TagsListChildrenProps.ts @@ -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 = { diff --git a/shlink-web-component/tags/helpers/DeleteTagConfirmModal.tsx b/shlink-web-component/tags/helpers/DeleteTagConfirmModal.tsx index 58f56d65..0d218db3 100644 --- a/shlink-web-component/tags/helpers/DeleteTagConfirmModal.tsx +++ b/shlink-web-component/tags/helpers/DeleteTagConfirmModal.tsx @@ -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'; diff --git a/shlink-web-component/tags/helpers/EditTagModal.tsx b/shlink-web-component/tags/helpers/EditTagModal.tsx index 2279e473..e835d572 100644 --- a/shlink-web-component/tags/helpers/EditTagModal.tsx +++ b/shlink-web-component/tags/helpers/EditTagModal.tsx @@ -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'; diff --git a/shlink-web-component/utils/components/IconInput.tsx b/shlink-web-component/utils/components/IconInput.tsx index f631f7f6..f11eb187 100644 --- a/shlink-web-component/utils/components/IconInput.tsx +++ b/shlink-web-component/utils/components/IconInput.tsx @@ -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 & { diff --git a/shlink-web-component/utils/components/InfoTooltip.tsx b/shlink-web-component/utils/components/InfoTooltip.tsx index 44994e3a..3e08e3a2 100644 --- a/shlink-web-component/utils/components/InfoTooltip.tsx +++ b/shlink-web-component/utils/components/InfoTooltip.tsx @@ -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; diff --git a/shlink-web-component/utils/dates/DateIntervalSelector.tsx b/shlink-web-component/utils/dates/DateIntervalSelector.tsx index 2faf46ed..fb4f88a4 100644 --- a/shlink-web-component/utils/dates/DateIntervalSelector.tsx +++ b/shlink-web-component/utils/dates/DateIntervalSelector.tsx @@ -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'; diff --git a/shlink-web-component/utils/dates/DateRangeSelector.tsx b/shlink-web-component/utils/dates/DateRangeSelector.tsx index 1235c9bc..2953340c 100644 --- a/shlink-web-component/utils/dates/DateRangeSelector.tsx +++ b/shlink-web-component/utils/dates/DateRangeSelector.tsx @@ -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'; diff --git a/shlink-web-component/utils/helpers/hooks.ts b/shlink-web-component/utils/helpers/hooks.ts index 5a7c94c6..934d0f3a 100644 --- a/shlink-web-component/utils/helpers/hooks.ts +++ b/shlink-web-component/utils/helpers/hooks.ts @@ -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(initialValue); - return [flag, () => setFlag(!flag), () => setFlag(true), () => setFlag(false)]; -}; - -export const useDomId = (): string => { - const { current: id } = useRef(`dom-${uuid()}`); - return id; -}; - -export const useElementRef = () => useRef(null); diff --git a/shlink-web-component/utils/table/TableOrderIcon.tsx b/shlink-web-component/utils/table/TableOrderIcon.tsx index b4d617ec..0c343246 100644 --- a/shlink-web-component/utils/table/TableOrderIcon.tsx +++ b/shlink-web-component/utils/table/TableOrderIcon.tsx @@ -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 { currentOrder: Order; diff --git a/shlink-web-component/visits/VisitsStats.tsx b/shlink-web-component/visits/VisitsStats.tsx index 6354e4c7..b6b3c423 100644 --- a/shlink-web-component/visits/VisitsStats.tsx +++ b/shlink-web-component/visits/VisitsStats.tsx @@ -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'; diff --git a/shlink-web-component/visits/VisitsTable.tsx b/shlink-web-component/visits/VisitsTable.tsx index 869087b5..38b79fb9 100644 --- a/shlink-web-component/visits/VisitsTable.tsx +++ b/shlink-web-component/visits/VisitsTable.tsx @@ -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'; diff --git a/shlink-web-component/visits/charts/LineChartCard.tsx b/shlink-web-component/visits/charts/LineChartCard.tsx index 5350a7c5..a2841cd2 100644 --- a/shlink-web-component/visits/charts/LineChartCard.tsx +++ b/shlink-web-component/visits/charts/LineChartCard.tsx @@ -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'; diff --git a/shlink-web-component/visits/charts/SortableBarChartCard.tsx b/shlink-web-component/visits/charts/SortableBarChartCard.tsx index 65382cb0..5fb67518 100644 --- a/shlink-web-component/visits/charts/SortableBarChartCard.tsx +++ b/shlink-web-component/visits/charts/SortableBarChartCard.tsx @@ -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'; diff --git a/shlink-web-component/visits/helpers/OpenMapModalBtn.tsx b/shlink-web-component/visits/helpers/OpenMapModalBtn.tsx index b36a2ce9..5952b17e 100644 --- a/shlink-web-component/visits/helpers/OpenMapModalBtn.tsx +++ b/shlink-web-component/visits/helpers/OpenMapModalBtn.tsx @@ -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'; diff --git a/shlink-web-component/visits/helpers/VisitsFilterDropdown.tsx b/shlink-web-component/visits/helpers/VisitsFilterDropdown.tsx index b6dfc136..47b258fb 100644 --- a/shlink-web-component/visits/helpers/VisitsFilterDropdown.tsx +++ b/shlink-web-component/visits/helpers/VisitsFilterDropdown.tsx @@ -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'; diff --git a/src/api/services/ShlinkApiClient.ts b/src/api/services/ShlinkApiClient.ts index 965e633c..1f123b56 100644 --- a/src/api/services/ShlinkApiClient.ts +++ b/src/api/services/ShlinkApiClient.ts @@ -1,4 +1,5 @@ import { isEmpty, isNil, reject } from 'ramda'; +import { orderToString } from '../../../shlink-frontend-kit/src'; import type { ShlinkApiClient as BaseShlinkApiClient, ShlinkDomainRedirects, @@ -20,7 +21,6 @@ import { isRegularNotFound, parseApiError } from '../../../shlink-web-component/ import type { ShortUrl, ShortUrlData } from '../../../shlink-web-component/short-urls/data'; import { stringifyQuery } from '../../../shlink-web-component/utils/helpers/query'; import type { HttpClient } from '../../common/services/HttpClient'; -import { orderToString } from '../../utils/helpers/ordering'; import { replaceAuthorityFromUri } from '../../utils/helpers/uri'; import type { OptionalString } from '../../utils/utils'; diff --git a/src/common/AppUpdateBanner.tsx b/src/common/AppUpdateBanner.tsx index cb97179c..c08ca057 100644 --- a/src/common/AppUpdateBanner.tsx +++ b/src/common/AppUpdateBanner.tsx @@ -2,8 +2,7 @@ import { faSyncAlt as reloadIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import type { FC, MouseEventHandler } from 'react'; import { Alert, Button } from 'reactstrap'; -import { useToggle } from '../utils/helpers/hooks'; -import { SimpleCard } from '../utils/SimpleCard'; +import { SimpleCard, useToggle } from '../../shlink-frontend-kit/src'; import './AppUpdateBanner.scss'; interface AppUpdateBannerProps { diff --git a/src/common/ErrorHandler.tsx b/src/common/ErrorHandler.tsx index f01178cc..9e2ea815 100644 --- a/src/common/ErrorHandler.tsx +++ b/src/common/ErrorHandler.tsx @@ -1,7 +1,7 @@ import type { ReactNode } from 'react'; import { Component } from 'react'; import { Button } from 'reactstrap'; -import { SimpleCard } from '../utils/SimpleCard'; +import { SimpleCard } from '../../shlink-frontend-kit/src'; interface ErrorHandlerState { hasError: boolean; diff --git a/src/common/MainHeader.tsx b/src/common/MainHeader.tsx index 3098d4ca..de7f8dd5 100644 --- a/src/common/MainHeader.tsx +++ b/src/common/MainHeader.tsx @@ -5,7 +5,7 @@ import type { FC } from 'react'; import { useEffect } from 'react'; import { Link, useLocation } from 'react-router-dom'; import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap'; -import { useToggle } from '../utils/helpers/hooks'; +import { useToggle } from '../../shlink-frontend-kit/src'; import { ShlinkLogo } from './img/ShlinkLogo'; import './MainHeader.scss'; diff --git a/src/common/NotFound.tsx b/src/common/NotFound.tsx index 2e5660cc..4982c3da 100644 --- a/src/common/NotFound.tsx +++ b/src/common/NotFound.tsx @@ -1,6 +1,6 @@ import type { FC, PropsWithChildren } from 'react'; import { Link } from 'react-router-dom'; -import { SimpleCard } from '../utils/SimpleCard'; +import { SimpleCard } from '../../shlink-frontend-kit/src'; type NotFoundProps = PropsWithChildren<{ to?: string }>; diff --git a/src/servers/CreateServer.tsx b/src/servers/CreateServer.tsx index 9de1ab6f..91c7855d 100644 --- a/src/servers/CreateServer.tsx +++ b/src/servers/CreateServer.tsx @@ -3,10 +3,10 @@ import { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Button } from 'reactstrap'; import { v4 as uuid } from 'uuid'; +import { Result, useToggle } from '../../shlink-frontend-kit/src'; import { NoMenuLayout } from '../common/NoMenuLayout'; import type { TimeoutToggle } from '../utils/helpers/hooks'; -import { useGoBack, useToggle } from '../utils/helpers/hooks'; -import { Result } from '../utils/Result'; +import { useGoBack } from '../utils/helpers/hooks'; import type { ServerData, ServersMap, ServerWithId } from './data'; import { DuplicatedServersModal } from './helpers/DuplicatedServersModal'; import type { ImportServersBtnProps } from './helpers/ImportServersBtn'; diff --git a/src/servers/DeleteServerButton.tsx b/src/servers/DeleteServerButton.tsx index 6b931bad..5aa08c93 100644 --- a/src/servers/DeleteServerButton.tsx +++ b/src/servers/DeleteServerButton.tsx @@ -1,7 +1,7 @@ import { faMinusCircle as deleteIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import type { FC, PropsWithChildren } from 'react'; -import { useToggle } from '../utils/helpers/hooks'; +import { useToggle } from '../../shlink-frontend-kit/src'; import type { ServerWithId } from './data'; import type { DeleteServerModalProps } from './DeleteServerModal'; diff --git a/src/servers/ManageServers.tsx b/src/servers/ManageServers.tsx index 378f157a..b0204e28 100644 --- a/src/servers/ManageServers.tsx +++ b/src/servers/ManageServers.tsx @@ -4,11 +4,9 @@ import type { FC } from 'react'; import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { Button, Row } from 'reactstrap'; +import { Result, SearchField, SimpleCard } from '../../shlink-frontend-kit/src'; import { NoMenuLayout } from '../common/NoMenuLayout'; import type { TimeoutToggle } from '../utils/helpers/hooks'; -import { Result } from '../utils/Result'; -import { SearchField } from '../utils/SearchField'; -import { SimpleCard } from '../utils/SimpleCard'; import type { ServersMap } from './data'; import type { ImportServersBtnProps } from './helpers/ImportServersBtn'; import type { ManageServersRowProps } from './ManageServersRow'; diff --git a/src/servers/ManageServersRowDropdown.tsx b/src/servers/ManageServersRowDropdown.tsx index 9e058df0..30f2bb9e 100644 --- a/src/servers/ManageServersRowDropdown.tsx +++ b/src/servers/ManageServersRowDropdown.tsx @@ -9,8 +9,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import type { FC } from 'react'; import { Link } from 'react-router-dom'; import { DropdownItem } from 'reactstrap'; -import { useToggle } from '../utils/helpers/hooks'; -import { RowDropdownBtn } from '../utils/RowDropdownBtn'; +import { RowDropdownBtn, useToggle } from '../../shlink-frontend-kit/src'; import type { ServerWithId } from './data'; import type { DeleteServerModalProps } from './DeleteServerModal'; diff --git a/src/servers/helpers/ImportServersBtn.tsx b/src/servers/helpers/ImportServersBtn.tsx index b6b0cf41..76f73cbc 100644 --- a/src/servers/helpers/ImportServersBtn.tsx +++ b/src/servers/helpers/ImportServersBtn.tsx @@ -4,7 +4,7 @@ import { complement, pipe } from 'ramda'; import type { ChangeEvent, FC, PropsWithChildren } from 'react'; import { useEffect, useState } from 'react'; import { Button, UncontrolledTooltip } from 'reactstrap'; -import { useElementRef, useToggle } from '../../utils/helpers/hooks'; +import { useElementRef, useToggle } from '../../../shlink-frontend-kit/src'; import type { ServerData, ServersMap } from '../data'; import type { ServersImporter } from '../services/ServersImporter'; import { DuplicatedServersModal } from './DuplicatedServersModal'; diff --git a/src/servers/helpers/ServerError.tsx b/src/servers/helpers/ServerError.tsx index 15fc2493..e5cb416f 100644 --- a/src/servers/helpers/ServerError.tsx +++ b/src/servers/helpers/ServerError.tsx @@ -1,7 +1,7 @@ import type { FC } from 'react'; import { Link } from 'react-router-dom'; +import { Message } from '../../../shlink-frontend-kit/src'; import { NoMenuLayout } from '../../common/NoMenuLayout'; -import { Message } from '../../utils/Message'; import type { SelectedServer, ServersMap } from '../data'; import { isServerWithId } from '../data'; import type { DeleteServerButtonProps } from '../DeleteServerButton'; diff --git a/src/servers/helpers/ServerForm.tsx b/src/servers/helpers/ServerForm.tsx index f06dec56..0c8cfb49 100644 --- a/src/servers/helpers/ServerForm.tsx +++ b/src/servers/helpers/ServerForm.tsx @@ -1,7 +1,6 @@ import type { FC, PropsWithChildren, ReactNode } from 'react'; import { useEffect, useState } from 'react'; -import { InputFormGroup } from '../../utils/forms/InputFormGroup'; -import { SimpleCard } from '../../utils/SimpleCard'; +import { InputFormGroup, SimpleCard } from '../../../shlink-frontend-kit/src'; import { handleEventPreventingDefault } from '../../utils/utils'; import type { ServerData } from '../data'; diff --git a/src/servers/helpers/withSelectedServer.tsx b/src/servers/helpers/withSelectedServer.tsx index 8f28b9bd..cdb93d3f 100644 --- a/src/servers/helpers/withSelectedServer.tsx +++ b/src/servers/helpers/withSelectedServer.tsx @@ -1,8 +1,8 @@ import type { FC } from 'react'; import { useEffect } from 'react'; import { useParams } from 'react-router-dom'; +import { Message } from '../../../shlink-frontend-kit/src'; import { NoMenuLayout } from '../../common/NoMenuLayout'; -import { Message } from '../../utils/Message'; import type { SelectedServer } from '../data'; import { isNotFoundServer } from '../data'; diff --git a/src/settings/RealTimeUpdatesSettings.tsx b/src/settings/RealTimeUpdatesSettings.tsx index ad7469ca..f883f133 100644 --- a/src/settings/RealTimeUpdatesSettings.tsx +++ b/src/settings/RealTimeUpdatesSettings.tsx @@ -1,11 +1,8 @@ import classNames from 'classnames'; import { FormGroup, Input } from 'reactstrap'; +import { LabeledFormGroup, SimpleCard, ToggleSwitch, useDomId } from '../../shlink-frontend-kit/src'; import type { Settings } from '../../shlink-web-component'; import { FormText } from '../utils/forms/FormText'; -import { LabeledFormGroup } from '../utils/forms/LabeledFormGroup'; -import { useDomId } from '../utils/helpers/hooks'; -import { SimpleCard } from '../utils/SimpleCard'; -import { ToggleSwitch } from '../utils/ToggleSwitch'; type RealTimeUpdatesProps = { settings: Settings; diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index cf39be3c..8971d16a 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -1,7 +1,7 @@ import type { FC, ReactNode } from 'react'; import { Navigate, Route, Routes } from 'react-router-dom'; +import { NavPillItem, NavPills } from '../../shlink-frontend-kit/src'; import { NoMenuLayout } from '../common/NoMenuLayout'; -import { NavPillItem, NavPills } from '../utils/NavPills'; const SettingsSections: FC<{ items: ReactNode[] }> = ({ items }) => ( <> diff --git a/src/settings/ShortUrlCreationSettings.tsx b/src/settings/ShortUrlCreationSettings.tsx index 736c032a..d7ee1128 100644 --- a/src/settings/ShortUrlCreationSettings.tsx +++ b/src/settings/ShortUrlCreationSettings.tsx @@ -1,11 +1,12 @@ import type { FC, ReactNode } from 'react'; import { DropdownItem, FormGroup } from 'reactstrap'; -import { DropdownBtn } from '../utils/DropdownBtn'; +import { DropdownBtn, LabeledFormGroup, SimpleCard, ToggleSwitch } from '../../shlink-frontend-kit/src'; +import type { Settings } from '../../shlink-web-component'; import { FormText } from '../utils/forms/FormText'; -import { LabeledFormGroup } from '../utils/forms/LabeledFormGroup'; -import { SimpleCard } from '../utils/SimpleCard'; -import { ToggleSwitch } from '../utils/ToggleSwitch'; -import type { Settings, ShortUrlCreationSettings as ShortUrlsSettings, TagFilteringMode } from './reducers/settings'; +import type { Defined } from '../utils/types'; + +type ShortUrlsSettings = Defined; +type TagFilteringMode = Defined; interface ShortUrlCreationProps { settings: Settings; diff --git a/src/settings/ShortUrlsListSettings.tsx b/src/settings/ShortUrlsListSettings.tsx index 5785fee0..4be09724 100644 --- a/src/settings/ShortUrlsListSettings.tsx +++ b/src/settings/ShortUrlsListSettings.tsx @@ -1,11 +1,12 @@ import type { FC } from 'react'; +import { LabeledFormGroup, OrderingDropdown, SimpleCard } from '../../shlink-frontend-kit/src'; +import type { Settings } from '../../shlink-web-component'; import { SHORT_URLS_ORDERABLE_FIELDS } from '../../shlink-web-component/short-urls/data'; -import { LabeledFormGroup } from '../utils/forms/LabeledFormGroup'; -import { OrderingDropdown } from '../utils/OrderingDropdown'; -import { SimpleCard } from '../utils/SimpleCard'; -import type { Settings, ShortUrlsListSettings as ShortUrlsSettings } from './reducers/settings'; +import type { Defined } from '../utils/types'; import { DEFAULT_SHORT_URLS_ORDERING } from './reducers/settings'; +type ShortUrlsSettings = Defined; + interface ShortUrlsListSettingsProps { settings: Settings; setShortUrlsListSettings: (settings: ShortUrlsSettings) => void; diff --git a/src/settings/TagsSettings.tsx b/src/settings/TagsSettings.tsx index aa089f93..86ade4aa 100644 --- a/src/settings/TagsSettings.tsx +++ b/src/settings/TagsSettings.tsx @@ -1,9 +1,10 @@ import type { FC } from 'react'; +import { LabeledFormGroup, OrderingDropdown, SimpleCard } from '../../shlink-frontend-kit/src'; +import type { Settings } from '../../shlink-web-component'; import { TAGS_ORDERABLE_FIELDS } from '../../shlink-web-component/tags/data/TagsListChildrenProps'; -import { LabeledFormGroup } from '../utils/forms/LabeledFormGroup'; -import { OrderingDropdown } from '../utils/OrderingDropdown'; -import { SimpleCard } from '../utils/SimpleCard'; -import type { Settings, TagsSettings as TagsSettingsOptions } from './reducers/settings'; +import type { Defined } from '../utils/types'; + +type TagsSettingsOptions = Defined; interface TagsProps { settings: Settings; diff --git a/src/settings/UserInterfaceSettings.tsx b/src/settings/UserInterfaceSettings.tsx index a2be2fdc..720a57f8 100644 --- a/src/settings/UserInterfaceSettings.tsx +++ b/src/settings/UserInterfaceSettings.tsx @@ -1,13 +1,15 @@ import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import type { FC } from 'react'; -import { SimpleCard } from '../utils/SimpleCard'; +import { SimpleCard, ToggleSwitch } from '../../shlink-frontend-kit/src'; +import type { Settings } from '../../shlink-web-component'; import type { Theme } from '../utils/theme'; import { changeThemeInMarkup } from '../utils/theme'; -import { ToggleSwitch } from '../utils/ToggleSwitch'; -import type { Settings, UiSettings } from './reducers/settings'; +import type { Defined } from '../utils/types'; import './UserInterfaceSettings.scss'; +type UiSettings = Defined; + interface UserInterfaceProps { settings: Settings; setUiSettings: (settings: UiSettings) => void; diff --git a/src/settings/VisitsSettings.tsx b/src/settings/VisitsSettings.tsx index 713c095e..27e1c7c8 100644 --- a/src/settings/VisitsSettings.tsx +++ b/src/settings/VisitsSettings.tsx @@ -1,12 +1,10 @@ import type { FC } from 'react'; import { FormGroup } from 'reactstrap'; +import { LabeledFormGroup, SimpleCard, ToggleSwitch } from '../../shlink-frontend-kit/src'; import type { Settings } from '../../shlink-web-component'; import type { DateInterval } from '../../shlink-web-component/utils/dates/helpers/dateIntervals'; import { DateIntervalSelector } from '../utils/dates/DateIntervalSelector'; import { FormText } from '../utils/forms/FormText'; -import { LabeledFormGroup } from '../utils/forms/LabeledFormGroup'; -import { SimpleCard } from '../utils/SimpleCard'; -import { ToggleSwitch } from '../utils/ToggleSwitch'; type VisitsSettingsConfig = Settings['visits']; diff --git a/src/settings/reducers/settings.ts b/src/settings/reducers/settings.ts index 51888901..7d1ed4bd 100644 --- a/src/settings/reducers/settings.ts +++ b/src/settings/reducers/settings.ts @@ -2,8 +2,9 @@ import type { PayloadAction, PrepareAction } from '@reduxjs/toolkit'; import { createSlice } from '@reduxjs/toolkit'; import { mergeDeepRight } from 'ramda'; import type { Settings } from '../../../shlink-web-component'; +import type { Defined } from '../../utils/types'; -type ShortUrlsOrder = Exclude['defaultOrdering'], undefined>; +type ShortUrlsOrder = Defined['defaultOrdering']>; export const DEFAULT_SHORT_URLS_ORDERING: ShortUrlsOrder = { field: 'dateCreated', diff --git a/src/utils/dates/DateIntervalSelector.tsx b/src/utils/dates/DateIntervalSelector.tsx index 1e8ad01e..d847dfba 100644 --- a/src/utils/dates/DateIntervalSelector.tsx +++ b/src/utils/dates/DateIntervalSelector.tsx @@ -1,10 +1,11 @@ import type { FC } from 'react'; import { DropdownItem } from 'reactstrap'; +import { DropdownBtn } from '../../../shlink-frontend-kit/src'; import type { Settings } from '../../../shlink-web-component'; import { rangeOrIntervalToString } from '../../../shlink-web-component/utils/dates/helpers/dateIntervals'; -import { DropdownBtn } from '../DropdownBtn'; +import type { Defined } from '../types'; -type DateInterval = Exclude['defaultInterval']; +type DateInterval = Defined['defaultInterval']; export interface DateIntervalSelectorProps { active?: DateInterval; diff --git a/src/utils/helpers/hooks.ts b/src/utils/helpers/hooks.ts index 9321d9d4..29ee0857 100644 --- a/src/utils/helpers/hooks.ts +++ b/src/utils/helpers/hooks.ts @@ -1,6 +1,5 @@ import { useRef, useState } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; -import { v4 as uuid } from 'uuid'; import { parseQuery } from '../../../shlink-web-component/utils/helpers/query'; const DEFAULT_DELAY = 2000; @@ -35,17 +34,3 @@ export const useParsedQuery = (): T => { const { search } = useLocation(); return parseQuery(search); }; - -type ToggleResult = [boolean, () => void, () => void, () => void]; - -export const useToggle = (initialValue = false): ToggleResult => { - const [flag, setFlag] = useState(initialValue); - return [flag, () => setFlag(!flag), () => setFlag(true), () => setFlag(false)]; -}; - -export const useDomId = (): string => { - const { current: id } = useRef(`dom-${uuid()}`); - return id; -}; - -export const useElementRef = () => useRef(null); diff --git a/src/utils/types.ts b/src/utils/types.ts new file mode 100644 index 00000000..fd8e7d22 --- /dev/null +++ b/src/utils/types.ts @@ -0,0 +1 @@ +export type Defined = Exclude; diff --git a/test/utils/Checkbox.test.tsx b/test/utils/Checkbox.test.tsx index 09c248be..27d1c56c 100644 --- a/test/utils/Checkbox.test.tsx +++ b/test/utils/Checkbox.test.tsx @@ -1,5 +1,5 @@ import { render, screen } from '@testing-library/react'; -import { Checkbox } from '../../src/utils/Checkbox'; +import { Checkbox } from '../../shlink-frontend-kit/src/form/Checkbox'; import { renderWithEvents } from '../__helpers__/setUpTest'; describe('', () => { diff --git a/test/utils/DropdownBtn.test.tsx b/test/utils/DropdownBtn.test.tsx index a3c6309e..42cb8f82 100644 --- a/test/utils/DropdownBtn.test.tsx +++ b/test/utils/DropdownBtn.test.tsx @@ -1,7 +1,7 @@ import { screen } from '@testing-library/react'; import type { PropsWithChildren } from 'react'; -import type { DropdownBtnProps } from '../../src/utils/DropdownBtn'; -import { DropdownBtn } from '../../src/utils/DropdownBtn'; +import type { DropdownBtnProps } from '../../shlink-frontend-kit/src/navigation/DropdownBtn'; +import { DropdownBtn } from '../../shlink-frontend-kit/src/navigation/DropdownBtn'; import { renderWithEvents } from '../__helpers__/setUpTest'; describe('', () => { diff --git a/test/utils/Message.test.tsx b/test/utils/Message.test.tsx index 7adbe691..3b5bb783 100644 --- a/test/utils/Message.test.tsx +++ b/test/utils/Message.test.tsx @@ -1,7 +1,7 @@ import { render, screen } from '@testing-library/react'; import type { PropsWithChildren } from 'react'; -import type { MessageProps } from '../../src/utils/Message'; -import { Message } from '../../src/utils/Message'; +import type { MessageProps } from '../../shlink-frontend-kit/src/block/Message'; +import { Message } from '../../shlink-frontend-kit/src/block/Message'; describe('', () => { const setUp = (props: PropsWithChildren = {}) => render(); diff --git a/test/utils/NavPills.test.tsx b/test/utils/NavPills.test.tsx index 63f45f9f..4718d335 100644 --- a/test/utils/NavPills.test.tsx +++ b/test/utils/NavPills.test.tsx @@ -1,7 +1,7 @@ /* eslint-disable no-console */ import { render, screen } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; -import { NavPillItem, NavPills } from '../../src/utils/NavPills'; +import { NavPillItem, NavPills } from '../../shlink-frontend-kit/src/navigation/NavPills'; describe('', () => { let originalError: typeof console.error; diff --git a/test/utils/OrderingDropdown.test.tsx b/test/utils/OrderingDropdown.test.tsx index 56ecba33..79c0b703 100644 --- a/test/utils/OrderingDropdown.test.tsx +++ b/test/utils/OrderingDropdown.test.tsx @@ -1,8 +1,8 @@ import { screen } from '@testing-library/react'; import { values } from 'ramda'; -import type { OrderDir } from '../../src/utils/helpers/ordering'; -import type { OrderingDropdownProps } from '../../src/utils/OrderingDropdown'; -import { OrderingDropdown } from '../../src/utils/OrderingDropdown'; +import type { OrderDir } from '../../shlink-frontend-kit/src/ordering/ordering'; +import type { OrderingDropdownProps } from '../../shlink-frontend-kit/src/ordering/OrderingDropdown'; +import { OrderingDropdown } from '../../shlink-frontend-kit/src/ordering/OrderingDropdown'; import { renderWithEvents } from '../__helpers__/setUpTest'; describe('', () => { diff --git a/test/utils/Result.test.tsx b/test/utils/Result.test.tsx index 92a342a6..4ff4d5d5 100644 --- a/test/utils/Result.test.tsx +++ b/test/utils/Result.test.tsx @@ -1,6 +1,6 @@ import { render, screen } from '@testing-library/react'; -import type { ResultProps, ResultType } from '../../src/utils/Result'; -import { Result } from '../../src/utils/Result'; +import type { ResultProps, ResultType } from '../../shlink-frontend-kit/src/block/Result'; +import { Result } from '../../shlink-frontend-kit/src/block/Result'; describe('', () => { const setUp = (props: ResultProps) => render(); diff --git a/test/utils/RowDropdownBtn.test.tsx b/test/utils/RowDropdownBtn.test.tsx index ae47a0ce..862f2611 100644 --- a/test/utils/RowDropdownBtn.test.tsx +++ b/test/utils/RowDropdownBtn.test.tsx @@ -1,7 +1,7 @@ import { screen } from '@testing-library/react'; import { fromPartial } from '@total-typescript/shoehorn'; -import type { DropdownBtnMenuProps } from '../../src/utils/RowDropdownBtn'; -import { RowDropdownBtn } from '../../src/utils/RowDropdownBtn'; +import type { DropdownBtnMenuProps } from '../../shlink-frontend-kit/src/navigation/RowDropdownBtn'; +import { RowDropdownBtn } from '../../shlink-frontend-kit/src/navigation/RowDropdownBtn'; import { renderWithEvents } from '../__helpers__/setUpTest'; describe('', () => { diff --git a/test/utils/SimpleCard.test.tsx b/test/utils/SimpleCard.test.tsx index b570fc28..9cce1929 100644 --- a/test/utils/SimpleCard.test.tsx +++ b/test/utils/SimpleCard.test.tsx @@ -1,5 +1,5 @@ import { render, screen } from '@testing-library/react'; -import { SimpleCard } from '../../src/utils/SimpleCard'; +import { SimpleCard } from '../../shlink-frontend-kit/src/block/SimpleCard'; describe('', () => { it('does not render title if not provided', () => { diff --git a/test/utils/dates/DateIntervalDropdownItems.test.tsx b/test/utils/dates/DateIntervalDropdownItems.test.tsx index 9937441f..e06b7930 100644 --- a/test/utils/dates/DateIntervalDropdownItems.test.tsx +++ b/test/utils/dates/DateIntervalDropdownItems.test.tsx @@ -1,8 +1,8 @@ import { screen, waitFor } from '@testing-library/react'; +import { DropdownBtn } from '../../../shlink-frontend-kit/src/navigation/DropdownBtn'; import type { DateInterval } from '../../../shlink-web-component/utils/dates/helpers/dateIntervals'; import { DATE_INTERVALS, rangeOrIntervalToString } from '../../../shlink-web-component/utils/dates/helpers/dateIntervals'; import { DateIntervalDropdownItems } from '../../../src/utils/dates/DateIntervalDropdownItems'; -import { DropdownBtn } from '../../../src/utils/DropdownBtn'; import { renderWithEvents } from '../../__helpers__/setUpTest'; describe('', () => { diff --git a/test/utils/helpers/ordering.test.ts b/test/utils/helpers/ordering.test.ts index d604ab3a..f1ce3c21 100644 --- a/test/utils/helpers/ordering.test.ts +++ b/test/utils/helpers/ordering.test.ts @@ -1,5 +1,5 @@ -import type { OrderDir } from '../../../src/utils/helpers/ordering'; -import { determineOrderDir, orderToString, stringToOrder } from '../../../src/utils/helpers/ordering'; +import type { OrderDir } from '../../../shlink-frontend-kit/src/ordering/ordering'; +import { determineOrderDir, orderToString, stringToOrder } from '../../../shlink-frontend-kit/src/ordering/ordering'; describe('ordering', () => { describe('determineOrderDir', () => { diff --git a/test/utils/table/TableOrderIcon.test.tsx b/test/utils/table/TableOrderIcon.test.tsx index 7a1dec55..a4d875ac 100644 --- a/test/utils/table/TableOrderIcon.test.tsx +++ b/test/utils/table/TableOrderIcon.test.tsx @@ -1,6 +1,6 @@ import { render } from '@testing-library/react'; import { TableOrderIcon } from '../../../shlink-web-component/utils/table/TableOrderIcon'; -import type { OrderDir } from '../../../src/utils/helpers/ordering'; +import type { OrderDir } from '../../../shlink-frontend-kit/src/ordering/ordering'; describe('', () => { const setUp = (field: string, currentDir?: OrderDir, className?: string) => render(