@delightui/components 0.1.116 → 0.1.118
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
package/dist/index.d.ts
CHANGED
|
@@ -1168,29 +1168,27 @@ declare const Card: (props: CardProps) => react_jsx_runtime.JSX.Element;
|
|
|
1168
1168
|
|
|
1169
1169
|
/**
|
|
1170
1170
|
* Enum for the alignment of the list.
|
|
1171
|
-
*
|
|
1172
|
-
* @typedef {'Horizontal' | 'Vertical'} ListAlignEnum
|
|
1173
1171
|
*/
|
|
1174
1172
|
type ListAlignEnum = 'Horizontal' | 'Vertical';
|
|
1175
1173
|
/**
|
|
1176
1174
|
* Represents a generic list item.
|
|
1177
|
-
*
|
|
1178
|
-
* @property {string | number} [id] - A unique identifier for the list item. This is optional and can be auto-generated if not provided.
|
|
1179
|
-
* @property {string} [itemClassName] - Additional class for styling the list item.
|
|
1180
|
-
* @property {React.CSSProperties} [itemStyle] - Additional styles for the list item.
|
|
1181
1175
|
*/
|
|
1182
|
-
type ListItemType =
|
|
1176
|
+
type ListItemType = {
|
|
1183
1177
|
id?: string | number;
|
|
1184
1178
|
itemClassName?: string;
|
|
1185
1179
|
itemStyle?: React.CSSProperties;
|
|
1186
1180
|
};
|
|
1181
|
+
/**
|
|
1182
|
+
* Base props shared by all list components.
|
|
1183
|
+
*/
|
|
1184
|
+
type BaseListProps<T extends ListItemType> = Omit<HTMLAttributes<HTMLUListElement>, 'children'> & {
|
|
1185
|
+
component: React.FC<any>;
|
|
1186
|
+
align?: ListAlignEnum;
|
|
1187
|
+
wrap?: boolean;
|
|
1188
|
+
className?: string;
|
|
1189
|
+
};
|
|
1187
1190
|
/**
|
|
1188
1191
|
* Props for an individual list item component.
|
|
1189
|
-
*
|
|
1190
|
-
* @template T - The type of the list item.
|
|
1191
|
-
* @property {string | number} id - The unique identifier of the list item.
|
|
1192
|
-
* @property {React.FC<any>} component - The React functional component used to render the list item.
|
|
1193
|
-
* @property {T} item - The data for the list item.
|
|
1194
1192
|
*/
|
|
1195
1193
|
type ListItemProps<T extends ListItemType> = Omit<HTMLAttributes<HTMLLIElement>, 'id' | 'children'> & {
|
|
1196
1194
|
id: string | number;
|
|
@@ -1199,69 +1197,39 @@ type ListItemProps<T extends ListItemType> = Omit<HTMLAttributes<HTMLLIElement>,
|
|
|
1199
1197
|
};
|
|
1200
1198
|
/**
|
|
1201
1199
|
* Props for the repeater list component.
|
|
1202
|
-
*
|
|
1203
|
-
* @template T - The type of the list items.
|
|
1204
1200
|
*/
|
|
1205
|
-
type RepeaterListProps<T extends ListItemType> =
|
|
1201
|
+
type RepeaterListProps<T extends ListItemType> = BaseListProps<T> & {
|
|
1202
|
+
data?: T[];
|
|
1203
|
+
};
|
|
1204
|
+
/**
|
|
1205
|
+
* Function type for handling sort order updates.
|
|
1206
|
+
*/
|
|
1207
|
+
type SortOrderFunction<T extends ListItemType> = (data: T[], oldIndex: number, newIndex: number) => T[] | undefined;
|
|
1206
1208
|
type SortableTriggerProps = IconButtonProps;
|
|
1207
1209
|
/**
|
|
1208
|
-
* Props for the
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
* @property {T[]} [data] - The data to be rendered in the list.
|
|
1212
|
-
* @property {React.FC<any>} component - The React functional component used to render each list item.
|
|
1213
|
-
* @property {(item: T, index: number) => string | number} [keyExtractor] - A function to extract unique keys for each item.
|
|
1214
|
-
* @property {'Horizontal' | 'Vertical'} [align='Vertical'] - The alignment of the list. Defaults to `'Vertical'`.
|
|
1215
|
-
* @property {boolean} [wrap] - Whether the list content should wrap.
|
|
1216
|
-
* @property {string} [className] - Additional class for styling the list.
|
|
1217
|
-
* @property {boolean} [sortable] - Whether the list items can be sorted using drag-and-drop.
|
|
1218
|
-
* @property {Dispatch<SetStateAction<T[]>>} [updateSortOrder] - Callback function to update the order of the list items after sorting.
|
|
1219
|
-
*/
|
|
1220
|
-
type ListProps<T extends ListItemType> = Omit<HTMLAttributes<HTMLUListElement>, 'children'> & {
|
|
1210
|
+
* Props for the main List facade component.
|
|
1211
|
+
*/
|
|
1212
|
+
type ListProps<T extends ListItemType> = BaseListProps<T> & {
|
|
1221
1213
|
/**
|
|
1222
1214
|
* The data to be rendered in the list.
|
|
1223
1215
|
*/
|
|
1224
1216
|
data?: T[];
|
|
1225
1217
|
/**
|
|
1226
|
-
*
|
|
1227
|
-
*/
|
|
1228
|
-
component: React.FC<any>;
|
|
1229
|
-
/**
|
|
1230
|
-
* Function to extract keys.
|
|
1218
|
+
* Function to extract keys for items without IDs.
|
|
1231
1219
|
*/
|
|
1232
1220
|
keyExtractor?: (item: T, index: number) => string | number;
|
|
1233
1221
|
/**
|
|
1234
|
-
*
|
|
1235
|
-
* @default 'Vertical'
|
|
1236
|
-
*/
|
|
1237
|
-
align?: ListAlignEnum;
|
|
1238
|
-
/**
|
|
1239
|
-
* Flag to control if the content should wrap.
|
|
1240
|
-
*/
|
|
1241
|
-
wrap?: boolean;
|
|
1242
|
-
/**
|
|
1243
|
-
* Additional class for styling.
|
|
1244
|
-
*/
|
|
1245
|
-
className?: string;
|
|
1246
|
-
/**
|
|
1247
|
-
* Flag to enable sorting of list items
|
|
1222
|
+
* Flag to enable sorting of list items.
|
|
1248
1223
|
*/
|
|
1249
1224
|
sortable?: boolean;
|
|
1250
1225
|
/**
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
* @param data
|
|
1254
|
-
* @returns
|
|
1226
|
+
* Callback function to update the current order of data.
|
|
1255
1227
|
*/
|
|
1256
|
-
updateSortOrder?:
|
|
1228
|
+
updateSortOrder?: SortOrderFunction<T>;
|
|
1257
1229
|
};
|
|
1258
1230
|
|
|
1259
1231
|
/**
|
|
1260
1232
|
* A wrapper component that manages the rendering of either a sortable or regular list based on the provided props.
|
|
1261
|
-
*
|
|
1262
|
-
* @template T - The type of the list items.
|
|
1263
|
-
* @param {ListProps<T>} props - The properties for the list wrapper.
|
|
1264
|
-
* @returns {JSX.Element} The rendered list component.
|
|
1265
1233
|
*/
|
|
1266
1234
|
declare const List: <T extends ListItemType>(props: ListProps<T>) => react_jsx_runtime.JSX.Element;
|
|
1267
1235
|
|
|
@@ -1274,6 +1242,13 @@ declare const List: <T extends ListItemType>(props: ListProps<T>) => react_jsx_r
|
|
|
1274
1242
|
*/
|
|
1275
1243
|
declare const SortableItem: <T extends ListItemType>(props: ListItemProps<T>) => react_jsx_runtime.JSX.Element;
|
|
1276
1244
|
|
|
1245
|
+
/**
|
|
1246
|
+
* A list component that renders a list of items without any parent container.
|
|
1247
|
+
*
|
|
1248
|
+
* @template T - The type of the list item.
|
|
1249
|
+
* @param {RepeaterListProps<T>} props - The properties for the repeater list.
|
|
1250
|
+
* @returns {JSX.Element} The rendered repeater list.
|
|
1251
|
+
*/
|
|
1277
1252
|
declare const RepeaterList: <T extends ListItemType>(props: RepeaterListProps<T>) => react_jsx_runtime.JSX.Element;
|
|
1278
1253
|
|
|
1279
1254
|
declare const SortableTrigger: (props: SortableTriggerProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
A flexible list component that renders collections of data with support for custom item components, sorting functionality, and both horizontal and vertical layouts. Provides efficient rendering for dynamic data sets with keyboard navigation and accessibility features.
|
|
5
|
+
A flexible list component that renders collections of data with support for custom item components, sorting functionality, and both horizontal and vertical layouts. The component acts as a facade that automatically chooses between BasicList and SortableList implementations based on the `sortable` prop. Provides efficient rendering for dynamic data sets with keyboard navigation and accessibility features.
|
|
6
6
|
|
|
7
7
|
## Aliases
|
|
8
8
|
|
|
@@ -24,7 +24,7 @@ A flexible list component that renders collections of data with support for cust
|
|
|
24
24
|
| `wrap` | `boolean` | - | No | Whether list content should wrap |
|
|
25
25
|
| `align` | `'Horizontal' \| 'Vertical'` | `'Vertical'` | No | Layout direction for the list |
|
|
26
26
|
| `sortable` | `boolean` | - | No | Enable drag-and-drop sorting |
|
|
27
|
-
| `updateSortOrder` | `(data: T[], oldIndex: number, newIndex: number) =>
|
|
27
|
+
| `updateSortOrder` | `(data: T[], oldIndex: number, newIndex: number) => T[] \| undefined` | - | No | Callback when sort order changes. Return new data array or undefined to use default behavior |
|
|
28
28
|
| `className` | `string` | - | No | Additional CSS class names |
|
|
29
29
|
|
|
30
30
|
Plus all standard HTML ul attributes (role, aria-*, data-*, etc.).
|
|
@@ -147,12 +147,17 @@ function SortableListExample() {
|
|
|
147
147
|
</div>
|
|
148
148
|
);
|
|
149
149
|
|
|
150
|
+
const handleSortUpdate = (newData, oldIndex, newIndex) => {
|
|
151
|
+
setTasks(newData);
|
|
152
|
+
return newData; // Return the new data to update internal state
|
|
153
|
+
};
|
|
154
|
+
|
|
150
155
|
return (
|
|
151
156
|
<List
|
|
152
157
|
data={tasks}
|
|
153
158
|
component={TaskItem}
|
|
154
159
|
sortable
|
|
155
|
-
updateSortOrder={
|
|
160
|
+
updateSortOrder={handleSortUpdate}
|
|
156
161
|
keyExtractor={(task) => task.id}
|
|
157
162
|
/>
|
|
158
163
|
);
|
package/package.json
CHANGED