@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.
Files changed (29) hide show
  1. package/dist/cjs/components/atoms/Input/Input.d.ts +1 -0
  2. package/dist/cjs/components/atoms/Input/Input.presenter.d.ts +2 -1
  3. package/dist/cjs/components/atoms/Input/Input.types.d.ts +5 -0
  4. package/dist/cjs/components/atoms/Password/Password.presenter.d.ts +1 -0
  5. package/dist/cjs/components/molecules/List/List.d.ts +0 -4
  6. package/dist/cjs/components/molecules/List/List.types.d.ts +36 -62
  7. package/dist/cjs/components/molecules/List/RepeaterList.d.ts +10 -0
  8. package/dist/cjs/components/molecules/List/components/BasicList.d.ts +5 -0
  9. package/dist/cjs/components/molecules/List/components/SortableList.d.ts +2 -4
  10. package/dist/cjs/components/molecules/List/index.d.ts +1 -1
  11. package/dist/cjs/library.js +2 -2
  12. package/dist/cjs/library.js.map +1 -1
  13. package/dist/esm/components/atoms/Input/Input.d.ts +1 -0
  14. package/dist/esm/components/atoms/Input/Input.presenter.d.ts +2 -1
  15. package/dist/esm/components/atoms/Input/Input.types.d.ts +5 -0
  16. package/dist/esm/components/atoms/Password/Password.presenter.d.ts +1 -0
  17. package/dist/esm/components/molecules/List/List.d.ts +0 -4
  18. package/dist/esm/components/molecules/List/List.types.d.ts +36 -62
  19. package/dist/esm/components/molecules/List/RepeaterList.d.ts +10 -0
  20. package/dist/esm/components/molecules/List/components/BasicList.d.ts +5 -0
  21. package/dist/esm/components/molecules/List/components/SortableList.d.ts +2 -4
  22. package/dist/esm/components/molecules/List/index.d.ts +1 -1
  23. package/dist/esm/library.js +3 -3
  24. package/dist/esm/library.js.map +1 -1
  25. package/dist/index.d.ts +37 -56
  26. package/docs/components/molecules/List.md +8 -3
  27. package/package.json +1 -1
  28. package/dist/cjs/components/molecules/List/components/RepeaterList.d.ts +0 -3
  29. package/dist/esm/components/molecules/List/components/RepeaterList.d.ts +0 -3
@@ -2,6 +2,7 @@ declare const Input: import("react").ForwardRefExoticComponent<Omit<import("reac
2
2
  inputType?: import("./Input.types").InputTypeEnum;
3
3
  leadingIcon?: React.ReactNode;
4
4
  trailingIcon?: React.ReactNode;
5
+ preProcessInput?: (text: string) => string;
5
6
  'component-variant'?: string;
6
7
  } & import("react").RefAttributes<HTMLInputElement>>;
7
8
  export default Input;
@@ -1,5 +1,5 @@
1
1
  import { InputProps } from './Input.types';
2
- declare const usePresenter: (props: InputProps) => {
2
+ declare const usePresenter: (props: InputProps, ref: React.ForwardedRef<HTMLInputElement>) => {
3
3
  variantProps: {
4
4
  'component-variant': string;
5
5
  };
@@ -307,5 +307,6 @@ declare const usePresenter: (props: InputProps) => {
307
307
  inputType: "number" | "text" | "email" | "password";
308
308
  required: boolean | undefined;
309
309
  componentVariant: string | undefined;
310
+ inputRef: import("react").Ref<HTMLInputElement>;
310
311
  };
311
312
  export default usePresenter;
@@ -18,6 +18,11 @@ export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'v
18
18
  * Icon to be displayed after the input.
19
19
  */
20
20
  trailingIcon?: React.ReactNode;
21
+ /**
22
+ * a function that will preprocess the value before updating the value for form
23
+ * and onValueChange value
24
+ */
25
+ preProcessInput?: (text: string) => string;
21
26
  /**
22
27
  * provide a way to override the styling
23
28
  */
@@ -304,6 +304,7 @@ declare const usePresenter: (props: PasswordProps) => {
304
304
  placeholder?: string | undefined;
305
305
  readOnly?: boolean | undefined;
306
306
  onValueChange?: ((value: string) => void) | undefined;
307
+ preProcessInput?: (text: string) => string;
307
308
  'component-variant'?: string;
308
309
  initialValue?: string | undefined;
309
310
  };
@@ -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 = object & {
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, excluding certain properties.
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<ListProps<T>, 'data' | 'component' | 'keyExtractor' | 'sortable'> & {
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> = Omit<ListProps<T>, 'keyExtractor' | 'sortable' | 'updateSortOrder' | 'align' | 'wrap'>;
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
- id: string | number;
56
- }> = ListProps<T> & {
57
- data: T[];
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 list wrapper component.
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> = Omit<HTMLAttributes<HTMLUListElement>, 'children'> & {
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
- * The component used to render each item in the list.
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
- * The alignment of the list.
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
- * callback function to update the current order of data
133
- *
134
- * @param data
135
- * @returns
108
+ * Callback function to update the current order of data.
136
109
  */
137
- updateSortOrder?: (data: T[], oldIndex: number, newIndex: number) => void;
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 './components/RepeaterList';
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 };