@delightui/components 0.1.115 → 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/atoms/Input/Input.d.ts +1 -0
- package/dist/cjs/components/atoms/Input/Input.presenter.d.ts +2 -1
- package/dist/cjs/components/atoms/Input/Input.types.d.ts +5 -0
- package/dist/cjs/components/atoms/Password/Password.presenter.d.ts +1 -0
- 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/atoms/Input/Input.d.ts +1 -0
- package/dist/esm/components/atoms/Input/Input.presenter.d.ts +2 -1
- package/dist/esm/components/atoms/Input/Input.types.d.ts +5 -0
- package/dist/esm/components/atoms/Password/Password.presenter.d.ts +1 -0
- 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 +3 -3
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +37 -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
|
@@ -426,6 +426,11 @@ type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value'>
|
|
|
426
426
|
* Icon to be displayed after the input.
|
|
427
427
|
*/
|
|
428
428
|
trailingIcon?: React.ReactNode;
|
|
429
|
+
/**
|
|
430
|
+
* a function that will preprocess the value before updating the value for form
|
|
431
|
+
* and onValueChange value
|
|
432
|
+
*/
|
|
433
|
+
preProcessInput?: (text: string) => string;
|
|
429
434
|
/**
|
|
430
435
|
* provide a way to override the styling
|
|
431
436
|
*/
|
|
@@ -436,6 +441,7 @@ declare const Input: React$1.ForwardRefExoticComponent<Omit<React$1.InputHTMLAtt
|
|
|
436
441
|
inputType?: InputTypeEnum;
|
|
437
442
|
leadingIcon?: React.ReactNode;
|
|
438
443
|
trailingIcon?: React.ReactNode;
|
|
444
|
+
preProcessInput?: (text: string) => string;
|
|
439
445
|
'component-variant'?: string;
|
|
440
446
|
} & React$1.RefAttributes<HTMLInputElement>>;
|
|
441
447
|
|
|
@@ -1162,29 +1168,27 @@ declare const Card: (props: CardProps) => react_jsx_runtime.JSX.Element;
|
|
|
1162
1168
|
|
|
1163
1169
|
/**
|
|
1164
1170
|
* Enum for the alignment of the list.
|
|
1165
|
-
*
|
|
1166
|
-
* @typedef {'Horizontal' | 'Vertical'} ListAlignEnum
|
|
1167
1171
|
*/
|
|
1168
1172
|
type ListAlignEnum = 'Horizontal' | 'Vertical';
|
|
1169
1173
|
/**
|
|
1170
1174
|
* Represents a generic list item.
|
|
1171
|
-
*
|
|
1172
|
-
* @property {string | number} [id] - A unique identifier for the list item. This is optional and can be auto-generated if not provided.
|
|
1173
|
-
* @property {string} [itemClassName] - Additional class for styling the list item.
|
|
1174
|
-
* @property {React.CSSProperties} [itemStyle] - Additional styles for the list item.
|
|
1175
1175
|
*/
|
|
1176
|
-
type ListItemType =
|
|
1176
|
+
type ListItemType = {
|
|
1177
1177
|
id?: string | number;
|
|
1178
1178
|
itemClassName?: string;
|
|
1179
1179
|
itemStyle?: React.CSSProperties;
|
|
1180
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
|
+
};
|
|
1181
1190
|
/**
|
|
1182
1191
|
* Props for an individual list item component.
|
|
1183
|
-
*
|
|
1184
|
-
* @template T - The type of the list item.
|
|
1185
|
-
* @property {string | number} id - The unique identifier of the list item.
|
|
1186
|
-
* @property {React.FC<any>} component - The React functional component used to render the list item.
|
|
1187
|
-
* @property {T} item - The data for the list item.
|
|
1188
1192
|
*/
|
|
1189
1193
|
type ListItemProps<T extends ListItemType> = Omit<HTMLAttributes<HTMLLIElement>, 'id' | 'children'> & {
|
|
1190
1194
|
id: string | number;
|
|
@@ -1193,69 +1197,39 @@ type ListItemProps<T extends ListItemType> = Omit<HTMLAttributes<HTMLLIElement>,
|
|
|
1193
1197
|
};
|
|
1194
1198
|
/**
|
|
1195
1199
|
* Props for the repeater list component.
|
|
1196
|
-
*
|
|
1197
|
-
* @template T - The type of the list items.
|
|
1198
1200
|
*/
|
|
1199
|
-
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;
|
|
1200
1208
|
type SortableTriggerProps = IconButtonProps;
|
|
1201
1209
|
/**
|
|
1202
|
-
* Props for the
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
* @property {T[]} [data] - The data to be rendered in the list.
|
|
1206
|
-
* @property {React.FC<any>} component - The React functional component used to render each list item.
|
|
1207
|
-
* @property {(item: T, index: number) => string | number} [keyExtractor] - A function to extract unique keys for each item.
|
|
1208
|
-
* @property {'Horizontal' | 'Vertical'} [align='Vertical'] - The alignment of the list. Defaults to `'Vertical'`.
|
|
1209
|
-
* @property {boolean} [wrap] - Whether the list content should wrap.
|
|
1210
|
-
* @property {string} [className] - Additional class for styling the list.
|
|
1211
|
-
* @property {boolean} [sortable] - Whether the list items can be sorted using drag-and-drop.
|
|
1212
|
-
* @property {Dispatch<SetStateAction<T[]>>} [updateSortOrder] - Callback function to update the order of the list items after sorting.
|
|
1213
|
-
*/
|
|
1214
|
-
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> & {
|
|
1215
1213
|
/**
|
|
1216
1214
|
* The data to be rendered in the list.
|
|
1217
1215
|
*/
|
|
1218
1216
|
data?: T[];
|
|
1219
1217
|
/**
|
|
1220
|
-
*
|
|
1221
|
-
*/
|
|
1222
|
-
component: React.FC<any>;
|
|
1223
|
-
/**
|
|
1224
|
-
* Function to extract keys.
|
|
1218
|
+
* Function to extract keys for items without IDs.
|
|
1225
1219
|
*/
|
|
1226
1220
|
keyExtractor?: (item: T, index: number) => string | number;
|
|
1227
1221
|
/**
|
|
1228
|
-
*
|
|
1229
|
-
* @default 'Vertical'
|
|
1230
|
-
*/
|
|
1231
|
-
align?: ListAlignEnum;
|
|
1232
|
-
/**
|
|
1233
|
-
* Flag to control if the content should wrap.
|
|
1234
|
-
*/
|
|
1235
|
-
wrap?: boolean;
|
|
1236
|
-
/**
|
|
1237
|
-
* Additional class for styling.
|
|
1238
|
-
*/
|
|
1239
|
-
className?: string;
|
|
1240
|
-
/**
|
|
1241
|
-
* Flag to enable sorting of list items
|
|
1222
|
+
* Flag to enable sorting of list items.
|
|
1242
1223
|
*/
|
|
1243
1224
|
sortable?: boolean;
|
|
1244
1225
|
/**
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
* @param data
|
|
1248
|
-
* @returns
|
|
1226
|
+
* Callback function to update the current order of data.
|
|
1249
1227
|
*/
|
|
1250
|
-
updateSortOrder?:
|
|
1228
|
+
updateSortOrder?: SortOrderFunction<T>;
|
|
1251
1229
|
};
|
|
1252
1230
|
|
|
1253
1231
|
/**
|
|
1254
1232
|
* A wrapper component that manages the rendering of either a sortable or regular list based on the provided props.
|
|
1255
|
-
*
|
|
1256
|
-
* @template T - The type of the list items.
|
|
1257
|
-
* @param {ListProps<T>} props - The properties for the list wrapper.
|
|
1258
|
-
* @returns {JSX.Element} The rendered list component.
|
|
1259
1233
|
*/
|
|
1260
1234
|
declare const List: <T extends ListItemType>(props: ListProps<T>) => react_jsx_runtime.JSX.Element;
|
|
1261
1235
|
|
|
@@ -1268,6 +1242,13 @@ declare const List: <T extends ListItemType>(props: ListProps<T>) => react_jsx_r
|
|
|
1268
1242
|
*/
|
|
1269
1243
|
declare const SortableItem: <T extends ListItemType>(props: ListItemProps<T>) => react_jsx_runtime.JSX.Element;
|
|
1270
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
|
+
*/
|
|
1271
1252
|
declare const RepeaterList: <T extends ListItemType>(props: RepeaterListProps<T>) => react_jsx_runtime.JSX.Element;
|
|
1272
1253
|
|
|
1273
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