@janrankenhohn/react-thumbnail-list 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/index.esm.js +20936 -549
  2. package/dist/index.js +21024 -0
  3. package/dist/types/components/DropdownInput.d.ts +26 -0
  4. package/dist/types/components/EllipsisContainer.d.ts +15 -0
  5. package/dist/types/components/ImageCropper.d.ts +22 -0
  6. package/dist/types/components/ThumbnailList.d.ts +34 -0
  7. package/dist/types/components/ThumbnailListFilterTag.d.ts +12 -0
  8. package/dist/types/components/ThumbnailListFilterTags.d.ts +21 -0
  9. package/dist/types/components/ThumbnailListHeader.d.ts +19 -0
  10. package/dist/types/components/ThumbnailListHeaderSort.d.ts +17 -0
  11. package/dist/types/components/ThumbnailListItem.d.ts +11 -0
  12. package/dist/types/components/ThumbnailListItemContext.d.ts +26 -0
  13. package/dist/types/components/ThumbnailListItemInfoLabel.d.ts +5 -0
  14. package/dist/types/components/ThumbnailListItemTitle.d.ts +5 -0
  15. package/dist/types/components/ThumbnailListItemType.d.ts +9 -0
  16. package/dist/types/components/ThumbnailListMainContent.d.ts +19 -0
  17. package/dist/types/components/ThumbnailListSearchField.d.ts +8 -0
  18. package/dist/types/config/ThumbnailListConfiguration.d.ts +7 -0
  19. package/dist/types/hooks/useFilteredThumbnailListItems.d.ts +13 -0
  20. package/dist/types/hooks/usePagedThumbnailListItems.d.ts +15 -0
  21. package/dist/types/hooks/useSortedThumbnailListItems.d.ts +8 -0
  22. package/dist/types/hooks/useTagFilteredThumbnailListItems.d.ts +19 -0
  23. package/dist/types/hooks/useWithLoading.d.ts +5 -0
  24. package/dist/types/index.d.ts +1 -0
  25. package/dist/types/interfaces/ThumbnailListItemInterface.d.ts +9 -0
  26. package/dist/types/tests/mocks/MockListItems.d.ts +41 -0
  27. package/dist/types/types/AlignType.d.ts +1 -0
  28. package/dist/types/types/BreakpointType.d.ts +8 -0
  29. package/dist/types/utils/arrayHelper.d.ts +9 -0
  30. package/package.json +12 -13
  31. package/dist/index.cjs.js +0 -629
