Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STTYPES-15 Provide TS definitions for claiming feature in the stripes-acq-components lib #74

Merged
merged 6 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## 2.3.0 in progress

[[STTYPES-13](https://folio-org.atlassian.net/browse/STTYPES-13)] Add actual types for `acq-components`, `components`, `core` and `smart-components`.
[STTYPES-13](https://folio-org.atlassian.net/browse/STTYPES-13) Add actual types for `acq-components`, `components`, `core` and `smart-components`.
[STTYPES-15](https://folio-org.atlassian.net/browse/STTYPES-15) Provide TS definitions for claiming feature in the `stripes-acq-components` library.

## [2.2.0](https://github.com/folio-org/stripes-types/tree/v2.2.0) (2024-10-11)

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
export const useRecordsSelect: any;
interface useRecordsSelectReturn<T> {
allRecordsSelected: boolean;
isRecordSelected: ({ item: T });
resetAllSelectedRecords: () => void;
/*
* Clear selected records with provided ids.
*/
resetSelectedRecordsByIds: (ids: string[]) => void;
/*
* Clear selected records except the ones with provided ids.
*/
resetOtherSelectedRecordsByIds: (ids: string[]) => void;
selectedRecordsLength: number;
selectedRecordsMap: Record<string, T>;
selectRecord: (record: T) => void;
toggleSelectAll: () => void;
}

export declare function useRecordsSelect<T = unknown & { id: string }>({ records }: { records: T[] }): useRecordsSelectReturn<T>;
1 change: 1 addition & 0 deletions acq-components/lib/FindRecords/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './FindRecords';
export { useRecordsSelect } from './hooks';
2 changes: 2 additions & 0 deletions acq-components/lib/claiming/components/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './menu-items';
export * from './modals';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface DelayClaimActionMenuItemProps {
disabled?: boolean;
onClick: (e?: Event) => void;
}

export declare function DelayClaimActionMenuItem(props: DelayClaimActionMenuItemProps): React.JSX.Element;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DelayClaimActionMenuItem } from './DelayClaimActionMenuItem';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface MarkUnreceivableActionMenuItemProps {
disabled?: boolean;
onClick: (e?: Event) => void;
}

export declare function MarkUnreceivableActionMenuItem(props: MarkUnreceivableActionMenuItemProps): React.JSX.Element;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { MarkUnreceivableActionMenuItem } from './MarkUnreceivableActionMenuItem';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface SendClaimActionMenuItemProps {
disabled?: boolean;
onClick: (e?: Event) => void;
}

export declare function SendClaimActionMenuItem(props: SendClaimActionMenuItemProps): React.JSX.Element;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SendClaimActionMenuItem } from './SendClaimActionMenuItem';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { DelayClaimActionMenuItem } from './DelayClaimActionMenuItem';
export { MarkUnreceivableActionMenuItem } from './MarkUnreceivableActionMenuItem';
export { SendClaimActionMenuItem } from './SendClaimActionMenuItem';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
FormProps,
FormRenderProps,
} from 'react-final-form';


interface DelayClaimsModalOwnProps {
claimsCount: number;
disabled: boolean;
message?: React.JSX.Element,
onCancel: () => void;
open: boolean;
}

type DelayClaimsModalProps<FormValues = Record<string, unknown>> =
DelayClaimsModalOwnProps &
Pick<FormProps<FormValues>, 'onSubmit'> &
Partial<FormRenderProps<FormValues>>;

export declare const DelayClaimsModal: <FormValues = Record<string, unknown>>(props: DelayClaimsModalProps<FormValues>) => React.JSX.Element;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DelayClaimsModal } from './DelayClaimsModal';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
FormProps,
FormRenderProps,
} from 'react-final-form';

interface SendClaimsModalOwnProps {
claimsCount: number;
disabled: boolean;
message?: React.JSX.Element,
onCancel: () => void;
open: boolean;
}

type SendClaimsModalProps<FormValues = Record<string, unknown>> =
SendClaimsModalOwnProps &
Pick<FormProps<FormValues>, 'onSubmit'> &
Partial<FormRenderProps<FormValues>>;

