pl-fe: Remove unused exports
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
60a7865420
commit
b3db562a32
33 changed files with 13 additions and 220 deletions
|
@ -72,7 +72,6 @@ const useFollowers = (accountId: string | undefined) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
useAccountList,
|
|
||||||
useBlocks,
|
useBlocks,
|
||||||
useMutes,
|
useMutes,
|
||||||
useFollowing,
|
useFollowing,
|
||||||
|
|
|
@ -199,6 +199,5 @@ const RelativeTimestamp = injectIntl(class RelativeTimestamp extends React.Compo
|
||||||
|
|
||||||
export {
|
export {
|
||||||
dateFormatOptions,
|
dateFormatOptions,
|
||||||
timeAgoString,
|
|
||||||
RelativeTimestamp as default,
|
RelativeTimestamp as default,
|
||||||
};
|
};
|
||||||
|
|
|
@ -110,4 +110,4 @@ const SensitiveContentOverlay = React.forwardRef<HTMLDivElement, ISensitiveConte
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export { SensitiveContentOverlay as default, isMediaVisible, showOverlay };
|
export { SensitiveContentOverlay as default, isMediaVisible };
|
||||||
|
|
|
@ -60,4 +60,4 @@ const Avatar = (props: IAvatar) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { Avatar as default, AVATAR_SIZE };
|
export { Avatar as default };
|
||||||
|
|
|
@ -101,7 +101,4 @@ const Button = React.forwardRef<HTMLButtonElement, IButton>(({
|
||||||
return renderButton();
|
return renderButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
export {
|
export { Button as default };
|
||||||
Button as default,
|
|
||||||
Button,
|
|
||||||
};
|
|
||||||
|
|
|
@ -122,5 +122,4 @@ const Column = React.forwardRef<HTMLDivElement, IColumn>((props, ref): JSX.Eleme
|
||||||
export {
|
export {
|
||||||
Column as default,
|
Column as default,
|
||||||
Column,
|
Column,
|
||||||
ColumnHeader,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import throttle from 'lodash/throttle';
|
import throttle from 'lodash/throttle';
|
||||||
import React, { useRef } from 'react';
|
import React, { useRef } from 'react';
|
||||||
|
|
||||||
type Point = { x: number; y: number };
|
import { getPointerPosition } from 'pl-fe/features/video';
|
||||||
|
|
||||||
interface ISlider {
|
interface ISlider {
|
||||||
/** Value between 0 and 1. */
|
/** Value between 0 and 1. */
|
||||||
|
@ -68,56 +68,4 @@ const Slider: React.FC<ISlider> = ({ value, onChange }) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const findElementPosition = (el: HTMLElement) => {
|
|
||||||
let box;
|
|
||||||
|
|
||||||
if (el.getBoundingClientRect && el.parentNode) {
|
|
||||||
box = el.getBoundingClientRect();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!box) {
|
|
||||||
return {
|
|
||||||
left: 0,
|
|
||||||
top: 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const docEl = document.documentElement;
|
|
||||||
const body = document.body;
|
|
||||||
|
|
||||||
const clientLeft = docEl.clientLeft || body.clientLeft || 0;
|
|
||||||
const scrollLeft = window.pageXOffset || body.scrollLeft;
|
|
||||||
const left = (box.left + scrollLeft) - clientLeft;
|
|
||||||
|
|
||||||
const clientTop = docEl.clientTop || body.clientTop || 0;
|
|
||||||
const scrollTop = window.pageYOffset || body.scrollTop;
|
|
||||||
const top = (box.top + scrollTop) - clientTop;
|
|
||||||
|
|
||||||
return {
|
|
||||||
left: Math.round(left),
|
|
||||||
top: Math.round(top),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const getPointerPosition = (el: HTMLElement, event: MouseEvent & TouchEvent): Point => {
|
|
||||||
const box = findElementPosition(el);
|
|
||||||
const boxW = el.offsetWidth;
|
|
||||||
const boxH = el.offsetHeight;
|
|
||||||
const boxY = box.top;
|
|
||||||
const boxX = box.left;
|
|
||||||
|
|
||||||
let pageY = event.pageY;
|
|
||||||
let pageX = event.pageX;
|
|
||||||
|
|
||||||
if (event.changedTouches) {
|
|
||||||
pageX = event.changedTouches[0].pageX;
|
|
||||||
pageY = event.changedTouches[0].pageY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
y: Math.max(0, Math.min(1, (pageY - boxY) / boxH)),
|
|
||||||
x: Math.max(0, Math.min(1, (pageX - boxX) / boxW)),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export { Slider as default };
|
export { Slider as default };
|
||||||
|
|
|
@ -30,4 +30,4 @@ const StatProvider: React.FC<IStatProvider> = ({ children }) => {
|
||||||
|
|
||||||
const useStatContext = (): IStatContext => useContext(StatContext);
|
const useStatContext = (): IStatContext => useContext(StatContext);
|
||||||
|
|
||||||
export { StatProvider, useStatContext, IStatContext };
|
export { StatProvider, useStatContext };
|
||||||
|
|
|
@ -62,7 +62,6 @@ const findEntity = <TEntity extends Entity>(
|
||||||
|
|
||||||
export {
|
export {
|
||||||
selectCache,
|
selectCache,
|
||||||
selectList,
|
|
||||||
selectListState,
|
selectListState,
|
||||||
useListState,
|
useListState,
|
||||||
selectEntities,
|
selectEntities,
|
||||||
|
|
|
@ -88,4 +88,4 @@ const UploadButton: React.FC<IUploadButton> = ({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { UploadButton as default, onlyImages };
|
export { UploadButton as default };
|
||||||
|
|
|
@ -20,7 +20,4 @@ const validateUrl = (url: string): boolean => {
|
||||||
|
|
||||||
const LinkPlugin = (): JSX.Element => <LexicalLinkPlugin validateUrl={validateUrl} />;
|
const LinkPlugin = (): JSX.Element => <LexicalLinkPlugin validateUrl={validateUrl} />;
|
||||||
|
|
||||||
export {
|
export { LinkPlugin as default };
|
||||||
validateUrl,
|
|
||||||
LinkPlugin as default,
|
|
||||||
};
|
|
||||||
|
|
|
@ -11,4 +11,4 @@ const getTitle = (ticker: string): string => {
|
||||||
return typeof title === 'string' ? title : '';
|
return typeof title === 'string' ? title : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
export { getTitle, coinDB as default };
|
export { getTitle };
|
||||||
|
|
|
@ -236,7 +236,6 @@ const EmojiPickerDropdown: React.FC<IEmojiPickerDropdown> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
messages,
|
|
||||||
type IEmojiPickerDropdown,
|
|
||||||
EmojiPickerDropdown as default,
|
EmojiPickerDropdown as default,
|
||||||
|
type IEmojiPickerDropdown,
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,15 +45,12 @@ interface EmojiData {
|
||||||
}
|
}
|
||||||
|
|
||||||
const emojiData = data as EmojiData;
|
const emojiData = data as EmojiData;
|
||||||
const { categories, emojis, aliases, sheet } = emojiData;
|
const { emojis } = emojiData;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
type CustomEmoji,
|
type CustomEmoji,
|
||||||
type Emoji,
|
type Emoji,
|
||||||
type EmojiData,
|
type EmojiData,
|
||||||
categories,
|
|
||||||
emojis,
|
emojis,
|
||||||
aliases,
|
|
||||||
sheet,
|
|
||||||
emojiData as default,
|
emojiData as default,
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,16 +71,6 @@ const LabelInput: React.FC<ILabelInput> = ({ label, ...props }) => (
|
||||||
</LabelInputContainer>
|
</LabelInputContainer>
|
||||||
);
|
);
|
||||||
|
|
||||||
interface ILabelTextarea {
|
|
||||||
label?: React.ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
const LabelTextarea: React.FC<ILabelTextarea> = ({ label, ...props }) => (
|
|
||||||
<LabelInputContainer label={label}>
|
|
||||||
<textarea {...props} />
|
|
||||||
</LabelInputContainer>
|
|
||||||
);
|
|
||||||
|
|
||||||
interface ISimpleInput {
|
interface ISimpleInput {
|
||||||
type: string;
|
type: string;
|
||||||
label?: React.ReactNode;
|
label?: React.ReactNode;
|
||||||
|
@ -110,20 +100,6 @@ const SimpleInput: React.FC<ISimpleInput> = (props) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ICheckbox {
|
|
||||||
label?: React.ReactNode;
|
|
||||||
hint?: React.ReactNode;
|
|
||||||
name?: string;
|
|
||||||
checked?: boolean;
|
|
||||||
disabled?: boolean;
|
|
||||||
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
||||||
required?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Checkbox: React.FC<ICheckbox> = (props) => (
|
|
||||||
<SimpleInput type='checkbox' {...props} />
|
|
||||||
);
|
|
||||||
|
|
||||||
interface ISelectDropdown {
|
interface ISelectDropdown {
|
||||||
className?: string;
|
className?: string;
|
||||||
label?: React.ReactNode;
|
label?: React.ReactNode;
|
||||||
|
@ -189,25 +165,6 @@ const Mutliselect: React.FC<IMultiselect> = (props) => {
|
||||||
) : selectElem;
|
) : selectElem;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ITextInput {
|
|
||||||
name?: string;
|
|
||||||
onChange?: React.ChangeEventHandler;
|
|
||||||
label?: React.ReactNode;
|
|
||||||
hint?: React.ReactNode;
|
|
||||||
placeholder?: string;
|
|
||||||
value?: string;
|
|
||||||
autoComplete?: string;
|
|
||||||
autoCorrect?: string;
|
|
||||||
autoCapitalize?: string;
|
|
||||||
pattern?: string;
|
|
||||||
error?: boolean;
|
|
||||||
required?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TextInput: React.FC<ITextInput> = props => (
|
|
||||||
<SimpleInput type='text' {...props} />
|
|
||||||
);
|
|
||||||
|
|
||||||
const FileChooser : React.FC = (props) => (
|
const FileChooser : React.FC = (props) => (
|
||||||
<SimpleInput type='file' {...props} />
|
<SimpleInput type='file' {...props} />
|
||||||
);
|
);
|
||||||
|
@ -233,15 +190,6 @@ FileChooserLogo.defaultProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
InputContainer,
|
|
||||||
LabelInputContainer,
|
|
||||||
LabelInput,
|
|
||||||
LabelTextarea,
|
|
||||||
SimpleInput,
|
|
||||||
Checkbox,
|
|
||||||
SelectDropdown,
|
SelectDropdown,
|
||||||
Mutliselect,
|
Mutliselect,
|
||||||
TextInput,
|
|
||||||
FileChooser,
|
|
||||||
FileChooserLogo,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,8 +13,4 @@ const generateText = (length: number) => {
|
||||||
// https://stackoverflow.com/a/7228322/8811886
|
// https://stackoverflow.com/a/7228322/8811886
|
||||||
const randomIntFromInterval = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1) + min);
|
const randomIntFromInterval = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1) + min);
|
||||||
|
|
||||||
export {
|
export { generateText, randomIntFromInterval };
|
||||||
PLACEHOLDER_CHAR,
|
|
||||||
generateText,
|
|
||||||
randomIntFromInterval,
|
|
||||||
};
|
|
||||||
|
|
|
@ -87,14 +87,6 @@ const getPointerPosition = (el: HTMLElement, event: MouseEvent & TouchEvent): Po
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const fileNameFromURL = (str: string) => {
|
|
||||||
const url = new URL(str);
|
|
||||||
const pathname = url.pathname;
|
|
||||||
const index = pathname.lastIndexOf('/');
|
|
||||||
|
|
||||||
return pathname.substring(index + 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
interface IVideo {
|
interface IVideo {
|
||||||
preview?: string;
|
preview?: string;
|
||||||
src: string;
|
src: string;
|
||||||
|
@ -579,6 +571,5 @@ export {
|
||||||
formatTime,
|
formatTime,
|
||||||
findElementPosition,
|
findElementPosition,
|
||||||
getPointerPosition,
|
getPointerPosition,
|
||||||
fileNameFromURL,
|
|
||||||
Video as default,
|
Video as default,
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
groupRelationshipSchema,
|
groupRelationshipSchema,
|
||||||
groupSchema,
|
groupSchema,
|
||||||
instanceSchema,
|
instanceSchema,
|
||||||
previewCardSchema,
|
|
||||||
relationshipSchema,
|
relationshipSchema,
|
||||||
statusSchema,
|
statusSchema,
|
||||||
GroupRoles,
|
GroupRoles,
|
||||||
|
@ -13,7 +12,6 @@ import {
|
||||||
type GroupMember,
|
type GroupMember,
|
||||||
type GroupRelationship,
|
type GroupRelationship,
|
||||||
type Instance,
|
type Instance,
|
||||||
type PreviewCard,
|
|
||||||
type Relationship,
|
type Relationship,
|
||||||
type Status,
|
type Status,
|
||||||
} from 'pl-api';
|
} from 'pl-api';
|
||||||
|
@ -30,11 +28,6 @@ const buildAccount = (props: PartialDeep<Account> = {}): Account =>
|
||||||
url: `https://soapbox.test/users/${crypto.randomUUID()}`,
|
url: `https://soapbox.test/users/${crypto.randomUUID()}`,
|
||||||
}, props));
|
}, props));
|
||||||
|
|
||||||
const buildCard = (props: PartialDeep<PreviewCard> = {}): PreviewCard =>
|
|
||||||
v.parse(previewCardSchema, Object.assign({
|
|
||||||
url: 'https://soapbox.test',
|
|
||||||
}, props));
|
|
||||||
|
|
||||||
const buildGroup = (props: PartialDeep<Group> = {}): Group =>
|
const buildGroup = (props: PartialDeep<Group> = {}): Group =>
|
||||||
v.parse(groupSchema, Object.assign({
|
v.parse(groupSchema, Object.assign({
|
||||||
id: crypto.randomUUID(),
|
id: crypto.randomUUID(),
|
||||||
|
@ -72,7 +65,6 @@ const buildStatus = (props: PartialDeep<Status> = {}) =>
|
||||||
|
|
||||||
export {
|
export {
|
||||||
buildAccount,
|
buildAccount,
|
||||||
buildCard,
|
|
||||||
buildGroup,
|
buildGroup,
|
||||||
buildGroupMember,
|
buildGroupMember,
|
||||||
buildGroupRelationship,
|
buildGroupRelationship,
|
||||||
|
|
|
@ -1,26 +1,9 @@
|
||||||
import { instanceSchema } from 'pl-api';
|
import { instanceSchema } from 'pl-api';
|
||||||
import * as v from 'valibot';
|
import * as v from 'valibot';
|
||||||
|
|
||||||
import alexJson from 'pl-fe/__fixtures__/pleroma-account.json';
|
|
||||||
|
|
||||||
import { buildAccount } from './factory';
|
|
||||||
|
|
||||||
/** Store with registrations open. */
|
/** Store with registrations open. */
|
||||||
const storeOpen = { instance: v.parse(instanceSchema, { registrations: true }) };
|
const storeOpen = { instance: v.parse(instanceSchema, { registrations: true }) };
|
||||||
|
|
||||||
/** Store with registrations closed. */
|
|
||||||
const storeClosed = { instance: v.parse(instanceSchema, { registrations: false }) };
|
|
||||||
|
|
||||||
/** Store with a logged-in user. */
|
|
||||||
const storeLoggedIn = {
|
|
||||||
me: alexJson.id,
|
|
||||||
accounts: {
|
|
||||||
[alexJson.id]: buildAccount(alexJson as any),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
storeOpen,
|
storeOpen,
|
||||||
storeClosed,
|
|
||||||
storeLoggedIn,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -113,7 +113,6 @@ export {
|
||||||
mockStore,
|
mockStore,
|
||||||
applyActions,
|
applyActions,
|
||||||
rootState,
|
rootState,
|
||||||
rootReducer,
|
|
||||||
mockWindowProperty,
|
mockWindowProperty,
|
||||||
createTestStore,
|
createTestStore,
|
||||||
queryClient,
|
queryClient,
|
||||||
|
|
|
@ -221,7 +221,6 @@ const normalizePlFeConfig = (plFeConfig: Record<string, any>) => PlFeConfigRecor
|
||||||
|
|
||||||
export {
|
export {
|
||||||
PromoPanelItemRecord,
|
PromoPanelItemRecord,
|
||||||
PromoPanelRecord,
|
|
||||||
FooterItemRecord,
|
FooterItemRecord,
|
||||||
CryptoAddressRecord,
|
CryptoAddressRecord,
|
||||||
PlFeConfigRecord,
|
PlFeConfigRecord,
|
||||||
|
|
|
@ -365,6 +365,5 @@ const auth = (oldState: State = initialState, action: AnyAction) => {
|
||||||
export {
|
export {
|
||||||
AuthUserRecord,
|
AuthUserRecord,
|
||||||
ReducerRecord,
|
ReducerRecord,
|
||||||
localState,
|
|
||||||
auth as default,
|
auth as default,
|
||||||
};
|
};
|
||||||
|
|
|
@ -605,7 +605,6 @@ const compose = (state = initialState, action: ComposeAction | EventsAction | In
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ReducerCompose,
|
ReducerCompose,
|
||||||
statusToMentionsArray,
|
|
||||||
statusToMentionsAccountIdsArray,
|
statusToMentionsAccountIdsArray,
|
||||||
initialState,
|
initialState,
|
||||||
compose as default,
|
compose as default,
|
||||||
|
|
|
@ -218,8 +218,6 @@ const userLists = (state = ReducerRecord(), action: DirectoryAction | AnyAction)
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ListRecord,
|
ListRecord,
|
||||||
ReactionRecord,
|
|
||||||
ParticipationRequest,
|
|
||||||
ReducerRecord,
|
ReducerRecord,
|
||||||
userLists as default,
|
userLists as default,
|
||||||
};
|
};
|
||||||
|
|
|
@ -349,7 +349,6 @@ const makeGetStatusIds = () => createSelector([
|
||||||
export {
|
export {
|
||||||
type RemoteInstance,
|
type RemoteInstance,
|
||||||
selectAccount,
|
selectAccount,
|
||||||
selectAccounts,
|
|
||||||
selectOwnAccount,
|
selectOwnAccount,
|
||||||
makeGetAccount,
|
makeGetAccount,
|
||||||
getFilters,
|
getFilters,
|
||||||
|
@ -363,7 +362,6 @@ export {
|
||||||
makeGetReport,
|
makeGetReport,
|
||||||
makeGetOtherAccounts,
|
makeGetOtherAccounts,
|
||||||
makeGetHosts,
|
makeGetHosts,
|
||||||
RemoteInstanceRecord,
|
|
||||||
makeGetRemoteInstance,
|
makeGetRemoteInstance,
|
||||||
makeGetStatusIds,
|
makeGetStatusIds,
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,5 +55,4 @@ const tagHistory = new Settings('plfe_tag_history');
|
||||||
export {
|
export {
|
||||||
pushNotificationsSetting,
|
pushNotificationsSetting,
|
||||||
tagHistory,
|
tagHistory,
|
||||||
Settings as default,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,6 +24,5 @@ KVStore.getItemOrError = (key: string) => KVStore.getItem(key).then(value => {
|
||||||
});
|
});
|
||||||
|
|
||||||
export {
|
export {
|
||||||
KVStore,
|
|
||||||
KVStore as default,
|
KVStore as default,
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,7 +70,6 @@ export {
|
||||||
parseBaseURL,
|
parseBaseURL,
|
||||||
getLoggedInAccount,
|
getLoggedInAccount,
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
getUserToken,
|
|
||||||
getAccessToken,
|
getAccessToken,
|
||||||
getAuthUserId,
|
getAuthUserId,
|
||||||
getAuthUserUrl,
|
getAuthUserUrl,
|
||||||
|
|
|
@ -51,19 +51,6 @@ const rgbToHex = (r: number, g: number, b: number): string => {
|
||||||
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTextColor = (color: string): '#FFF' | '#333' => {
|
|
||||||
const rgbColor = hexToRgb(color);
|
|
||||||
|
|
||||||
if (!rgbColor) {
|
|
||||||
return '#333';
|
|
||||||
}
|
|
||||||
|
|
||||||
const { r, g, b } = rgbColor;
|
|
||||||
const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
||||||
|
|
||||||
return luma < 120 ? '#FFF' : '#333';
|
|
||||||
};
|
|
||||||
|
|
||||||
const lighten = (hex: string, intensity: number): string => {
|
const lighten = (hex: string, intensity: number): string => {
|
||||||
const color = hexToRgb(`#${hex}`);
|
const color = hexToRgb(`#${hex}`);
|
||||||
|
|
||||||
|
@ -124,6 +111,5 @@ const colors = (baseColor: string): TailwindColorObject => {
|
||||||
|
|
||||||
export {
|
export {
|
||||||
hexToRgb,
|
hexToRgb,
|
||||||
getTextColor,
|
|
||||||
colors as default,
|
colors as default,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,27 +1,3 @@
|
||||||
import camelCase from 'lodash/camelCase';
|
|
||||||
import startCase from 'lodash/startCase';
|
|
||||||
|
|
||||||
const toSentence = (arr: string[]) => arr
|
|
||||||
.reduce(
|
|
||||||
(prev, curr, i) => prev + curr + (i === arr.length - 2 ? ' and ' : ', '),
|
|
||||||
'',
|
|
||||||
)
|
|
||||||
.slice(0, -2);
|
|
||||||
|
|
||||||
type Errors = {
|
|
||||||
[key: string]: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const buildErrorMessage = (errors: Errors) => {
|
|
||||||
const individualErrors = Object.keys(errors).map(
|
|
||||||
(attribute) => `${startCase(camelCase(attribute))} ${toSentence(
|
|
||||||
errors[attribute],
|
|
||||||
)}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
return toSentence(individualErrors);
|
|
||||||
};
|
|
||||||
|
|
||||||
const httpErrorMessages: { code: number; name: string; description: string }[] = [
|
const httpErrorMessages: { code: number; name: string; description: string }[] = [
|
||||||
{
|
{
|
||||||
code: 100,
|
code: 100,
|
||||||
|
@ -206,4 +182,4 @@ const isNetworkError = (error: unknown): boolean =>
|
||||||
&& error.name === 'TypeError'
|
&& error.name === 'TypeError'
|
||||||
&& error.message.startsWith('Failed to fetch dynamically imported module: ');
|
&& error.message.startsWith('Failed to fetch dynamically imported module: ');
|
||||||
|
|
||||||
export { buildErrorMessage, httpErrorMessages, isNetworkError };
|
export { httpErrorMessages, isNetworkError };
|
||||||
|
|
|
@ -56,4 +56,4 @@ const getTextDirection = (text: string, { fallback = 'ltr', confidence }: GetTex
|
||||||
return isRtl(text, confidence) ? 'rtl' : 'ltr';
|
return isRtl(text, confidence) ? 'rtl' : 'ltr';
|
||||||
};
|
};
|
||||||
|
|
||||||
export { getTextDirection, isRtl };
|
export { getTextDirection };
|
||||||
|
|
|
@ -68,7 +68,6 @@ const getStatusIdsFromLinksInContent = (content: string): string[] => {
|
||||||
|
|
||||||
export {
|
export {
|
||||||
defaultMediaVisibility,
|
defaultMediaVisibility,
|
||||||
getFirstExternalLink,
|
|
||||||
shouldHaveCard,
|
shouldHaveCard,
|
||||||
hasIntegerMediaIds,
|
hasIntegerMediaIds,
|
||||||
textForScreenReader,
|
textForScreenReader,
|
||||||
|
|
|
@ -131,7 +131,6 @@ const hueShift = (hex: string, delta: number): string => {
|
||||||
export {
|
export {
|
||||||
generateAccent,
|
generateAccent,
|
||||||
generateNeutral,
|
generateNeutral,
|
||||||
colorsToCss,
|
|
||||||
generateThemeCss,
|
generateThemeCss,
|
||||||
hexToHsl,
|
hexToHsl,
|
||||||
hueShift,
|
hueShift,
|
||||||
|
|
Loading…
Reference in a new issue