@@ -0,0 +1,26 @@
1
+ import { Breakpoint } from '@mui/material';
2
+ import { ReactNode } from 'react';
3
+ /**
4
+ * Displays a generic MUI select dropdown.
5
+ * Optinal collapses to a sort icon at a certain breakpoint
6
+ * @param props.label Select Label
7
+ * @param props.width * Width of the input field
8
+ * @param props.collapseBreakPoint * MUI breakpoint after that the select will collapse to the sort icon
9
+ * @param props.onChangeCallback * Callback function that gets triggered once a item is selected
10
+ * @param props.items * Array of items (name-value-pairs) that will be the select options
11
+ * @returns Drowpdown Input Component
12
+ */
13
+ export default function DropdownInput(props: DropdownInputProps): import("react/jsx-runtime").JSX.Element;
14
+ type DropdownInputProps = {
15
+ label: string;
16
+ width: string;
17
+ collapseBreakpoint?: Breakpoint;
18
+ defaultValue?: string;
19
+ icon?: ReactNode;
20
+ onChangeCallback: (value: string, name?: string) => void;
21
+ items: Array<{
22
+ name: string;
23
+ value: string;
24
+ }>;
25
+ };
26
+ export {};
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Creates a ellipies text with webkit css styles
4
+ * @param props lineClamp: lines till ellipses
5
+ * @returns component
6
+ */
7
+ export default function EllipsisContainer(props: EllipsisContainerProps): import("react/jsx-runtime").JSX.Element;
8
+ type EllipsisContainerProps = {
9
+ lineClamp: {
10
+ xs: number;
11
+ sm: number;
12
+ };
13
+ children: ReactNode;
14
+ };
15
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Currently UNUSED
4
+ * Can be used as parent component to crop a wrapped image
5
+ * @param props width: width for cropping
6
+ * height: height for cropping
7
+ * seperate xs and sm values for mui breakpoints
8
+ * @returns component
9
+ */
10
+ export default function ImageCropper(props: ImageCropperProps): import("react/jsx-runtime").JSX.Element;
11
+ type ImageCropperProps = {
12
+ width: {
13
+ xs: string;
14
+ sm: string;
15
+ };
16
+ height: {
17
+ xs: string;
18
+ sm: string;
19
+ };
20
+ children: ReactNode;
21
+ };
22
+ export {};
@@ -0,0 +1,34 @@
1
+ import { ReactNode } from 'react';
2
+ import ThumbnailListMainContent from './ThumbnailListMainContent';
3
+ import { ThumbnailListItemInterface } from '../interfaces/ThumbnailListItemInterface';
4
+ import ThumbnailListConfigurationInterface from '../config/ThumbnailListConfiguration';
5
+ /**
6
+ * Main Component: Renders all sub components
7
+ * Includes ThumbnailList Provider for context data
8
+ * @param props react children, items
9
+ * @returns component
10
+ */
11
+ declare function ThumbnailList<T extends ThumbnailListItemInterface>(props: ThumbnailListProps<T>): import("react/jsx-runtime").JSX.Element;
12
+ declare namespace ThumbnailList {
13
+ var MainContent: typeof ThumbnailListMainContent;
14
+ var Header: {
15
+ (props: {
16
+ children: ReactNode;
17
+ justifyContent?: "start" | "center" | "end" | "space-between";
18
+ }): import("react/jsx-runtime").JSX.Element;
19
+ SearchField: import("react").MemoExoticComponent<{
20
+ (): import("react/jsx-runtime").JSX.Element;
21
+ defaultProps: {
22
+ align: string;
23
+ };
24
+ }>;
25
+ FilterTags: typeof import("./ThumbnailListFilterTags").default;
26
+ Sort: typeof import("./ThumbnailListHeaderSort").default;
27
+ };
28
+ }
29
+ type ThumbnailListProps<T> = {
30
+ children: ReactNode;
31
+ items: T[];
32
+ config?: ThumbnailListConfigurationInterface<T>;
33
+ };
34
+ export default ThumbnailList;
@@ -0,0 +1,12 @@
1
+ import { Breakpoint } from '@mui/material';
2
+ import { ReactNode } from 'react';
3
+ export default function ThumbnailListFilterTag(props: ThumbnailListFilterTagProps): import("react/jsx-runtime").JSX.Element;
4
+ type ThumbnailListFilterTagProps = {
5
+ collapseBreakpoint?: Breakpoint;
6
+ label: string;
7
+ value: string;
8
+ variant: 'filled' | 'outlined';
9
+ icon?: ReactNode;
10
+ onClickCallback?: (value: string) => void;
11
+ };
12
+ export {};
@@ -0,0 +1,21 @@
1
+ import { Breakpoint } from '@mui/material';
2
+ import { ReactNode } from 'react';
3
+ declare function ThumbnailListFilterTags<T>(props: ThumbnailListFilterTagsProps<T>): import("react/jsx-runtime").JSX.Element;
4
+ declare namespace ThumbnailListFilterTags {
5
+ var defaultProps: {
6
+ align: string;
7
+ muiCollapseBreakpoint: string;
8
+ };
9
+ }
10
+ export type ThumbnailListItemTagType<T> = {
11
+ label: string;
12
+ key: keyof T;
13
+ icon?: ReactNode;
14
+ condition?: (value: any) => boolean;
15
+ };
16
+ type ThumbnailListFilterTagsProps<T> = {
17
+ tags: ThumbnailListItemTagType<T>[];
18
+ muiCollapseBreakpoint: Breakpoint;
19
+ align: AlignType;
20
+ };
21
+ export default ThumbnailListFilterTags;
@@ -0,0 +1,19 @@
1
+ import React, { ReactNode } from 'react';
2
+ import ThumbnailListFilterTags from './ThumbnailListFilterTags';
3
+ import ThumbnailListHeaderSort from './ThumbnailListHeaderSort';
4
+ declare const ThumbnailListHeader: {
5
+ (props: ThumbnailListHeaderProps): import("react/jsx-runtime").JSX.Element;
6
+ SearchField: React.MemoExoticComponent<{
7
+ (): import("react/jsx-runtime").JSX.Element;
8
+ defaultProps: {
9
+ align: string;
10
+ };
11
+ }>;
12
+ FilterTags: typeof ThumbnailListFilterTags;
13
+ Sort: typeof ThumbnailListHeaderSort;
14
+ };
15
+ type ThumbnailListHeaderProps = {
16
+ children: ReactNode;
17
+ justifyContent?: 'start' | 'center' | 'end' | 'space-between';
18
+ };
19
+ export default ThumbnailListHeader;
@@ -0,0 +1,17 @@
1
+ import { Breakpoint } from '@mui/material';
2
+ declare function ThumbnailListHeaderSort<T>(props: ThumbnailListHeaderSortProps<T>): import("react/jsx-runtime").JSX.Element;
3
+ declare namespace ThumbnailListHeaderSort {
4
+ var defaultProps: {
5
+ align: string;
6
+ muiBreakpoint: string;
7
+ };
8
+ }
9
+ type ThumbnailListHeaderSortProps<T> = {
10
+ items: {
11
+ label: string;
12
+ key: keyof T;
13
+ }[];
14
+ muiBreakpoint: Breakpoint;
15
+ align: AlignType;
16
+ };
17
+ export default ThumbnailListHeaderSort;
@@ -0,0 +1,11 @@
1
+ import React, { ReactNode } from 'react';
2
+ export type ThumbnailListItemProps = {
3
+ id: string;
4
+ onClick?: (id: string) => any;
5
+ thumbnailUrl: string;
6
+ title: string;
7
+ subTitle: ReactNode;
8
+ infoLabel: ReactNode;
9
+ };
10
+ declare const _default: React.MemoExoticComponent<(props: ThumbnailListItemProps) => import("react/jsx-runtime").JSX.Element>;
11
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { ThumbnailListItemInterface } from '../interfaces/ThumbnailListItemInterface';
3
+ import { ConditionFunction } from '../utils/arrayHelper';
4
+ type ThumbnailListItemContextType<T> = {
5
+ items: ThumbnailListItemInterface[];
6
+ setItems: React.Dispatch<React.SetStateAction<ThumbnailListItemInterface[]>>;
7
+ originalItems: T[];
8
+ setOriginalItems: React.Dispatch<React.SetStateAction<T[]>>;
9
+ tagFilterCallback: React.Dispatch<React.SetStateAction<{
10
+ tag: string;
11
+ condition: ConditionFunction<any> | undefined;
12
+ }>>;
13
+ tagAndCondition: {
14
+ tag: string;
15
+ condition: ConditionFunction<any> | undefined;
16
+ };
17
+ setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
18
+ setSortAscending: React.Dispatch<React.SetStateAction<boolean>>;
19
+ sortAscending: boolean;
20
+ sortBy: string;
21
+ setSortBy: React.Dispatch<React.SetStateAction<string>>;
22
+ isLoading: boolean;
23
+ };
24
+ export declare const ThumbnailListItemContext: React.Context<ThumbnailListItemContextType<any>>;
25
+ export declare const useThumbnailListItemContext: <T>() => ThumbnailListItemContextType<T>;
26
+ export {};
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ export default function ThumbnailListItemInfoLabel(props: {
3
+ topContent?: ReactNode;
4
+ bottomContent?: ReactNode;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ export default function ThumbnailListItemTitle(props: {
3
+ title: string;
4
+ subTitle: ReactNode;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ export type ThumbnailListItemType = {
3
+ id: string;
4
+ title: ReactNode;
5
+ subTitle: ReactNode;
6
+ thumbnailUrl: string;
7
+ link: string;
8
+ label: ReactNode;
9
+ };
@@ -0,0 +1,19 @@
1
+ import BreakpointType from '../types/BreakpointType';
2
+ declare function ThumbnailListMainContent(props: ThumbnailListMainContentProps): import("react/jsx-runtime").JSX.Element;
3
+ declare namespace ThumbnailListMainContent {
4
+ var defaultProps: {
5
+ spacing: number;
6
+ muiBreakpoints: {
7
+ xs: number;
8
+ sm: number;
9
+ md: number;
10
+ lg: number;
11
+ xl: number;
12
+ };
13
+ };
14
+ }
15
+ export default ThumbnailListMainContent;
16
+ type ThumbnailListMainContentProps = {
17
+ muiBreakpoints?: BreakpointType;
18
+ spacing: number;
19
+ };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ declare const _default: React.MemoExoticComponent<{
3
+ (): import("react/jsx-runtime").JSX.Element;
4
+ defaultProps: {
5
+ align: string;
6
+ };
7
+ }>;
8
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { ThumbnailListItemInterface } from '../interfaces/ThumbnailListItemInterface';
2
+ export default interface ThumbnailListConfigurationInterface<T> {
3
+ sortBy?: keyof T;
4
+ sortAscending?: boolean;
5
+ tag?: keyof T;
6
+ }
7
+ export declare const defaultConfiguration: ThumbnailListConfigurationInterface<ThumbnailListItemInterface>;
@@ -0,0 +1,13 @@
1
+ import { ThumbnailListItemInterface } from '../interfaces/ThumbnailListItemInterface';
2
+ /**
3
+ * Filters a list of event by a search term
4
+ * @param allEvents event list that will be formatted
5
+ * @param initialSearchTerm
6
+ * @returns
7
+ */
8
+ declare const useFilteredThumbnailListItems: (allItems: ThumbnailListItemInterface[], initialSearchTerm?: string) => {
9
+ searchTerm: string;
10
+ setSearchTerm: import("react").Dispatch<import("react").SetStateAction<string>>;
11
+ filteredItems: ThumbnailListItemInterface[];
12
+ };
13
+ export default useFilteredThumbnailListItems;
@@ -0,0 +1,15 @@
1
+ import { ThumbnailListItemInterface } from '../interfaces/ThumbnailListItemInterface';
2
+ /**
3
+ * Pages a list of event by paging number
4
+ * @param allEvents event list that will be formatted
5
+ * @param initialPagingNumber
6
+ * @returns
7
+ */
8
+ declare const usePagedThumbnailListItems: (allItems: ThumbnailListItemInterface[], initialEntriesPerPage?: number, initialPage?: number) => {
9
+ entriesPerPage: number;
10
+ setEntriesPerPage: import("react").Dispatch<import("react").SetStateAction<number>>;
11
+ page: number;
12
+ setPage: import("react").Dispatch<import("react").SetStateAction<number>>;
13
+ filteredItems: ThumbnailListItemInterface[];
14
+ };
15
+ export default usePagedThumbnailListItems;
@@ -0,0 +1,8 @@
1
+ declare const useSortedThumbnailListItems: <T>(allItems: T[], initialSortBy: string, initialSortAscending: boolean) => {
2
+ sortBy: string;
3
+ sortAscending: boolean;
4
+ setSortBy: import("react").Dispatch<import("react").SetStateAction<string>>;
5
+ setSortAscending: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
+ sortedItems: T[];
7
+ };
8
+ export default useSortedThumbnailListItems;
@@ -0,0 +1,19 @@
1
+ import { ConditionFunction } from '../utils/arrayHelper';
2
+ type UseTagFilteredThumbnailListItemsProps<T> = {
3
+ allItems: T[];
4
+ initialTag: string;
5
+ initialCondition?: ConditionFunction<any>;
6
+ };
7
+ declare const useTagFilteredThumbnailListItems: <T>({ allItems, initialTag, initialCondition, }: UseTagFilteredThumbnailListItemsProps<T>) => {
8
+ tagAndCondition: {
9
+ tag: string;
10
+ condition: ConditionFunction<any>;
11
+ };
12
+ setTagAndCondition: import("react").Dispatch<import("react").SetStateAction<{
13
+ tag: string;
14
+ condition: ConditionFunction<any>;
15
+ }>>;
16
+ tagFilteredItems: T[];
17
+ setTagWithCondition: (t: string, c: (value: any) => boolean) => void;
18
+ };
19
+ export default useTagFilteredThumbnailListItems;
@@ -0,0 +1,5 @@
1
+ declare const useWithLoading: () => {
2
+ isLoading: boolean;
3
+ withLoading: (fn: any, ...args: any[]) => Promise<void>;
4
+ };
5
+ export default useWithLoading;
@@ -0,0 +1 @@
1
+ export { default as ThumbnailList } from './components/ThumbnailList';
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ export interface ThumbnailListItemInterface {
3
+ id: string;
4
+ title: string;
5
+ subTitle?: ReactNode;
6
+ thumbnailUrl: string;
7
+ onClick?: (id: string) => any;
8
+ label?: ReactNode;
9
+ }
@@ -0,0 +1,41 @@
1
+ export declare const items: ({
2
+ id: string;
3
+ name: string;
4
+ title: string;
5
+ subTitle: string;
6
+ label: string;
7
+ isScheduled: boolean;
8
+ thumbnailUrl: string;
9
+ link: string;
10
+ startDateTimeStamp?: undefined;
11
+ } | {
12
+ id: string;
13
+ name: string;
14
+ title: string;
15
+ subTitle: string;
16
+ label: string;
17
+ thumbnailUrl: string;
18
+ link: string;
19
+ isScheduled?: undefined;
20
+ startDateTimeStamp?: undefined;
21
+ } | {
22
+ id: string;
23
+ title: string;
24
+ subTitle: string;
25
+ label: string;
26
+ thumbnailUrl: string;
27
+ link: string;
28
+ name?: undefined;
29
+ isScheduled?: undefined;
30
+ startDateTimeStamp?: undefined;
31
+ } | {
32
+ id: string;
33
+ title: string;
34
+ subTitle: string;
35
+ label: string;
36
+ startDateTimeStamp: number;
37
+ thumbnailUrl: string;
38
+ link: string;
39
+ name?: undefined;
40
+ isScheduled?: undefined;
41
+ })[];
@@ -0,0 +1 @@
1
+ type AlignType = 'start' | 'end';
@@ -0,0 +1,8 @@
1
+ type BreakpointType = {
2
+ xs: number;
3
+ sm: number;
4
+ md: number;
5
+ lg: number;
6
+ xl: number;
7
+ };
8
+ export default BreakpointType;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generic method that sorts an array of items based on an item key
3
+ * @param values The array that should be sorted
4
+ * @param orderType The key of the entity that the array should be sorted by
5
+ * @returns A new reference of the ordered array
6
+ */
7
+ export declare function orderByArray<T>(values: T[], orderType: keyof T): T[];
8
+ export type ConditionFunction<T> = (value: T) => boolean;
9
+ export declare function filterByTag<T>(array: T[], tagType: keyof T, condition?: ConditionFunction<unknown>): T[];
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@janrankenhohn/react-thumbnail-list",
3
- "version": "0.5.4",
4
- "main": "dist/index.cjs.js",
3
+ "version": "0.6.0",
4
+ "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
+ "types": "dist/types/index.d.ts",
6
7
  "files": [
7
- "./dist"
8
+ "dist"
8
9
  ],
9
10
  "repository": {
10
11
  "type": "git",
@@ -44,10 +45,6 @@
44
45
  "@babel/preset-env": "^7.23.9",
45
46
  "@babel/preset-react": "^7.23.3",
46
47
  "@eslint/js": "^9.1.1",
47
- "@rollup/plugin-babel": "^6.0.4",
48
- "@rollup/plugin-commonjs": "^25.0.7",
49
- "@rollup/plugin-node-resolve": "^15.2.3",
50
- "@rollup/plugin-typescript": "^8.3.3",
51
48
  "@testing-library/jest-dom": "^5.17.0",
52
49
  "@testing-library/react": "^13.4.0",
53
50
  "@testing-library/user-event": "^13.5.0",
@@ -63,10 +60,15 @@
63
60
  "npm-run-all": "^4.1.5",
64
61
  "prettier": "^3.2.5",
65
62
  "react-router": "^6.26.1",
66
- "rollup": "^2.79.1",
67
- "rollup-plugin-delete": "^2.0.0",
63
+ "@rollup/plugin-typescript": "^11.1.6",
64
+ "@rollup/plugin-url": "^8.0.2",
65
+ "@rollup/plugin-commonjs": "^25.0.8",
66
+ "@rollup/plugin-json": "^6.1.0",
67
+ "@rollup/plugin-node-resolve": "^15.2.3",
68
+ "rollup-plugin-dts": "^6.1.1",
69
+ "rollup": "^4.18.0",
68
70
  "rollup-plugin-peer-deps-external": "^2.2.4",
69
- "rollup-plugin-ts": "^3.4.5",
71
+ "rollup-plugin-typescript2": "^0.36.0",
70
72
  "typescript-eslint": "^7.8.0"
71
73
  },
72
74
  "peerDependencies": {
@@ -78,8 +80,5 @@
78
80
  "react": "^18.0.0",
79
81
  "react-dom": "^18.0.0",
80
82
  "web-vitals": "^2.1.4"
81
- },
82
- "overrides": {
83
- "typescript": "^5.3.2"
84
83
  }
85
84
  }