@delightui/components 0.1.116 → 0.1.117
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.
- package/dist/cjs/components/molecules/List/List.d.ts +0 -4
- package/dist/cjs/components/molecules/List/List.types.d.ts +36 -62
- package/dist/cjs/components/molecules/List/RepeaterList.d.ts +10 -0
- package/dist/cjs/components/molecules/List/components/BasicList.d.ts +5 -0
- package/dist/cjs/components/molecules/List/components/SortableList.d.ts +2 -4
- package/dist/cjs/components/molecules/List/index.d.ts +1 -1
- package/dist/cjs/library.js +2 -2
- package/dist/cjs/library.js.map +1 -1
- package/dist/esm/components/molecules/List/List.d.ts +0 -4
- package/dist/esm/components/molecules/List/List.types.d.ts +36 -62
- package/dist/esm/components/molecules/List/RepeaterList.d.ts +10 -0
- package/dist/esm/components/molecules/List/components/BasicList.d.ts +5 -0
- package/dist/esm/components/molecules/List/components/SortableList.d.ts +2 -4
- package/dist/esm/components/molecules/List/index.d.ts +1 -1
- package/dist/esm/library.js +2 -2
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +31 -56
- package/docs/components/molecules/List.md +8 -3
- package/package.json +1 -1
- package/dist/cjs/components/molecules/List/components/RepeaterList.d.ts +0 -3
- package/dist/esm/components/molecules/List/components/RepeaterList.d.ts +0 -3
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { ListItemType, ListProps } from './List.types';
|
|
2
2
|
/**
|
|
3
3
|
* A wrapper component that manages the rendering of either a sortable or regular list based on the provided props.
|
|
4
|
-
*
|
|
5
|
-
* @template T - The type of the list items.
|
|
6
|
-
* @param {ListProps<T>} props - The properties for the list wrapper.
|
|
7
|
-
* @returns {JSX.Element} The rendered list component.
|
|
8
4
|
*/
|
|
9
5
|
declare const List: <T extends ListItemType>(props: ListProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
10
6
|
export default List;
|
|
@@ -2,29 +2,33 @@ import type { HTMLAttributes } from 'react';
|
|
|
2
2
|
import { IconButtonProps } from '../../atoms';
|
|
3
3
|
/**
|
|
4
4
|
* Enum for the alignment of the list.
|
|
5
|
-
*
|
|
6
|
-
* @typedef {'Horizontal' | 'Vertical'} ListAlignEnum
|
|
7
5
|
*/
|
|
8
6
|
export type ListAlignEnum = 'Horizontal' | 'Vertical';
|
|
9
7
|
/**
|
|
10
8
|
* Represents a generic list item.
|
|
11
|
-
*
|
|
12
|
-
* @property {string | number} [id] - A unique identifier for the list item. This is optional and can be auto-generated if not provided.
|
|
13
|
-
* @property {string} [itemClassName] - Additional class for styling the list item.
|
|
14
|
-
* @property {React.CSSProperties} [itemStyle] - Additional styles for the list item.
|
|
15
9
|
*/
|
|
16
|
-
export type ListItemType =
|
|
10
|
+
export type ListItemType = {
|
|
17
11
|
id?: string | number;
|
|
18
12
|
itemClassName?: string;
|
|
19
13
|
itemStyle?: React.CSSProperties;
|
|
20
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* List item with required ID for sortable lists.
|
|
17
|
+
*/
|
|
18
|
+
export type SortableListItemType = ListItemType & {
|
|
19
|
+
id: string | number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Base props shared by all list components.
|
|
23
|
+
*/
|
|
24
|
+
type BaseListProps<T extends ListItemType> = Omit<HTMLAttributes<HTMLUListElement>, 'children'> & {
|
|
25
|
+
component: React.FC<any>;
|
|
26
|
+
align?: ListAlignEnum;
|
|
27
|
+
wrap?: boolean;
|
|
28
|
+
className?: string;
|
|
29
|
+
};
|
|
21
30
|
/**
|
|
22
31
|
* Props for an individual list item component.
|
|
23
|
-
*
|
|
24
|
-
* @template T - The type of the list item.
|
|
25
|
-
* @property {string | number} id - The unique identifier of the list item.
|
|
26
|
-
* @property {React.FC<any>} component - The React functional component used to render the list item.
|
|
27
|
-
* @property {T} item - The data for the list item.
|
|
28
32
|
*/
|
|
29
33
|
export type ListItemProps<T extends ListItemType> = Omit<HTMLAttributes<HTMLLIElement>, 'id' | 'children'> & {
|
|
30
34
|
id: string | number;
|
|
@@ -32,29 +36,28 @@ export type ListItemProps<T extends ListItemType> = Omit<HTMLAttributes<HTMLLIEl
|
|
|
32
36
|
item: T;
|
|
33
37
|
};
|
|
34
38
|
/**
|
|
35
|
-
* Props for the root list component
|
|
36
|
-
*
|
|
37
|
-
* @template T - The type of the list items.
|
|
39
|
+
* Props for the root list component.
|
|
38
40
|
*/
|
|
39
|
-
export type RootListProps<T extends ListItemType> = Omit<
|
|
41
|
+
export type RootListProps<T extends ListItemType> = Omit<BaseListProps<T>, 'component'> & {
|
|
40
42
|
children: React.ReactNode;
|
|
41
43
|
};
|
|
42
44
|
/**
|
|
43
45
|
* Props for the repeater list component.
|
|
44
|
-
*
|
|
45
|
-
* @template T - The type of the list items.
|
|
46
46
|
*/
|
|
47
|
-
export type RepeaterListProps<T extends ListItemType> =
|
|
47
|
+
export type RepeaterListProps<T extends ListItemType> = BaseListProps<T> & {
|
|
48
|
+
data?: T[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Function type for handling sort order updates.
|
|
52
|
+
*/
|
|
53
|
+
export type SortOrderFunction<T extends ListItemType> = (data: T[], oldIndex: number, newIndex: number) => T[] | undefined;
|
|
48
54
|
/**
|
|
49
55
|
* Props for the sortable list component.
|
|
50
|
-
*
|
|
51
|
-
* @template T - The type of the list items, which must include an `id` property.
|
|
52
|
-
* @property {T[]} data - The list of items to be rendered in the sortable list.
|
|
53
56
|
*/
|
|
54
|
-
export type SortableListProps<T extends {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
export type SortableListProps<T extends ListItemType> = BaseListProps<T> & {
|
|
58
|
+
data?: T[];
|
|
59
|
+
keyExtractor?: (item: T, index: number) => string | number;
|
|
60
|
+
updateSortOrder?: SortOrderFunction<T>;
|
|
58
61
|
};
|
|
59
62
|
/**
|
|
60
63
|
* Context type for the sortable item.
|
|
@@ -86,53 +89,24 @@ export type SortableItemContextType = {
|
|
|
86
89
|
};
|
|
87
90
|
export type SortableTriggerProps = IconButtonProps;
|
|
88
91
|
/**
|
|
89
|
-
* Props for the
|
|
90
|
-
*
|
|
91
|
-
* @template T - The type of the list items.
|
|
92
|
-
* @property {T[]} [data] - The data to be rendered in the list.
|
|
93
|
-
* @property {React.FC<any>} component - The React functional component used to render each list item.
|
|
94
|
-
* @property {(item: T, index: number) => string | number} [keyExtractor] - A function to extract unique keys for each item.
|
|
95
|
-
* @property {'Horizontal' | 'Vertical'} [align='Vertical'] - The alignment of the list. Defaults to `'Vertical'`.
|
|
96
|
-
* @property {boolean} [wrap] - Whether the list content should wrap.
|
|
97
|
-
* @property {string} [className] - Additional class for styling the list.
|
|
98
|
-
* @property {boolean} [sortable] - Whether the list items can be sorted using drag-and-drop.
|
|
99
|
-
* @property {Dispatch<SetStateAction<T[]>>} [updateSortOrder] - Callback function to update the order of the list items after sorting.
|
|
92
|
+
* Props for the main List facade component.
|
|
100
93
|
*/
|
|
101
|
-
export type ListProps<T extends ListItemType> =
|
|
94
|
+
export type ListProps<T extends ListItemType> = BaseListProps<T> & {
|
|
102
95
|
/**
|
|
103
96
|
* The data to be rendered in the list.
|
|
104
97
|
*/
|
|
105
98
|
data?: T[];
|
|
106
99
|
/**
|
|
107
|
-
*
|
|
108
|
-
*/
|
|
109
|
-
component: React.FC<any>;
|
|
110
|
-
/**
|
|
111
|
-
* Function to extract keys.
|
|
100
|
+
* Function to extract keys for items without IDs.
|
|
112
101
|
*/
|
|
113
102
|
keyExtractor?: (item: T, index: number) => string | number;
|
|
114
103
|
/**
|
|
115
|
-
*
|
|
116
|
-
* @default 'Vertical'
|
|
117
|
-
*/
|
|
118
|
-
align?: ListAlignEnum;
|
|
119
|
-
/**
|
|
120
|
-
* Flag to control if the content should wrap.
|
|
121
|
-
*/
|
|
122
|
-
wrap?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Additional class for styling.
|
|
125
|
-
*/
|
|
126
|
-
className?: string;
|
|
127
|
-
/**
|
|
128
|
-
* Flag to enable sorting of list items
|
|
104
|
+
* Flag to enable sorting of list items.
|
|
129
105
|
*/
|
|
130
106
|
sortable?: boolean;
|
|
131
107
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* @param data
|
|
135
|
-
* @returns
|
|
108
|
+
* Callback function to update the current order of data.
|
|
136
109
|
*/
|
|
137
|
-
updateSortOrder?:
|
|
110
|
+
updateSortOrder?: SortOrderFunction<T>;
|
|
138
111
|
};
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ListItemType, RepeaterListProps } from "./List.types";
|
|
2
|
+
/**
|
|
3
|
+
* A list component that renders a list of items without any parent container.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of the list item.
|
|
6
|
+
* @param {RepeaterListProps<T>} props - The properties for the repeater list.
|
|
7
|
+
* @returns {JSX.Element} The rendered repeater list.
|
|
8
|
+
*/
|
|
9
|
+
declare const RepeaterList: <T extends ListItemType>(props: RepeaterListProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default RepeaterList;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ListItemType, ListProps } from '../List.types';
|
|
2
|
+
/**
|
|
3
|
+
* A basic list component that renders items without sorting functionality.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BasicList: <T extends ListItemType>(props: ListProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SortableListProps } from "../List.types";
|
|
1
|
+
import { SortableListProps, ListItemType } from "../List.types";
|
|
2
2
|
/**
|
|
3
3
|
* A sortable list component that allows drag-and-drop reordering of items.
|
|
4
4
|
*
|
|
@@ -6,6 +6,4 @@ import { SortableListProps } from "../List.types";
|
|
|
6
6
|
* @param {SortableListProps<T>} props - The properties for the sortable list.
|
|
7
7
|
* @returns {JSX.Element} The rendered sortable list.
|
|
8
8
|
*/
|
|
9
|
-
export declare const SortableList: <T extends
|
|
10
|
-
id: string | number;
|
|
11
|
-
}>(props: SortableListProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const SortableList: <T extends ListItemType>(props: SortableListProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import List from './List';
|
|
2
2
|
import { SortableItem as DraggableItem } from './components/SortableListItem';
|
|
3
|
-
import RepeaterList from './
|
|
3
|
+
import RepeaterList from './RepeaterList';
|
|
4
4
|
import DraggableItemTrigger from './components/SortableTrigger';
|
|
5
5
|
import type { ListProps, RepeaterListProps } from './List.types';
|
|
6
6
|
export type { ListProps, RepeaterListProps };
|