fuck
This commit is contained in:
@@ -85,7 +85,7 @@ const rgbToHsl = ({ r, g, b }: RgbColor) => {
|
||||
return { h: hue, s: clamp01(saturation), l: clamp01(lightness) };
|
||||
};
|
||||
|
||||
export const hexToRgb = (input: string | null | undefined): (RgbColor & { hex: string }) | null => {
|
||||
export const hexToRgb = (input?: string): (RgbColor & { hex: string }) | null => {
|
||||
if (!input) return null;
|
||||
const match = HEX_COLOR_PATTERN.exec(input.trim());
|
||||
if (!match) return null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const ensureDate = (value: string | number | Date | null | undefined): Date | null => {
|
||||
const ensureDate = (value: string | number | Date | null): Date | null => {
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
@@ -12,7 +12,7 @@ interface FormatOptions {
|
||||
options?: Intl.DateTimeFormatOptions;
|
||||
}
|
||||
|
||||
export const formatDate = (value: string | number | Date | null | undefined, { fallback = '—', locale, options }: FormatOptions = {}): string => {
|
||||
export const formatDate = (value: string | number | Date | null, { fallback = '—', locale, options }: FormatOptions = {}): string => {
|
||||
const date = ensureDate(value);
|
||||
if (!date) {
|
||||
return fallback;
|
||||
@@ -20,7 +20,7 @@ export const formatDate = (value: string | number | Date | null | undefined, { f
|
||||
return date.toLocaleDateString(locale, options);
|
||||
};
|
||||
|
||||
export const formatDateTime = (value: string | number | Date | null | undefined, { fallback = '—', locale, options }: FormatOptions = {}): string => {
|
||||
export const formatDateTime = (value: string | number | Date | null, { fallback = '—', locale, options }: FormatOptions = {}): string => {
|
||||
const date = ensureDate(value);
|
||||
if (!date) {
|
||||
return fallback;
|
||||
@@ -28,7 +28,7 @@ export const formatDateTime = (value: string | number | Date | null | undefined,
|
||||
return date.toLocaleString(locale, options);
|
||||
};
|
||||
|
||||
export const toDateInputValue = (value: string | number | Date | null | undefined): string => {
|
||||
export const toDateInputValue = (value: string | number | Date | null): string => {
|
||||
const date = ensureDate(value);
|
||||
if (!date) {
|
||||
return '';
|
||||
@@ -38,7 +38,7 @@ export const toDateInputValue = (value: string | number | Date | null | undefine
|
||||
return localDate.toISOString().slice(0, 10);
|
||||
};
|
||||
|
||||
export const toIssuedTimestamp = (dateString: string | null | undefined, fallback: string | number | Date | null | undefined): string | null => {
|
||||
export const toIssuedTimestamp = (dateString: string | null, fallback: string | number | Date | null): string | null => {
|
||||
if (!dateString) {
|
||||
return null;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export const toIssuedTimestamp = (dateString: string | null | undefined, fallbac
|
||||
return Number.isNaN(candidate.getTime()) ? null : candidate.toISOString();
|
||||
};
|
||||
|
||||
export const parseDateValue = (value: string | number | Date | null | undefined): Date | null => ensureDate(value);
|
||||
export const parseDateValue = (value: string | number | Date | null): Date | null => ensureDate(value);
|
||||
|
||||
export default {
|
||||
formatDate,
|
||||
|
||||
@@ -18,12 +18,12 @@ export interface DocumentLike extends AssetManagerDocumentLike {
|
||||
|
||||
export type AssetLike = AssetManagerAssetLike;
|
||||
|
||||
export type EnsurePreviewData = (id: string | number) => Promise<DocumentLike | null | undefined>;
|
||||
export type EnsurePreviewData = (id: string | number) => Promise<DocumentLike | null>;
|
||||
export type EnsureAssetUrl = (
|
||||
id: string | number,
|
||||
asset: AssetLike,
|
||||
options?: { start?: number; limit?: number; force?: boolean },
|
||||
) => Promise<AssetLike | null | undefined>;
|
||||
) => Promise<AssetLike | null>;
|
||||
export type GetDocumentAsset = AssetManagerGetAsset;
|
||||
|
||||
interface ResolveOcrTextUrlOptions {
|
||||
@@ -33,7 +33,7 @@ interface ResolveOcrTextUrlOptions {
|
||||
ensureAssetUrl?: EnsureAssetUrl;
|
||||
}
|
||||
|
||||
const pickAsset = (doc: DocumentLike | null | undefined, getDocumentAsset?: GetDocumentAsset): AssetLike | null => {
|
||||
const pickAsset = (doc?: DocumentLike | null, getDocumentAsset?: GetDocumentAsset): AssetLike | null => {
|
||||
if (!doc || !getDocumentAsset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user