@delightui/components 0.1.109 → 0.1.111
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/Search/Search.d.ts +18 -0
- package/dist/cjs/components/molecules/Search/Search.presenter.d.ts +320 -0
- package/dist/cjs/components/molecules/Search/Search.types.d.ts +53 -0
- package/dist/cjs/components/molecules/Search/index.d.ts +2 -0
- package/dist/cjs/components/molecules/index.d.ts +2 -0
- package/dist/cjs/components/utils/RenderStateView/RenderStateView.types.d.ts +4 -0
- package/dist/cjs/components/utils/RenderStateView/usePresenter.d.ts +1 -0
- package/dist/cjs/components/utils/index.d.ts +2 -0
- package/dist/cjs/components/utils/useDebounce/index.d.ts +1 -0
- package/dist/cjs/components/utils/useDebounce/useDebounce.d.ts +10 -0
- package/dist/cjs/components/utils/useInflateView/index.d.ts +0 -1
- package/dist/cjs/components/utils/useInflateView/useInflateView.d.ts +1 -1
- package/dist/cjs/library.css +66 -0
- package/dist/cjs/library.js +3 -3
- package/dist/cjs/library.js.map +1 -1
- package/dist/esm/components/molecules/Search/Search.d.ts +18 -0
- package/dist/esm/components/molecules/Search/Search.presenter.d.ts +320 -0
- package/dist/esm/components/molecules/Search/Search.types.d.ts +53 -0
- package/dist/esm/components/molecules/Search/index.d.ts +2 -0
- package/dist/esm/components/molecules/index.d.ts +2 -0
- package/dist/esm/components/utils/RenderStateView/RenderStateView.types.d.ts +4 -0
- package/dist/esm/components/utils/RenderStateView/usePresenter.d.ts +1 -0
- package/dist/esm/components/utils/index.d.ts +2 -0
- package/dist/esm/components/utils/useDebounce/index.d.ts +1 -0
- package/dist/esm/components/utils/useDebounce/useDebounce.d.ts +10 -0
- package/dist/esm/components/utils/useInflateView/index.d.ts +0 -1
- package/dist/esm/components/utils/useInflateView/useInflateView.d.ts +1 -1
- package/dist/esm/library.css +66 -0
- package/dist/esm/library.js +3 -3
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +83 -10
- package/docs/README.md +6 -0
- package/docs/components/atoms/Input.md +0 -63
- package/docs/components/molecules/Search.md +710 -0
- package/docs/components/utils/RenderStateView.md +137 -38
- package/docs/components/utils/useDebounce.md +576 -0
- package/package.json +1 -1
- package/dist/cjs/components/utils/useInflateView/useInflateView.types.d.ts +0 -12
- package/dist/esm/components/utils/useInflateView/useInflateView.types.d.ts +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -2027,6 +2027,76 @@ type ChipInputProps = ControlledFormComponentProps<string[]> & {
|
|
|
2027
2027
|
|
|
2028
2028
|
declare const _default: React__default.NamedExoticComponent<ChipInputProps>;
|
|
2029
2029
|
|
|
2030
|
+
/**
|
|
2031
|
+
* Enum for different search modes.
|
|
2032
|
+
*/
|
|
2033
|
+
type SearchStyleEnum = 'Auto' | 'Button';
|
|
2034
|
+
/**
|
|
2035
|
+
* Search callback function type that receives the search query and returns a promise
|
|
2036
|
+
*/
|
|
2037
|
+
type SearchCallback = (query: string) => Promise<void>;
|
|
2038
|
+
/**
|
|
2039
|
+
* Props for the Search component
|
|
2040
|
+
*/
|
|
2041
|
+
type SearchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value'> & ControlledFormComponentProps<string> & {
|
|
2042
|
+
/**
|
|
2043
|
+
* The search style - 'Auto' for debounced search on input, 'Button' for search on enter/submit
|
|
2044
|
+
* @default 'Auto'
|
|
2045
|
+
*/
|
|
2046
|
+
style?: SearchStyleEnum;
|
|
2047
|
+
/**
|
|
2048
|
+
* Callback function to handle search with the query string
|
|
2049
|
+
*/
|
|
2050
|
+
onSearch: SearchCallback;
|
|
2051
|
+
/**
|
|
2052
|
+
* Debounce delay in milliseconds for auto style
|
|
2053
|
+
* @default 300
|
|
2054
|
+
*/
|
|
2055
|
+
debounceMs?: number;
|
|
2056
|
+
/**
|
|
2057
|
+
* Minimum characters required to trigger search in auto style
|
|
2058
|
+
* @default 1
|
|
2059
|
+
*/
|
|
2060
|
+
minCharacters?: number;
|
|
2061
|
+
/**
|
|
2062
|
+
* Show submit button in button style
|
|
2063
|
+
* @default true
|
|
2064
|
+
*/
|
|
2065
|
+
showSubmitButton?: boolean;
|
|
2066
|
+
/**
|
|
2067
|
+
* Show clear button when there is text
|
|
2068
|
+
* @default true
|
|
2069
|
+
*/
|
|
2070
|
+
showClearButton?: boolean;
|
|
2071
|
+
/**
|
|
2072
|
+
* Loading state while search is in progress in auto style
|
|
2073
|
+
* @default false
|
|
2074
|
+
*/
|
|
2075
|
+
loading?: boolean;
|
|
2076
|
+
/**
|
|
2077
|
+
* Provide a way to override the styling
|
|
2078
|
+
*/
|
|
2079
|
+
'component-variant'?: string;
|
|
2080
|
+
};
|
|
2081
|
+
|
|
2082
|
+
/**
|
|
2083
|
+
* Search component with auto and manual search modes
|
|
2084
|
+
*
|
|
2085
|
+
* @param props - The search component props
|
|
2086
|
+
* @param ref - Forward ref to the input element
|
|
2087
|
+
* @returns Search component
|
|
2088
|
+
*/
|
|
2089
|
+
declare const Search: React$1.ForwardRefExoticComponent<Omit<React$1.InputHTMLAttributes<HTMLInputElement>, "value" | "type"> & ControlledFormComponentProps<string> & {
|
|
2090
|
+
style?: SearchStyleEnum;
|
|
2091
|
+
onSearch: SearchCallback;
|
|
2092
|
+
debounceMs?: number;
|
|
2093
|
+
minCharacters?: number;
|
|
2094
|
+
showSubmitButton?: boolean;
|
|
2095
|
+
showClearButton?: boolean;
|
|
2096
|
+
loading?: boolean;
|
|
2097
|
+
'component-variant'?: string;
|
|
2098
|
+
} & React$1.RefAttributes<HTMLInputElement>>;
|
|
2099
|
+
|
|
2030
2100
|
type DropzoneStatus = 'Empty' | 'Loading' | 'Uploaded';
|
|
2031
2101
|
/**
|
|
2032
2102
|
* Dropzone component props
|
|
@@ -2319,11 +2389,15 @@ type RenderStateViewProps<T = unknown, P = any> = {
|
|
|
2319
2389
|
className?: string;
|
|
2320
2390
|
data?: T | null;
|
|
2321
2391
|
isLoading?: boolean;
|
|
2392
|
+
errorData?: Error | string | null;
|
|
2322
2393
|
filled?: React.ComponentType<{
|
|
2323
2394
|
data: T;
|
|
2324
2395
|
} & P>;
|
|
2325
2396
|
empty?: React.ComponentType<P>;
|
|
2326
2397
|
loading?: React.ComponentType<P>;
|
|
2398
|
+
error?: React.ComponentType<{
|
|
2399
|
+
error: Error | string;
|
|
2400
|
+
} & P>;
|
|
2327
2401
|
};
|
|
2328
2402
|
|
|
2329
2403
|
declare const RenderStateView: <T = unknown, P = any>(props: RenderStateViewProps<T, P>) => react_jsx_runtime.JSX.Element;
|
|
@@ -2367,18 +2441,17 @@ declare const RenderStateView: <T = unknown, P = any>(props: RenderStateViewProp
|
|
|
2367
2441
|
* }
|
|
2368
2442
|
* ```
|
|
2369
2443
|
*/
|
|
2370
|
-
declare const useInflateView: <T extends
|
|
2444
|
+
declare const useInflateView: <T extends ComponentType<any>>(Component: T, props: React.ComponentProps<T>) => ReactElement;
|
|
2371
2445
|
|
|
2372
2446
|
/**
|
|
2373
|
-
*
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
* Parameters for the useInflateView hook.
|
|
2447
|
+
* Custom hook that debounces a callback function
|
|
2448
|
+
* @param callback - The function to debounce
|
|
2449
|
+
* @param delay - The debounce delay in milliseconds
|
|
2450
|
+
* @returns Object containing the debounced function and a cancel function
|
|
2378
2451
|
*/
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2452
|
+
declare const useDebounce: <T extends (...args: any[]) => void>(callback: T, delay: number) => {
|
|
2453
|
+
debouncedCallback: (...args: Parameters<T>) => void;
|
|
2454
|
+
cancel: () => void;
|
|
2382
2455
|
};
|
|
2383
2456
|
|
|
2384
2457
|
type ArrowDirectionEnum = 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight';
|
|
@@ -2478,4 +2551,4 @@ declare const NotificationContext: React__default.Context<NotificationContextVal
|
|
|
2478
2551
|
declare const NotificationProvider: React__default.FC<NotificationProviderProps>;
|
|
2479
2552
|
declare const useNotification: () => NotificationContextValue;
|
|
2480
2553
|
|
|
2481
|
-
export { type AccessibilityActions, type AccessibilityProps, Accordion, AccordionDetails, AccordionGroup, AccordionSummary, ActionCard, type ActionCardProps, ActionImage, type ActionImageProps, Breadcrumb, type BreadcrumbProps, Breadcrumbs, type BreadcrumbsProps, Breakpoint, type BreakpointProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, Card, type CardProps, Checkbox, CheckboxItem, type CheckboxItemProps, type CheckboxLabelAlignmentEnum, type CheckboxProps, type CheckboxSizeEnum, type CheckboxTypeEnum, Chip, _default as ChipInput, type ChipInputProps, type ChipListItemProps, type ChipListItemTypeEnum, type ChipProps, ConditionalView, type ConditionalViewProps, ContextMenu, type ContextMenuProps, type CustomTimePickerConfig, CustomToggle, type CustomToggleProps, DatePicker, type DatePickerProps, SortableItem as DraggableItem, SortableTrigger as DraggableItemTrigger, Dropzone, DropzoneClear, DropzoneContent, type DropzoneContentProps, type DropzoneContentTypeEnum, DropzoneFilename, DropzoneFilename as DropzonePreview, type DropzoneProps, DropzoneSupportedFormats as DropzoneReject, DropzoneTrigger as DropzoneRoot, DropzoneSupportedFormats, DropzoneTrigger, type FieldValidationFunction, type FieldValidators, type FieldValue, Form, type FormContextValues, type FormErrors, FormField, type FormFieldProps, type FormProps, type FormProviderProps, type FormState, type FormStateChangeHandler, type FormSubmitHandler, type FormValidator, Grid, GridItem, type GridItemProps, GridList, type GridListProps, type GridProps, Icon, IconButton, type IconButtonProps, type IconButtonStyleEnum, type IconProps, type IconSizeEnum, type IconStyleEnum, Image, type ImageFitEnum, type ImageProps, Input, type InputProps, type InputTypeEnum, List, ListItem, type ListItemProps$1 as ListItemProps, type ListProps, Modal, type ModalComponentProps, ModalFooter, type ModalFooterProps, ModalHeader, type ModalHeaderProps, type ModalProps, ModalProvider, type ModalProviderProps, Nav, NavItem, type NavItemProps, NavLink, type NavLinkProps, type NavProps, type NotificationContainerProps, NotificationContext, NotificationProvider, Option, type OptionProps, type OverlayDirectionEnum, Pagination, PaginationNumberField, type PaginationNumberFieldProps, type PaginationProps, Password, Popover, type PopoverHandle, type PopoverProps, ProgressBar, type ProgressBarProps, RadioButton, RadioButtonItem, type RadioButtonItemProps, type RadioButtonLabelAlignmentEnum, type RadioButtonProps, type RadioButtonSizeEnum, RadioGroup, type RadioGroupProps, RenderStateView, type RenderStateViewProps, RepeaterList, type RepeaterListProps, type RequiredFields, ResponsiveComponent, type ResponsiveComponentProps, Select, SelectListItem, type SelectListItemProps, type SelectProps, SelectProvider, SlideOutPanel, type SlideOutPanelDirectionEnum, type SlideOutPanelProps, type SlideOutPanelSizeEnum, Slider, type SliderProps, Spinner, type SpinnerProps, TabContent, type TabContentProps, TabItem, type TabItemProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHeader, TableHeaderCell, type TableHeaderCellProps, type TableHeaderProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsProps, Text, TextArea, type TextAreaProps, type TextDecorationEnum, type TextProps, type TextTypeEnum, type TextWeightEnum, ThemeContext, type ThemeContextType, ThemeProvider, type ThemeProviderProps, Toggle, ToggleButton, type ToggleButtonProps, type ToggleLabelAlignmentEnum, type ToggleProps, Tooltip, type TooltipProps, type
|
|
2554
|
+
export { type AccessibilityActions, type AccessibilityProps, Accordion, AccordionDetails, AccordionGroup, AccordionSummary, ActionCard, type ActionCardProps, ActionImage, type ActionImageProps, Breadcrumb, type BreadcrumbProps, Breadcrumbs, type BreadcrumbsProps, Breakpoint, type BreakpointProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, Card, type CardProps, Checkbox, CheckboxItem, type CheckboxItemProps, type CheckboxLabelAlignmentEnum, type CheckboxProps, type CheckboxSizeEnum, type CheckboxTypeEnum, Chip, _default as ChipInput, type ChipInputProps, type ChipListItemProps, type ChipListItemTypeEnum, type ChipProps, ConditionalView, type ConditionalViewProps, ContextMenu, type ContextMenuProps, type CustomTimePickerConfig, CustomToggle, type CustomToggleProps, DatePicker, type DatePickerProps, SortableItem as DraggableItem, SortableTrigger as DraggableItemTrigger, Dropzone, DropzoneClear, DropzoneContent, type DropzoneContentProps, type DropzoneContentTypeEnum, DropzoneFilename, DropzoneFilename as DropzonePreview, type DropzoneProps, DropzoneSupportedFormats as DropzoneReject, DropzoneTrigger as DropzoneRoot, DropzoneSupportedFormats, DropzoneTrigger, type FieldValidationFunction, type FieldValidators, type FieldValue, Form, type FormContextValues, type FormErrors, FormField, type FormFieldProps, type FormProps, type FormProviderProps, type FormState, type FormStateChangeHandler, type FormSubmitHandler, type FormValidator, Grid, GridItem, type GridItemProps, GridList, type GridListProps, type GridProps, Icon, IconButton, type IconButtonProps, type IconButtonStyleEnum, type IconProps, type IconSizeEnum, type IconStyleEnum, Image, type ImageFitEnum, type ImageProps, Input, type InputProps, type InputTypeEnum, List, ListItem, type ListItemProps$1 as ListItemProps, type ListProps, Modal, type ModalComponentProps, ModalFooter, type ModalFooterProps, ModalHeader, type ModalHeaderProps, type ModalProps, ModalProvider, type ModalProviderProps, Nav, NavItem, type NavItemProps, NavLink, type NavLinkProps, type NavProps, type NotificationContainerProps, NotificationContext, NotificationProvider, Option, type OptionProps, type OverlayDirectionEnum, Pagination, PaginationNumberField, type PaginationNumberFieldProps, type PaginationProps, Password, Popover, type PopoverHandle, type PopoverProps, ProgressBar, type ProgressBarProps, RadioButton, RadioButtonItem, type RadioButtonItemProps, type RadioButtonLabelAlignmentEnum, type RadioButtonProps, type RadioButtonSizeEnum, RadioGroup, type RadioGroupProps, RenderStateView, type RenderStateViewProps, RepeaterList, type RepeaterListProps, type RequiredFields, ResponsiveComponent, type ResponsiveComponentProps, Search, type SearchCallback, type SearchStyleEnum as SearchModeEnum, type SearchProps, Select, SelectListItem, type SelectListItemProps, type SelectProps, SelectProvider, SlideOutPanel, type SlideOutPanelDirectionEnum, type SlideOutPanelProps, type SlideOutPanelSizeEnum, Slider, type SliderProps, Spinner, type SpinnerProps, TabContent, type TabContentProps, TabItem, type TabItemProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHeader, TableHeaderCell, type TableHeaderCellProps, type TableHeaderProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsProps, Text, TextArea, type TextAreaProps, type TextDecorationEnum, type TextProps, type TextTypeEnum, type TextWeightEnum, ThemeContext, type ThemeContextType, ThemeProvider, type ThemeProviderProps, Toggle, ToggleButton, type ToggleButtonProps, type ToggleLabelAlignmentEnum, type ToggleProps, Tooltip, type TooltipProps, type UseModalReturn, WrapTextNodes, type WrapTextNodesProps, applyPropsToChildren, getClickAccessibilityProps, mergeRefs, useDebounce, useDropzoneContext, useInflateView, useModal, useNotification, useSelectContext, useTab };
|
package/docs/README.md
CHANGED
|
@@ -185,6 +185,9 @@ Combinations of atoms forming more complex UI patterns:
|
|
|
185
185
|
- **[RepeaterList](./docs/components/molecules/RepeaterList.md)** - A simple list rendering component that iterates over an array of data and renders each item using a specified component. It provides a minimal, lightweight approach to rendering collections without additional layout or styling, making it perfect for simple repetitive content rendering.
|
|
186
186
|
- *Aliases: RepeaterList, ItemRepeater, DataRepeater, ComponentRepeater*
|
|
187
187
|
|
|
188
|
+
- **[Search](./docs/components/molecules/Search.md)** - A versatile search input component that supports both automatic and manual search modes. In auto mode, searches are triggered automatically with debouncing as the user types. In manual mode, searches are triggered only when the user presses Enter or clicks the search button. Includes built-in search, clear, and loading states with full keyboard navigation support.
|
|
189
|
+
- *Aliases: Search, SearchInput, SearchField, SearchBox, QueryInput*
|
|
190
|
+
|
|
188
191
|
- **[Select](./docs/components/molecules/Select.md)** - A dropdown selection component that allows users to choose from a list of options. Supports single and multiple selections, custom icons, placeholder text, and integrates seamlessly with form validation. Built with accessibility and keyboard navigation in mind.
|
|
189
192
|
- *Aliases: Select, Dropdown, ComboBox, Picker, OptionList*
|
|
190
193
|
|
|
@@ -254,6 +257,9 @@ React hooks for enhanced functionality:
|
|
|
254
257
|
- **[useInflateView](./docs/components/utils/useInflateView.md)** - A React hook that takes a component type and props and returns a memoized React element. This hook is useful for creating reusable component instances with built-in memoization to prevent unnecessary re-renders when props haven't changed.
|
|
255
258
|
- *Aliases: useInflateView, Component Inflater, Memoized View Hook, Dynamic Component Hook*
|
|
256
259
|
|
|
260
|
+
- **[useDebounce](./docs/components/utils/useDebounce.md)** - A React hook that debounces callback functions, preventing them from being called too frequently. Particularly useful for optimizing performance in scenarios like search inputs, API calls, window resize handlers, or any function that might be triggered rapidly.
|
|
261
|
+
- *Aliases: useDebounce, Debounce Hook, Throttled Callback Hook, Delayed Execution Hook*
|
|
262
|
+
|
|
257
263
|
### Utilities
|
|
258
264
|
Helper components and utilities:
|
|
259
265
|
|
|
@@ -263,69 +263,6 @@ function DisabledExample() {
|
|
|
263
263
|
}
|
|
264
264
|
```
|
|
265
265
|
|
|
266
|
-
### Search Input
|
|
267
|
-
```tsx
|
|
268
|
-
import { IconButton, Icon } from '@delightui/components';
|
|
269
|
-
|
|
270
|
-
function SearchExample() {
|
|
271
|
-
const [searchTerm, setSearchTerm] = useState('');
|
|
272
|
-
const [results, setResults] = useState([]);
|
|
273
|
-
|
|
274
|
-
const handleSearch = useCallback(
|
|
275
|
-
debounce((term) => {
|
|
276
|
-
if (term.length > 2) {
|
|
277
|
-
// Simulate search
|
|
278
|
-
setResults([
|
|
279
|
-
`Result 1 for "${term}"`,
|
|
280
|
-
`Result 2 for "${term}"`,
|
|
281
|
-
`Result 3 for "${term}"`
|
|
282
|
-
]);
|
|
283
|
-
} else {
|
|
284
|
-
setResults([]);
|
|
285
|
-
}
|
|
286
|
-
}, 300),
|
|
287
|
-
[]
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
useEffect(() => {
|
|
291
|
-
handleSearch(searchTerm);
|
|
292
|
-
}, [searchTerm, handleSearch]);
|
|
293
|
-
|
|
294
|
-
const clearSearch = () => {
|
|
295
|
-
setSearchTerm('');
|
|
296
|
-
setResults([]);
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
return (
|
|
300
|
-
<div className="search-input">
|
|
301
|
-
<Input
|
|
302
|
-
leadingIcon={<MagnifyingGlassIcon />}
|
|
303
|
-
trailingIcon={
|
|
304
|
-
searchTerm ? (
|
|
305
|
-
<IconButton onClick={clearSearch} size="Small">
|
|
306
|
-
<Icon icon="Close" />
|
|
307
|
-
</IconButton>
|
|
308
|
-
) : null
|
|
309
|
-
}
|
|
310
|
-
placeholder="Search..."
|
|
311
|
-
value={searchTerm}
|
|
312
|
-
onValueChange={setSearchTerm}
|
|
313
|
-
/>
|
|
314
|
-
|
|
315
|
-
{results.length > 0 && (
|
|
316
|
-
<div className="search-results">
|
|
317
|
-
{results.map((result, index) => (
|
|
318
|
-
<div key={index} className="result-item">
|
|
319
|
-
{result}
|
|
320
|
-
</div>
|
|
321
|
-
))}
|
|
322
|
-
</div>
|
|
323
|
-
)}
|
|
324
|
-
</div>
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
```
|
|
328
|
-
|
|
329
266
|
### Number Input with Validation
|
|
330
267
|
```tsx
|
|
331
268
|
import { Text } from '@delightui/components';
|