export declare const SendClaimsModal: <FormValues = Record<string, unknown>>(props: SendClaimsModalProps<FormValues>) => React.JSX.Element;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SendClaimsModal } from './SendClaimsModal';
2 changes: 2 additions & 0 deletions acq-components/lib/claiming/components/modals/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { DelayClaimsModal } from './DelayClaimsModal';
export { SendClaimsModal } from './SendClaimsModal';
2 changes: 2 additions & 0 deletions acq-components/lib/claiming/hooks/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { useClaimsDelay } from './useClaimsDelay';
export { ClaimingPieceResult, useClaimsSend } from './useClaimsSend';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useClaimsDelay } from './useClaimsDelay';
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { usePiecesStatusBatchUpdate } from '../../../hooks';

interface useClaimsDelayReturn {
isLoading: boolean;
delayClaims: ({
claimingInterval,
pieceIds,
}: {
claimingInterval: number,
pieceIds: string[],
}) => Promise<ReturnType<typeof usePiecesStatusBatchUpdate>>;
}

export declare function useClaimsDelay(): useClaimsDelayReturn;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ClaimingPieceResult, useClaimsSend } from './useClaimsSend';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
interface SendClaimsData {
claimingPieceIds: string[];
claimingInterval: number;
internalNote?: string;
externalNote?: string;
}

export interface ClaimingPieceResult {
pieceId: string;
type: 'success' | 'failure';
error?: {
code?: string;
message: string;
type?: string;
};
}

export interface SendClaimsResponse {
claimingPieceResults: ClaimingPieceResult[];
totalRecords: number;
}

interface useClaimsSendReturn {
isLoading: boolean;
sendClaims: ({ data }: { data: SendClaimsData }) => Promise<SendClaimsResponse>;
}

export declare function useClaimsSend(): useClaimsSendReturn;
3 changes: 3 additions & 0 deletions acq-components/lib/claiming/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './components';
export * from './hooks';
export * from './utils';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import dayjs from 'dayjs';

export declare function getClaimingIntervalFromDate(date: dayjs.ConfigType): number;
1 change: 1 addition & 0 deletions acq-components/lib/claiming/utils/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { getClaimingIntervalFromDate } from './getClaimingIntervalFromDate';
1 change: 1 addition & 0 deletions acq-components/lib/hooks/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './useLocations';
export * from './useModalToggle';
export * from './useOrganization';
export * from './usePaneFocus';
export * from './usePiecesStatusBatchUpdate';
export * from './useShowCallout';
export * from './useToggle';
export * from './useTranslatedCategories';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { usePiecesStatusBatchUpdate } from './usePiecesStatusBatchUpdate';
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export interface UpdatePiecesStatusData {
pieceIds: string[],
receivingStatus: ACQ.Piece.ReceivingStatus,
claimingInterval?: number,
}

interface UpdatePiecesStatusErrorResponse {
errors: Array<{
message: string;
code?: string;
}>
}

export type UpdatePiecesStatusResponse = null | UpdatePiecesStatusErrorResponse;

interface usePiecesStatusBatchUpdateReturn {
isLoading: boolean;
updatePiecesStatus: ({ data }: { data: UpdatePiecesStatusData }) => Promise<UpdatePiecesStatusResponse>;
}

export declare function usePiecesStatusBatchUpdate(): usePiecesStatusBatchUpdateReturn;
11 changes: 10 additions & 1 deletion acq-components/lib/hooks/useShowCallout/useShowCallout.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
export const useShowCallout: any;
import { CalloutContextType } from '../../../../core';

type ShowCalloutFnArgs = Omit<Parameters<CalloutContextType['sendCallout']>[0], 'message'> & {
message?: string,
messageId?: string,
};

type ShowCalloutFn = (args: ShowCalloutFnArgs) => void;

export declare function useShowCallout(): ShowCalloutFn;
1 change: 1 addition & 0 deletions acq-components/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from './AcqUnits';
export * from './AmountWithCurrencyField';
export * from './apiHooks';
export * from './BooleanFilter';
export * from './claiming';
export * from './constants';
export * from './ContributorDetails';
export * from './CountryFilter';
Expand Down
2 changes: 1 addition & 1 deletion final-form/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// targeted to stripes-final-form v7.0.0
export { default } from './lib/stripesFinalForm';
export { default, FormProps, FormRenderProps } from './lib/stripesFinalForm';
2 changes: 2 additions & 0 deletions final-form/lib/stripesFinalForm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export default function stripesFinalForm<
): (
Component: ComponentType<FormRenderProps<FormValues> & ComponentProps>
) => ComponentType<ComponentProps & Pick<FormProps<FormValues>, extractedProps>>;

export type { FormProps, FormRenderProps } from 'react-final-form';
Loading