react-restyle-components 0.4.46 → 0.4.47
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/lib/index.js +1 -3
- package/lib/src/core-components/index.js +1 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Accordion.js +1 -15
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionContext.js +1 -6
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionSection.js +1 -39
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Header.js +1 -39
- package/lib/src/core-components/src/components/Accordion/AccordionSection/elements.js +57 -94
- package/lib/src/core-components/src/components/Accordion/AccordionSection/hooks/useCurrentAccordionIndex.js +1 -13
- package/lib/src/core-components/src/components/Accordion/AccordionSection/index.js +1 -3
- package/lib/src/core-components/src/components/Accordion/AccordionSection/types.js +1 -9
- package/lib/src/core-components/src/components/Accordion/Collapsible/Collapsible2.component.js +1 -249
- package/lib/src/core-components/src/components/Action/types.js +1 -8
- package/lib/src/core-components/src/components/AlertBanner/AlertBanner.js +1 -45
- package/lib/src/core-components/src/components/AlertBanner/elements.js +45 -120
- package/lib/src/core-components/src/components/AlertBanner/index.js +1 -2
- package/lib/src/core-components/src/components/AlertBanner/types.js +1 -10
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-group-by-multiple-select-multiple-fields-display/auto-complete-filter-group-by-multiple-select-multiple-fields-display.component.js +1 -451
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-multi-fields-display-drag-drop/auto-complete-filter-multi-select-multi-fields-display-drag-drop.component.js +1 -229
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-selected-top-display/auto-complete-filter-multi-select-selected-top-display.component.js +1 -174
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.js +2 -129
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select/auto-complete-filter-single-select.component.js +1 -55
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.js +2 -308
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-group-by/auto-complete-group-by.component.js +1 -115
- package/lib/src/core-components/src/components/AutoComplete/autocomplete/autocomplete.js +2 -442
- package/lib/src/core-components/src/components/AutoComplete/index.js +1 -8
- package/lib/src/core-components/src/components/Avatar/Avatar.js +14 -148
- package/lib/src/core-components/src/components/Badge/Badge.js +2 -25
- package/lib/src/core-components/src/components/Badge/InnerBadge/Inline.js +1 -25
- package/lib/src/core-components/src/components/Badge/InnerBadge/InnerBadge.js +1 -25
- package/lib/src/core-components/src/components/Badge/InnerBadge/elements.js +32 -78
- package/lib/src/core-components/src/components/Badge/InnerBadge/index.js +1 -1
- package/lib/src/core-components/src/components/Badge/index.js +1 -1
- package/lib/src/core-components/src/components/Badge/types.js +1 -5
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.js +1 -83
- package/lib/src/core-components/src/components/Breadcrumb/elements.js +94 -166
- package/lib/src/core-components/src/components/Breadcrumb/index.js +1 -3
- package/lib/src/core-components/src/components/Breadcrumb/types.js +1 -3
- package/lib/src/core-components/src/components/Button/button.component.js +1 -18
- package/lib/src/core-components/src/components/Button/buttonGroup/buttonGroup.component.js +1 -4
- package/lib/src/core-components/src/components/Button/index.js +1 -2
- package/lib/src/core-components/src/components/Button/types.js +1 -1
- package/lib/src/core-components/src/components/Chip/Chip.js +1 -64
- package/lib/src/core-components/src/components/Chip/elements.js +48 -148
- package/lib/src/core-components/src/components/Chip/index.js +1 -2
- package/lib/src/core-components/src/components/Chip/types.js +1 -4
- package/lib/src/core-components/src/components/Divider/Divider.js +1 -25
- package/lib/src/core-components/src/components/Divider/elements.js +31 -68
- package/lib/src/core-components/src/components/Divider/index.js +1 -2
- package/lib/src/core-components/src/components/Divider/types.js +1 -4
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.js +1 -147
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.js +17 -24
- package/lib/src/core-components/src/components/DynamicGrid/elements.js +100 -162
- package/lib/src/core-components/src/components/DynamicGrid/index.js +1 -3
- package/lib/src/core-components/src/components/DynamicGrid/types.js +1 -28
- package/lib/src/core-components/src/components/DynamicGrid/utils.js +1 -193
- package/lib/src/core-components/src/components/FormField/FormField.js +1 -103
- package/lib/src/core-components/src/components/FormField/components/CheckboxGroupInput.js +1 -37
- package/lib/src/core-components/src/components/FormField/components/CheckboxInput.js +1 -8
- package/lib/src/core-components/src/components/FormField/components/CssMultilineInput.js +1 -192
- package/lib/src/core-components/src/components/FormField/components/DatePickerInput.js +1 -99
- package/lib/src/core-components/src/components/FormField/components/DropdownInput.js +1 -70
- package/lib/src/core-components/src/components/FormField/components/OtpInput.js +1 -81
- package/lib/src/core-components/src/components/FormField/components/PasswordInput.js +1 -40
- package/lib/src/core-components/src/components/FormField/components/PinInput.js +1 -75
- package/lib/src/core-components/src/components/FormField/components/RadioInput.js +1 -54
- package/lib/src/core-components/src/components/FormField/components/TextDropdownInput.js +1 -94
- package/lib/src/core-components/src/components/FormField/components/ToggleInput.js +1 -36
- package/lib/src/core-components/src/components/FormField/components/index.js +1 -11
- package/lib/src/core-components/src/components/FormField/css-properties.js +1 -161
- package/lib/src/core-components/src/components/FormField/index.js +1 -2
- package/lib/src/core-components/src/components/Icon/Icon.js +1 -159
- package/lib/src/core-components/src/components/Icon/index.js +1 -2
- package/lib/src/core-components/src/components/Icon/types.js +1 -9
- package/lib/src/core-components/src/components/Loader/loader.component.js +2 -215
- package/lib/src/core-components/src/components/Masonry/Masonry.js +1 -73
- package/lib/src/core-components/src/components/Masonry/elements.js +29 -46
- package/lib/src/core-components/src/components/Masonry/hooks.js +1 -100
- package/lib/src/core-components/src/components/Masonry/index.js +1 -3
- package/lib/src/core-components/src/components/Masonry/types.js +1 -1
- package/lib/src/core-components/src/components/Modal/BasicModal/modal.component.js +1 -116
- package/lib/src/core-components/src/components/Modal/index.js +1 -2
- package/lib/src/core-components/src/components/Modal/modal-confirm/modal-confirm.component.js +1 -147
- package/lib/src/core-components/src/components/Picker/color-picker/color-picker.component.js +1 -12
- package/lib/src/core-components/src/components/Picker/color-picker-modal/color-picker-modal.component.js +1 -40
- package/lib/src/core-components/src/components/Picker/index.js +1 -2
- package/lib/src/core-components/src/components/Selection/index.js +1 -4
- package/lib/src/core-components/src/components/Selection/multi-select/multi-select.component.js +1 -49
- package/lib/src/core-components/src/components/Selection/multi-select-with-field/multi-select-with-field.component.js +1 -58
- package/lib/src/core-components/src/components/Selection/multi-selection-dropdown/multi-selection-dropdown.component.js +1 -43
- package/lib/src/core-components/src/components/Selection/single-select/single-select.component.js +1 -87
- package/lib/src/core-components/src/components/Skeleton/Skeleton.js +1 -51
- package/lib/src/core-components/src/components/Skeleton/elements.js +54 -143
- package/lib/src/core-components/src/components/Skeleton/index.js +1 -2
- package/lib/src/core-components/src/components/Skeleton/types.js +1 -4
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.js +1 -128
- package/lib/src/core-components/src/components/SpeedDial/elements.js +62 -132
- package/lib/src/core-components/src/components/SpeedDial/index.js +1 -2
- package/lib/src/core-components/src/components/SpeedDial/types.js +1 -3
- package/lib/src/core-components/src/components/Stepper2/stepper.component.js +1 -139
- package/lib/src/core-components/src/components/Switch/Switch.js +1 -26
- package/lib/src/core-components/src/components/Switch/elements.js +34 -103
- package/lib/src/core-components/src/components/Switch/index.js +1 -2
- package/lib/src/core-components/src/components/Switch/types.js +1 -3
- package/lib/src/core-components/src/components/Table/Table.js +1 -1489
- package/lib/src/core-components/src/components/Table/columnReorder.js +36 -332
- package/lib/src/core-components/src/components/Table/columnResize.js +21 -284
- package/lib/src/core-components/src/components/Table/elements.js +173 -277
- package/lib/src/core-components/src/components/Table/filters.js +30 -555
- package/lib/src/core-components/src/components/Table/hooks.js +2 -536
- package/lib/src/core-components/src/components/Table/index.js +1 -6
- package/lib/src/core-components/src/components/Table/types.js +1 -1
- package/lib/src/core-components/src/components/Tabs/tabs.component.js +1 -22
- package/lib/src/core-components/src/components/Tags1/Tags.component.js +1 -118
- package/lib/src/core-components/src/components/Tags1/types.js +1 -20
- package/lib/src/core-components/src/components/Timer1/timer.component.js +1 -76
- package/lib/src/core-components/src/components/Toast/Toast.js +1 -50
- package/lib/src/core-components/src/components/Toast/elements.js +41 -122
- package/lib/src/core-components/src/components/Toast/index.js +1 -2
- package/lib/src/core-components/src/components/Toast/types.js +1 -9
- package/lib/src/core-components/src/components/Tooltip/Tooltip.js +1 -200
- package/lib/src/core-components/src/components/Tooltip/elements.js +55 -117
- package/lib/src/core-components/src/components/Tooltip/index.js +1 -2
- package/lib/src/core-components/src/components/Tooltip/types.js +1 -17
- package/lib/src/core-components/src/components/Tooltip/utils.js +1 -140
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.js +1 -303
- package/lib/src/core-components/src/components/TreeSelect/elements.js +117 -216
- package/lib/src/core-components/src/components/TreeSelect/hooks.js +1 -252
- package/lib/src/core-components/src/components/TreeSelect/index.js +1 -3
- package/lib/src/core-components/src/components/TreeSelect/types.js +1 -1
- package/lib/src/core-components/src/components/ag-grid/AgGrid.js +1 -1057
- package/lib/src/core-components/src/components/ag-grid/elements.js +396 -790
- package/lib/src/core-components/src/components/ag-grid/hooks.js +4 -1220
- package/lib/src/core-components/src/components/ag-grid/index.js +1 -15
- package/lib/src/core-components/src/components/ag-grid/types.js +1 -6
- package/lib/src/core-components/src/components/index.js +1 -31
- package/lib/src/core-components/src/components/pdf/pdf-images.components.js +1 -7
- package/lib/src/core-components/src/components/pdf/pdf-table.components.js +5 -48
- package/lib/src/core-components/src/components/pdf/pdf-typography.components.js +1 -70
- package/lib/src/core-components/src/components/pdf/pdf-wrapped-view.components.js +1 -50
- package/lib/src/core-components/src/core-components/Avatar.js +4 -33
- package/lib/src/core-components/src/core-components/CoreButton/CoreButton.js +1 -10
- package/lib/src/core-components/src/core-components/CoreButton/elements.js +67 -176
- package/lib/src/core-components/src/core-components/CoreButton/index.js +1 -3
- package/lib/src/core-components/src/core-components/CoreButton/types.js +1 -6
- package/lib/src/core-components/src/core-components/CoreButton/utils.js +1 -12
- package/lib/src/core-components/src/core-components/Divider/Divider.js +4 -19
- package/lib/src/core-components/src/core-components/Divider/index.js +1 -1
- package/lib/src/core-components/src/core-components/SelectionCardStrip/index.js +1 -1
- package/lib/src/core-components/src/core-components/SelectionCardStrip/selectionCardStrip.js +10 -33
- package/lib/src/core-components/src/core-components/StateLayer.js +3 -5
- package/lib/src/core-components/src/core-components/ToggleCore/elements.js +25 -50
- package/lib/src/core-components/src/core-components/ToggleCore/index.js +1 -2
- package/lib/src/core-components/src/core-components/ToggleCore/toggleCore.js +1 -14
- package/lib/src/core-components/src/core-components/atoms/Input/Input.js +1 -22
- package/lib/src/core-components/src/core-components/atoms/Label/Label.js +1 -21
- package/lib/src/core-components/src/core-components/atoms/Textarea/Textarea.js +1 -19
- package/lib/src/core-components/src/core-components/index.js +1 -3
- package/lib/src/core-components/src/helpers/constants.js +1 -11
- package/lib/src/core-components/src/hooks/index.js +1 -1
- package/lib/src/core-components/src/hooks/outside.hook.js +1 -28
- package/lib/src/core-components/src/index.js +1 -12
- package/lib/src/core-components/src/tc.global.css +1 -0
- package/lib/src/core-components/src/utils/abstracts/breakpoints/index.js +1 -28
- package/lib/src/core-components/src/utils/abstracts/colors/index.js +1 -49
- package/lib/src/core-components/src/utils/abstracts/index.js +1 -5
- package/lib/src/core-components/src/utils/abstracts/space/index.js +1 -26
- package/lib/src/core-components/src/utils/abstracts/theme/ThemeBoundary.js +1 -8
- package/lib/src/core-components/src/utils/abstracts/theme/default-themes.js +1 -30
- package/lib/src/core-components/src/utils/abstracts/theme/index.js +1 -3
- package/lib/src/core-components/src/utils/abstracts/theme/theme.js +1 -30
- package/lib/src/core-components/src/utils/abstracts/theme/types.js +1 -1
- package/lib/src/core-components/src/utils/abstracts/theme/useTheme.js +1 -17
- package/lib/src/core-components/src/utils/abstracts/typography/index.js +1 -25
- package/lib/src/core-components/src/utils/context/DefaultsProvider.js +1 -8
- package/lib/src/core-components/src/utils/context/InternalProvider.js +1 -24
- package/lib/src/core-components/src/utils/context/index.js +1 -2
- package/lib/src/core-components/src/utils/designTokens.js +1 -128
- package/lib/src/core-components/src/utils/helpers/attachSubComponents.js +1 -23
- package/lib/src/core-components/src/utils/helpers/flattenChildren.js +1 -11
- package/lib/src/core-components/src/utils/helpers/getChildByType.js +1 -3
- package/lib/src/core-components/src/utils/helpers/index.js +1 -5
- package/lib/src/core-components/src/utils/helpers/isComponentType.js +1 -16
- package/lib/src/core-components/src/utils/helpers/separateChildrenByType.js +1 -12
- package/lib/src/core-components/src/utils/hooks/index.js +1 -18
- package/lib/src/core-components/src/utils/hooks/useClickOutside.js +1 -18
- package/lib/src/core-components/src/utils/hooks/useCombinedRefs.js +1 -17
- package/lib/src/core-components/src/utils/hooks/useDebouncedCallback.js +1 -12
- package/lib/src/core-components/src/utils/hooks/useDebouncedValue.js +1 -20
- package/lib/src/core-components/src/utils/hooks/useDeprecation.js +1 -40
- package/lib/src/core-components/src/utils/hooks/useDeviceDetect.js +1 -10
- package/lib/src/core-components/src/utils/hooks/useDeviceForm.js +1 -24
- package/lib/src/core-components/src/utils/hooks/useDisableBodyScroll.js +1 -16
- package/lib/src/core-components/src/utils/hooks/useHoverState.js +1 -36
- package/lib/src/core-components/src/utils/hooks/useId.js +1 -7
- package/lib/src/core-components/src/utils/hooks/useIsBrowser.js +1 -11
- package/lib/src/core-components/src/utils/hooks/useMediaQuery.js +1 -16
- package/lib/src/core-components/src/utils/hooks/useOverflow.js +1 -22
- package/lib/src/core-components/src/utils/hooks/useSafeLayoutEffect.js +1 -5
- package/lib/src/core-components/src/utils/hooks/useScrollingUp.js +1 -18
- package/lib/src/core-components/src/utils/hooks/useTrapFocus.js +1 -30
- package/lib/src/core-components/src/utils/hooks/useWindowDimensions.js +1 -23
- package/lib/src/core-components/src/utils/index.js +1 -9
- package/lib/src/core-components/src/utils/stories/Wrappers.js +8 -23
- package/lib/src/core-components/src/utils/stories/cleanProps.js +1 -5
- package/lib/src/core-components/src/utils/stories/index.js +1 -4
- package/lib/src/core-components/src/utils/stories/sleep.js +1 -4
- package/lib/src/core-components/src/utils/stories/view-ports.js +1 -50
- package/lib/src/core-components/src/utils/styling/calcWidthOfColumns.js +1 -5
- package/lib/src/core-components/src/utils/styling/createGridContainer.js +6 -12
- package/lib/src/core-components/src/utils/styling/createTransition.js +2 -7
- package/lib/src/core-components/src/utils/styling/forwardProps.js +1 -10
- package/lib/src/core-components/src/utils/styling/index.js +1 -5
- package/lib/src/core-components/src/utils/styling/pxToRem.js +1 -6
- package/lib/src/core-components/src/utils/testing/getComputedStyle.js +1 -3
- package/lib/src/core-components/src/utils/testing/index.js +1 -1
- package/lib/src/core-components/src/utils/utility.util.js +1 -14
- package/lib/src/core-components/tailwind.config.js +1 -233
- package/lib/src/core-hooks/index.js +1 -3
- package/lib/src/core-hooks/src/useClickOutside/useClickOutside.hook.js +1 -46
- package/lib/src/core-hooks/src/useDebounce/useDebounce.hook.js +1 -30
- package/lib/src/core-hooks/src/usePreventEKey/usePreventEKey.hook.js +1 -8
- package/lib/src/core-utils/index.js +1 -7
- package/lib/src/core-utils/src/calculation/calculation.util.js +1 -89
- package/lib/src/core-utils/src/colors/color.util.js +1 -15
- package/lib/src/core-utils/src/convert/numberToWords/numToWords.util.js +1 -145
- package/lib/src/core-utils/src/convert/typography/camelCaseToTitleCase.util.js +1 -5
- package/lib/src/core-utils/src/form-helper/form-helper.util.js +1 -82
- package/lib/src/core-utils/src/index.js +1 -7
- package/lib/src/core-utils/src/utility/utility.util.js +1 -12
- package/lib/src/core-utils/src/uuid/uuid.util.js +1 -8
- package/package.json +1 -1
|
@@ -1,273 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
|
-
import { Icon } from '../../Icon/Icon';
|
|
4
|
-
import s from '../../../tc.module.css';
|
|
5
|
-
import { cn } from '../../../utils';
|
|
6
|
-
const DEFAULT_ITEM_HEIGHT = 34;
|
|
7
|
-
export const Autocomplete = ({ value = '', onValueChange, options = [], filterConfig = {}, displayConfig = {}, keyboardConfig = {}, uiConfig = {}, hasError = false, disabled = false, name, className, style, inputClassName, onInputValueChange, onOpen, onClose, onSelect, autoFocus = false, }) => {
|
|
8
|
-
// Merge configs with defaults
|
|
9
|
-
const { enabled: filterEnabled = true, caseSensitive = false, filterFn, minCharacters = 0, } = filterConfig;
|
|
10
|
-
const { renderOption, renderEmptyState, highlightActive = true, activeOptionClassName, optionClassName, } = displayConfig;
|
|
11
|
-
const { enabled: keyboardEnabled = true, selectKeys = ['Enter'], closeKeys = ['Escape'], enterToSelect = true, escapeToClose = true, } = keyboardConfig;
|
|
12
|
-
const { placeholder = 'Search...', emptyStateMessage = 'Not Found Result!!', itemHeight = DEFAULT_ITEM_HEIGHT, maxHeight, zIndex = 999, showOnFocus = true, showOnClick = true, autoSelectFirst = true, } = uiConfig;
|
|
13
|
-
// Helper to get option label (moved outside to avoid dependency issues)
|
|
14
|
-
const getOptionLabel = useCallback((option) => {
|
|
15
|
-
return typeof option === 'string' ? option : option.label;
|
|
16
|
-
}, []);
|
|
17
|
-
// Helper to get option value (moved outside to avoid dependency issues)
|
|
18
|
-
const getOptionValue = useCallback((option) => {
|
|
19
|
-
return typeof option === 'string' ? option : String(option.value);
|
|
20
|
-
}, []);
|
|
21
|
-
// Find initial active option index
|
|
22
|
-
const getInitialActiveIndex = useCallback(() => {
|
|
23
|
-
if (!value || options.length === 0)
|
|
24
|
-
return 0;
|
|
25
|
-
const index = options.findIndex((opt) => getOptionValue(opt) === value || getOptionLabel(opt) === value);
|
|
26
|
-
return index !== -1 ? index : 0;
|
|
27
|
-
}, [value, options, getOptionValue, getOptionLabel]);
|
|
28
|
-
const [activeOption, setActiveOption] = useState(() => {
|
|
29
|
-
if (!value || options.length === 0)
|
|
30
|
-
return 0;
|
|
31
|
-
const index = options.findIndex((opt) => (typeof opt === 'string' ? opt : String(opt.value)) === value ||
|
|
32
|
-
(typeof opt === 'string' ? opt : opt.label) === value);
|
|
33
|
-
return index !== -1 ? index : 0;
|
|
34
|
-
});
|
|
35
|
-
// Initialize filtered options - will be updated by useEffect
|
|
36
|
-
const [filteredOptions, setFilteredOptions] = useState(options);
|
|
37
|
-
const [shouldShowList, setShouldShowList] = useState(false);
|
|
38
|
-
const [searchValue, setSearchValue] = useState(value);
|
|
39
|
-
const inputRef = useRef(null);
|
|
40
|
-
const listRef = useRef(null);
|
|
41
|
-
const wrapperRef = useRef(null);
|
|
42
|
-
// Track if user is actively typing to prevent value prop from overwriting input
|
|
43
|
-
const isTypingRef = useRef(false);
|
|
44
|
-
const typingTimeoutRef = useRef(null);
|
|
45
|
-
// Filter function
|
|
46
|
-
const filterOptions = useCallback((searchValue) => {
|
|
47
|
-
if (!filterEnabled)
|
|
48
|
-
return options;
|
|
49
|
-
// If search is empty and minCharacters is 0, show all options
|
|
50
|
-
if (searchValue.length === 0 && minCharacters === 0)
|
|
51
|
-
return options;
|
|
52
|
-
// If search length is less than minCharacters, return empty array or all options
|
|
53
|
-
if (searchValue.length < minCharacters) {
|
|
54
|
-
return minCharacters === 0 ? options : [];
|
|
55
|
-
}
|
|
56
|
-
// Use custom filter function if provided
|
|
57
|
-
if (filterFn) {
|
|
58
|
-
return options.filter((option) => filterFn(option, searchValue));
|
|
59
|
-
}
|
|
60
|
-
// Default filtering: case-insensitive substring match
|
|
61
|
-
const lowerSearch = caseSensitive
|
|
62
|
-
? searchValue.trim()
|
|
63
|
-
: searchValue.trim().toLowerCase();
|
|
64
|
-
if (lowerSearch.length === 0)
|
|
65
|
-
return options;
|
|
66
|
-
return options.filter((option) => {
|
|
67
|
-
const label = getOptionLabel(option);
|
|
68
|
-
const matchText = caseSensitive
|
|
69
|
-
? label.trim()
|
|
70
|
-
: label.trim().toLowerCase();
|
|
71
|
-
return matchText.includes(lowerSearch);
|
|
72
|
-
});
|
|
73
|
-
}, [
|
|
74
|
-
options,
|
|
75
|
-
filterEnabled,
|
|
76
|
-
caseSensitive,
|
|
77
|
-
filterFn,
|
|
78
|
-
minCharacters,
|
|
79
|
-
getOptionLabel,
|
|
80
|
-
]);
|
|
81
|
-
const onInputChange = useCallback((event) => {
|
|
82
|
-
const input = event.target.value;
|
|
83
|
-
// Mark that user is typing
|
|
84
|
-
isTypingRef.current = true;
|
|
85
|
-
// Clear existing timeout
|
|
86
|
-
if (typingTimeoutRef.current) {
|
|
87
|
-
clearTimeout(typingTimeoutRef.current);
|
|
88
|
-
}
|
|
89
|
-
// Reset typing flag after user stops typing (300ms)
|
|
90
|
-
typingTimeoutRef.current = setTimeout(() => {
|
|
91
|
-
isTypingRef.current = false;
|
|
92
|
-
}, 300);
|
|
93
|
-
// Call onInputValueChange callback
|
|
94
|
-
if (onInputValueChange) {
|
|
95
|
-
onInputValueChange(input);
|
|
96
|
-
}
|
|
97
|
-
// Update search value immediately for responsive UI
|
|
98
|
-
setSearchValue(input);
|
|
99
|
-
// Filter options
|
|
100
|
-
const filtered = filterOptions(input);
|
|
101
|
-
setFilteredOptions(filtered);
|
|
102
|
-
// Reset active option to first item or 0
|
|
103
|
-
setActiveOption(filtered.length > 0 ? 0 : 0);
|
|
104
|
-
// Show list if there are filtered options or if input is not empty
|
|
105
|
-
if (filtered.length > 0 || input.length > 0) {
|
|
106
|
-
setShouldShowList(true);
|
|
107
|
-
}
|
|
108
|
-
// Don't auto-select when user is typing - only update the input value
|
|
109
|
-
// Auto-select should only happen on initial load or when dropdown opens
|
|
110
|
-
}, [filterOptions, onInputValueChange]);
|
|
111
|
-
const handleOptionSelect = useCallback((option, index) => {
|
|
112
|
-
const label = getOptionLabel(option);
|
|
113
|
-
setShouldShowList(false);
|
|
114
|
-
setActiveOption(0);
|
|
115
|
-
setFilteredOptions([]);
|
|
116
|
-
setSearchValue(label);
|
|
117
|
-
onValueChange(option);
|
|
118
|
-
if (onSelect) {
|
|
119
|
-
onSelect(option);
|
|
120
|
-
}
|
|
121
|
-
if (onClose) {
|
|
122
|
-
onClose();
|
|
123
|
-
}
|
|
124
|
-
}, [onValueChange, onSelect, onClose]);
|
|
125
|
-
const onOptionClick = useCallback((event) => {
|
|
126
|
-
const index = parseInt(event.currentTarget.getAttribute('data-index') || '0', 10);
|
|
127
|
-
const option = filteredOptions[index];
|
|
128
|
-
if (option) {
|
|
129
|
-
handleOptionSelect(option, index);
|
|
130
|
-
}
|
|
131
|
-
}, [filteredOptions, handleOptionSelect]);
|
|
132
|
-
const onKeyDown = useCallback((event) => {
|
|
133
|
-
if (!keyboardEnabled)
|
|
134
|
-
return;
|
|
135
|
-
const key = event.key;
|
|
136
|
-
const keyCode = event.keyCode;
|
|
137
|
-
// Arrow Up
|
|
138
|
-
if (keyCode === 38 || key === 'ArrowUp') {
|
|
139
|
-
event.preventDefault();
|
|
140
|
-
if (activeOption > 0) {
|
|
141
|
-
const newIndex = activeOption - 1;
|
|
142
|
-
const option = filteredOptions[newIndex];
|
|
143
|
-
setActiveOption(newIndex);
|
|
144
|
-
setSearchValue(getOptionLabel(option));
|
|
145
|
-
listRef.current?.scroll({
|
|
146
|
-
top: itemHeight * newIndex,
|
|
147
|
-
behavior: 'smooth',
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
// Arrow Down
|
|
153
|
-
if (keyCode === 40 || key === 'ArrowDown') {
|
|
154
|
-
event.preventDefault();
|
|
155
|
-
if (activeOption < filteredOptions.length - 1) {
|
|
156
|
-
const newIndex = activeOption + 1;
|
|
157
|
-
const option = filteredOptions[newIndex];
|
|
158
|
-
setActiveOption(newIndex);
|
|
159
|
-
setSearchValue(getOptionLabel(option));
|
|
160
|
-
listRef.current?.scroll({
|
|
161
|
-
top: itemHeight * newIndex,
|
|
162
|
-
behavior: 'smooth',
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
// Enter to select
|
|
168
|
-
if ((keyCode === 13 || key === 'Enter') && enterToSelect) {
|
|
169
|
-
event.preventDefault();
|
|
170
|
-
if (filteredOptions.length > 0 && activeOption >= 0) {
|
|
171
|
-
const option = filteredOptions[activeOption];
|
|
172
|
-
handleOptionSelect(option, activeOption);
|
|
173
|
-
}
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
// Escape to close
|
|
177
|
-
if ((keyCode === 27 || key === 'Escape') && escapeToClose) {
|
|
178
|
-
event.preventDefault();
|
|
179
|
-
setShouldShowList(false);
|
|
180
|
-
if (onClose) {
|
|
181
|
-
onClose();
|
|
182
|
-
}
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
// Other select keys
|
|
186
|
-
if (selectKeys.includes(key) &&
|
|
187
|
-
filteredOptions.length > 0 &&
|
|
188
|
-
activeOption >= 0) {
|
|
189
|
-
event.preventDefault();
|
|
190
|
-
const option = filteredOptions[activeOption];
|
|
191
|
-
handleOptionSelect(option, activeOption);
|
|
192
|
-
}
|
|
193
|
-
// Close keys
|
|
194
|
-
if (closeKeys.includes(key)) {
|
|
195
|
-
event.preventDefault();
|
|
196
|
-
setShouldShowList(false);
|
|
197
|
-
if (onClose) {
|
|
198
|
-
onClose();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}, [
|
|
202
|
-
keyboardEnabled,
|
|
203
|
-
activeOption,
|
|
204
|
-
filteredOptions,
|
|
205
|
-
itemHeight,
|
|
206
|
-
enterToSelect,
|
|
207
|
-
escapeToClose,
|
|
208
|
-
selectKeys,
|
|
209
|
-
closeKeys,
|
|
210
|
-
handleOptionSelect,
|
|
211
|
-
onClose,
|
|
212
|
-
]);
|
|
213
|
-
const handleInputFocus = useCallback(() => {
|
|
214
|
-
if (showOnFocus && !shouldShowList) {
|
|
215
|
-
// Update filtered options when opening
|
|
216
|
-
const filtered = filterOptions(searchValue);
|
|
217
|
-
setFilteredOptions(filtered);
|
|
218
|
-
setShouldShowList(true);
|
|
219
|
-
if (onOpen) {
|
|
220
|
-
onOpen();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}, [showOnFocus, shouldShowList, onOpen, filterOptions, searchValue]);
|
|
224
|
-
const handleInputClick = useCallback(() => {
|
|
225
|
-
if (showOnClick && !shouldShowList) {
|
|
226
|
-
// Update filtered options when opening
|
|
227
|
-
const filtered = filterOptions(searchValue);
|
|
228
|
-
setFilteredOptions(filtered);
|
|
229
|
-
setShouldShowList(true);
|
|
230
|
-
if (onOpen) {
|
|
231
|
-
onOpen();
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}, [showOnClick, shouldShowList, onOpen, filterOptions, searchValue]);
|
|
235
|
-
const handleIconClick = useCallback(() => {
|
|
236
|
-
if (disabled)
|
|
237
|
-
return;
|
|
238
|
-
if (shouldShowList) {
|
|
239
|
-
// Close dropdown
|
|
240
|
-
setShouldShowList(false);
|
|
241
|
-
if (onClose) {
|
|
242
|
-
onClose();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
// Open dropdown
|
|
247
|
-
const filtered = filterOptions(searchValue);
|
|
248
|
-
setFilteredOptions(filtered);
|
|
249
|
-
setShouldShowList(true);
|
|
250
|
-
// Focus input when opening via icon
|
|
251
|
-
inputRef.current?.focus();
|
|
252
|
-
if (onOpen) {
|
|
253
|
-
onOpen();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}, [disabled, shouldShowList, onOpen, onClose, filterOptions, searchValue]);
|
|
257
|
-
const renderList = () => {
|
|
258
|
-
if (!shouldShowList)
|
|
259
|
-
return null;
|
|
260
|
-
return (_jsxs("div", { className: cn(s['absolute'], s['w-full'], s['rounded-lg'], s['bg-white'], s['border'], s['border-gray-200'], s['shadow-lg'], s['overflow-hidden']), style: {
|
|
261
|
-
position: 'absolute',
|
|
262
|
-
top: 'calc(100% + 0.5rem)',
|
|
263
|
-
left: 0,
|
|
264
|
-
right: 0,
|
|
265
|
-
margin: 0,
|
|
266
|
-
padding: 0,
|
|
267
|
-
zIndex,
|
|
268
|
-
animation: 'fadeIn 0.15s ease-out',
|
|
269
|
-
transformOrigin: 'top',
|
|
270
|
-
}, children: [_jsx("style", { children: `
|
|
1
|
+
"use strict";import{jsx as f,Fragment as Se,jsxs as j}from"react/jsx-runtime";import{useState as R,useRef as D,useEffect as L,useCallback as h}from"react";import{Icon as z}from"../../Icon/Icon";import e from"../../../tc.module.css";import{cn as d}from"../../../utils";const ve=34;export const Autocomplete=({value:i="",onValueChange:O,options:o=[],filterConfig:ne={},displayConfig:ie={},keyboardConfig:le={},uiConfig:se={},hasError:k=!1,disabled:w=!1,name:oe,className:ce,style:ae,inputClassName:fe,onInputValueChange:H,onOpen:y,onClose:u,onSelect:M,autoFocus:G=!1})=>{const{enabled:q=!0,caseSensitive:_=!1,filterFn:K,minCharacters:A=0}=ne,{renderOption:B,renderEmptyState:J,highlightActive:C=!0,activeOptionClassName:ue,optionClassName:de}=ie,{enabled:P=!0,selectKeys:Q=["Enter"],closeKeys:X=["Escape"],enterToSelect:Z=!0,escapeToClose:V=!0}=le,{placeholder:me="Search...",emptyStateMessage:ge="Not Found Result!!",itemHeight:U=ve,maxHeight:he,zIndex:pe=999,showOnFocus:ee=!0,showOnClick:te=!0,autoSelectFirst:re=!0}=se,m=h(t=>typeof t=="string"?t:t.label,[]),T=h(t=>typeof t=="string"?t:String(t.value),[]),Ne=h(()=>{if(!i||o.length===0)return 0;const t=o.findIndex(r=>T(r)===i||m(r)===i);return t!==-1?t:0},[i,o,T,m]),[c,I]=R(()=>{if(!i||o.length===0)return 0;const t=o.findIndex(r=>(typeof r=="string"?r:String(r.value))===i||(typeof r=="string"?r:r.label)===i);return t!==-1?t:0}),[a,S]=R(o),[l,b]=R(!1),[g,v]=R(i),E=D(null),W=D(null),Y=D(null),$=D(!1),N=D(null),p=h(t=>{if(!q||t.length===0&&A===0)return o;if(t.length<A)return A===0?o:[];if(K)return o.filter(n=>K(n,t));const r=_?t.trim():t.trim().toLowerCase();return r.length===0?o:o.filter(n=>{const s=m(n);return(_?s.trim():s.trim().toLowerCase()).includes(r)})},[o,q,_,K,A,m]),xe=h(t=>{const r=t.target.value;$.current=!0,N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{$.current=!1},300),H&&H(r),v(r);const n=p(r);S(n),I((n.length>0,0)),(n.length>0||r.length>0)&&b(!0)},[p,H]),F=h((t,r)=>{const n=m(t);b(!1),I(0),S([]),v(n),O(t),M&&M(t),u&&u()},[O,M,u]),ye=h(t=>{const r=parseInt(t.currentTarget.getAttribute("data-index")||"0",10),n=a[r];n&&F(n,r)},[a,F]),be=h(t=>{if(!P)return;const r=t.key,n=t.keyCode;if(n===38||r==="ArrowUp"){if(t.preventDefault(),c>0){const s=c-1,x=a[s];I(s),v(m(x)),W.current?.scroll({top:U*s,behavior:"smooth"})}return}if(n===40||r==="ArrowDown"){if(t.preventDefault(),c<a.length-1){const s=c+1,x=a[s];I(s),v(m(x)),W.current?.scroll({top:U*s,behavior:"smooth"})}return}if((n===13||r==="Enter")&&Z){if(t.preventDefault(),a.length>0&&c>=0){const s=a[c];F(s,c)}return}if((n===27||r==="Escape")&&V){t.preventDefault(),b(!1),u&&u();return}if(Q.includes(r)&&a.length>0&&c>=0){t.preventDefault();const s=a[c];F(s,c)}X.includes(r)&&(t.preventDefault(),b(!1),u&&u())},[P,c,a,U,Z,V,Q,X,F,u]),we=h(()=>{if(ee&&!l){const t=p(g);S(t),b(!0),y&&y()}},[ee,l,y,p,g]),Ie=h(()=>{if(te&&!l){const t=p(g);S(t),b(!0),y&&y()}},[te,l,y,p,g]),ke=h(()=>{if(!w)if(l)b(!1),u&&u();else{const t=p(g);S(t),b(!0),E.current?.focus(),y&&y()}},[w,l,y,u,p,g]),Te=()=>l?j("div",{className:d(e.absolute,e["w-full"],e["rounded-lg"],e["bg-white"],e.border,e["border-gray-200"],e["shadow-lg"],e["overflow-hidden"]),style:{position:"absolute",top:"calc(100% + 0.5rem)",left:0,right:0,margin:0,padding:0,zIndex:pe,animation:"fadeIn 0.15s ease-out",transformOrigin:"top"},children:[f("style",{children:`
|
|
271
2
|
@keyframes fadeIn {
|
|
272
3
|
from {
|
|
273
4
|
opacity: 0;
|
|
@@ -278,175 +9,4 @@ export const Autocomplete = ({ value = '', onValueChange, options = [], filterCo
|
|
|
278
9
|
transform: translateY(0) scale(1);
|
|
279
10
|
}
|
|
280
11
|
}
|
|
281
|
-
` }),
|
|
282
|
-
maxHeight: maxHeight || '300px',
|
|
283
|
-
scrollbarWidth: 'thin',
|
|
284
|
-
margin: 0,
|
|
285
|
-
padding: 0,
|
|
286
|
-
listStyle: 'none',
|
|
287
|
-
}, children: filteredOptions.map((option, index) => {
|
|
288
|
-
const isActive = highlightActive && index === activeOption;
|
|
289
|
-
let itemClassName = cn(s['flex'], s['items-center'], s['px-4'], s['py-3'], s['cursor-pointer'], s['text-sm'], s['transition-all'], s['duration-150'], s['ease-in-out'], optionClassName);
|
|
290
|
-
if (isActive && highlightActive) {
|
|
291
|
-
itemClassName = cn(itemClassName, s['bg-blue-50'], s['text-blue-700'], s['font-medium'], activeOptionClassName);
|
|
292
|
-
}
|
|
293
|
-
return (_jsx("li", { className: itemClassName, role: "option", "aria-selected": isActive, id: `autocomplete-option-${index}`, "data-index": index, onClick: onOptionClick, onMouseEnter: () => setActiveOption(index), style: {
|
|
294
|
-
margin: 0,
|
|
295
|
-
padding: '0.75rem 1rem',
|
|
296
|
-
listStyle: 'none',
|
|
297
|
-
transition: 'background-color 0.15s ease, color 0.15s ease',
|
|
298
|
-
backgroundColor: isActive && highlightActive
|
|
299
|
-
? 'rgb(239, 246, 255)'
|
|
300
|
-
: 'transparent',
|
|
301
|
-
color: isActive && highlightActive
|
|
302
|
-
? 'rgb(29, 78, 216)'
|
|
303
|
-
: 'rgb(55, 65, 81)',
|
|
304
|
-
}, onMouseOver: (e) => {
|
|
305
|
-
if (!isActive) {
|
|
306
|
-
e.currentTarget.style.backgroundColor =
|
|
307
|
-
'rgb(239, 246, 255)';
|
|
308
|
-
e.currentTarget.style.color = 'rgb(29, 78, 216)';
|
|
309
|
-
}
|
|
310
|
-
}, onMouseOut: (e) => {
|
|
311
|
-
if (!isActive) {
|
|
312
|
-
e.currentTarget.style.backgroundColor = 'transparent';
|
|
313
|
-
e.currentTarget.style.color = 'rgb(55, 65, 81)';
|
|
314
|
-
}
|
|
315
|
-
}, children: renderOption ? (renderOption(option, index, isActive)) : (_jsx("span", { className: cn(s['select-none']), children: getOptionLabel(option) })) }, index));
|
|
316
|
-
}) })) : (_jsx("div", { className: cn(s['flex'], s['flex-col'], s['items-center'], s['justify-center'], s['px-4'], s['py-3'], s['text-center']), style: {
|
|
317
|
-
margin: 0,
|
|
318
|
-
padding: 0,
|
|
319
|
-
}, children: renderEmptyState ? (renderEmptyState()) : (_jsxs(_Fragment, { children: [_jsx(Icon, { nameIcon: "FaSearch", propsIcon: {
|
|
320
|
-
size: 32,
|
|
321
|
-
color: '#9ca3af',
|
|
322
|
-
} }), _jsx("p", { className: cn(s['mt-3'], s['text-sm'], s['font-medium'], s['text-gray-500']), children: emptyStateMessage }), _jsx("p", { className: cn(s['mt-1'], s['text-xs'], s['text-gray-400']), children: "Try adjusting your search" })] })) }))] }));
|
|
323
|
-
};
|
|
324
|
-
// Update filtered options when options or search value changes
|
|
325
|
-
useEffect(() => {
|
|
326
|
-
const filtered = filterOptions(searchValue);
|
|
327
|
-
setFilteredOptions(filtered);
|
|
328
|
-
// Update active option if current value is in filtered options
|
|
329
|
-
if (filtered.length > 0) {
|
|
330
|
-
const currentIndex = filtered.findIndex((opt) => getOptionValue(opt) === value || getOptionLabel(opt) === value);
|
|
331
|
-
if (currentIndex !== -1) {
|
|
332
|
-
setActiveOption(currentIndex);
|
|
333
|
-
}
|
|
334
|
-
else if (activeOption >= filtered.length) {
|
|
335
|
-
// Reset to first option if current active is out of bounds
|
|
336
|
-
setActiveOption(0);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
else if (filtered.length === 0 && searchValue.length === 0) {
|
|
340
|
-
// If no search and no filtered results, reset active option
|
|
341
|
-
setActiveOption(0);
|
|
342
|
-
}
|
|
343
|
-
}, [
|
|
344
|
-
options,
|
|
345
|
-
searchValue,
|
|
346
|
-
filterOptions,
|
|
347
|
-
value,
|
|
348
|
-
activeOption,
|
|
349
|
-
getOptionValue,
|
|
350
|
-
getOptionLabel,
|
|
351
|
-
]);
|
|
352
|
-
// Auto-focus and auto-select first option on mount
|
|
353
|
-
useEffect(() => {
|
|
354
|
-
if (autoFocus) {
|
|
355
|
-
setTimeout(() => {
|
|
356
|
-
inputRef.current?.focus();
|
|
357
|
-
inputRef.current?.select();
|
|
358
|
-
}, 0);
|
|
359
|
-
}
|
|
360
|
-
if (autoSelectFirst && filteredOptions.length > 0 && !value) {
|
|
361
|
-
onValueChange(filteredOptions[0]);
|
|
362
|
-
}
|
|
363
|
-
}, [autoFocus, autoSelectFirst, filteredOptions, value, onValueChange]);
|
|
364
|
-
// Update search value when value prop changes (but not when user is actively typing)
|
|
365
|
-
useEffect(() => {
|
|
366
|
-
// Don't sync if user is currently typing
|
|
367
|
-
if (isTypingRef.current) {
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
// Only sync if value prop changed and doesn't match current search
|
|
371
|
-
if (value !== searchValue) {
|
|
372
|
-
const matchingOption = options.find((opt) => getOptionValue(opt) === value || getOptionLabel(opt) === value);
|
|
373
|
-
if (matchingOption) {
|
|
374
|
-
setSearchValue(getOptionLabel(matchingOption));
|
|
375
|
-
}
|
|
376
|
-
else if (value) {
|
|
377
|
-
setSearchValue(value);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}, [value, options, searchValue, getOptionValue, getOptionLabel]);
|
|
381
|
-
// Handle click outside to close dropdown
|
|
382
|
-
useEffect(() => {
|
|
383
|
-
function handleClickOutside(event) {
|
|
384
|
-
if (wrapperRef.current &&
|
|
385
|
-
!wrapperRef.current.contains(event.target) &&
|
|
386
|
-
shouldShowList) {
|
|
387
|
-
setShouldShowList(false);
|
|
388
|
-
if (onClose) {
|
|
389
|
-
onClose();
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
if (shouldShowList) {
|
|
394
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
395
|
-
}
|
|
396
|
-
return () => {
|
|
397
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
398
|
-
};
|
|
399
|
-
}, [shouldShowList, onClose]);
|
|
400
|
-
// Cleanup typing timeout on unmount
|
|
401
|
-
useEffect(() => {
|
|
402
|
-
return () => {
|
|
403
|
-
if (typingTimeoutRef.current) {
|
|
404
|
-
clearTimeout(typingTimeoutRef.current);
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
}, []);
|
|
408
|
-
return (_jsxs("div", { ref: wrapperRef, className: cn(s['flex'], s['flex-col'], s['relative'], s['w-full'], className), style: {
|
|
409
|
-
...style,
|
|
410
|
-
position: 'relative',
|
|
411
|
-
margin: 0,
|
|
412
|
-
}, children: [_jsx("div", { className: cn(s['flex'], s['items-center'], s['relative'], s['w-full'], s['bg-white'], s['border'], s['rounded-lg'], s['shadow-sm'], s['transition-all'], s['duration-200'], s['ease-in-out'], s['overflow-hidden'], {
|
|
413
|
-
[s['border-red-500']]: hasError,
|
|
414
|
-
[s['border-gray-300']]: !hasError && !shouldShowList,
|
|
415
|
-
[s['border-blue-500']]: !hasError && shouldShowList,
|
|
416
|
-
[s['ring-2']]: !hasError && shouldShowList,
|
|
417
|
-
[s['ring-blue-200']]: !hasError && shouldShowList,
|
|
418
|
-
[s['opacity-50']]: disabled,
|
|
419
|
-
[s['cursor-not-allowed']]: disabled,
|
|
420
|
-
}), style: {
|
|
421
|
-
boxShadow: shouldShowList && !hasError
|
|
422
|
-
? '0 0 0 3px rgba(59, 130, 246, 0.1)'
|
|
423
|
-
: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
424
|
-
overflow: 'hidden',
|
|
425
|
-
}, children: _jsxs("div", { className: cn(s['flex'], s['items-center'], s['w-full'], s['relative']), style: {
|
|
426
|
-
padding: '0.5rem 0.75rem',
|
|
427
|
-
minWidth: 0,
|
|
428
|
-
}, children: [_jsx("div", { className: cn(s['mr-2'], s['flex-shrink-0']), style: { display: 'flex', alignItems: 'center' }, children: _jsx(Icon, { nameIcon: "FaSearch", propsIcon: {
|
|
429
|
-
size: 18,
|
|
430
|
-
color: shouldShowList ? '#3b82f6' : '#9ca3af',
|
|
431
|
-
} }) }), _jsx("input", { type: "text", role: "combobox", "aria-autocomplete": "list", "aria-expanded": shouldShowList, "aria-controls": "autocomplete-list", "aria-activedescendant": shouldShowList && activeOption >= 0
|
|
432
|
-
? `autocomplete-option-${activeOption}`
|
|
433
|
-
: undefined, name: name || 'autocomplete-input', className: cn(s['flex-1'], s['bg-transparent'], s['text-sm'], s['text-gray-700'], s['placeholder-gray-400'], s['focus:outline-none'], s['border-none'], s['focus:ring-0'], inputClassName), placeholder: placeholder, onChange: onInputChange, onKeyDown: onKeyDown, onFocus: handleInputFocus, onClick: handleInputClick, value: searchValue, ref: inputRef, disabled: disabled, autoComplete: "off", style: {
|
|
434
|
-
cursor: disabled ? 'not-allowed' : 'text',
|
|
435
|
-
minWidth: 0,
|
|
436
|
-
flex: '1 1 0%',
|
|
437
|
-
width: 0,
|
|
438
|
-
} }), _jsx("div", { className: cn(s['flex-shrink-0'], s['flex'], s['items-center'], s['justify-center'], s['cursor-pointer']), onClick: handleIconClick, style: {
|
|
439
|
-
marginLeft: '0.5rem',
|
|
440
|
-
transition: 'transform 0.2s ease',
|
|
441
|
-
display: 'flex',
|
|
442
|
-
alignItems: 'center',
|
|
443
|
-
justifyContent: 'center',
|
|
444
|
-
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
445
|
-
}, children: shouldShowList ? (_jsx(Icon, { nameIcon: "FaChevronUp", propsIcon: {
|
|
446
|
-
size: 16,
|
|
447
|
-
color: disabled ? '#9ca3af' : '#3b82f6',
|
|
448
|
-
} })) : (_jsx(Icon, { nameIcon: "FaChevronDown", propsIcon: {
|
|
449
|
-
size: 16,
|
|
450
|
-
color: '#9ca3af',
|
|
451
|
-
} })) })] }) }), renderList()] }));
|
|
452
|
-
};
|
|
12
|
+
`}),a.length>0?f("ul",{role:"listbox",className:d(e.flex,e["flex-col"],e["w-full"],e["overflow-y-auto"],e["overflow-x-hidden"]),id:"autocomplete-list",ref:W,style:{maxHeight:he||"300px",scrollbarWidth:"thin",margin:0,padding:0,listStyle:"none"},children:a.map((t,r)=>{const n=C&&r===c;let s=d(e.flex,e["items-center"],e["px-4"],e["py-3"],e["cursor-pointer"],e["text-sm"],e["transition-all"],e["duration-150"],e["ease-in-out"],de);return n&&C&&(s=d(s,e["bg-blue-50"],e["text-blue-700"],e["font-medium"],ue)),f("li",{className:s,role:"option","aria-selected":n,id:`autocomplete-option-${r}`,"data-index":r,onClick:ye,onMouseEnter:()=>I(r),style:{margin:0,padding:"0.75rem 1rem",listStyle:"none",transition:"background-color 0.15s ease, color 0.15s ease",backgroundColor:n&&C?"rgb(239, 246, 255)":"transparent",color:n&&C?"rgb(29, 78, 216)":"rgb(55, 65, 81)"},onMouseOver:x=>{n||(x.currentTarget.style.backgroundColor="rgb(239, 246, 255)",x.currentTarget.style.color="rgb(29, 78, 216)")},onMouseOut:x=>{n||(x.currentTarget.style.backgroundColor="transparent",x.currentTarget.style.color="rgb(55, 65, 81)")},children:B?B(t,r,n):f("span",{className:d(e["select-none"]),children:m(t)})},r)})}):f("div",{className:d(e.flex,e["flex-col"],e["items-center"],e["justify-center"],e["px-4"],e["py-3"],e["text-center"]),style:{margin:0,padding:0},children:J?J():j(Se,{children:[f(z,{nameIcon:"FaSearch",propsIcon:{size:32,color:"#9ca3af"}}),f("p",{className:d(e["mt-3"],e["text-sm"],e["font-medium"],e["text-gray-500"]),children:ge}),f("p",{className:d(e["mt-1"],e["text-xs"],e["text-gray-400"]),children:"Try adjusting your search"})]})})]}):null;return L(()=>{const t=p(g);if(S(t),t.length>0){const r=t.findIndex(n=>T(n)===i||m(n)===i);r!==-1?I(r):c>=t.length&&I(0)}else t.length===0&&g.length===0&&I(0)},[o,g,p,i,c,T,m]),L(()=>{G&&setTimeout(()=>{E.current?.focus(),E.current?.select()},0),re&&a.length>0&&!i&&O(a[0])},[G,re,a,i,O]),L(()=>{if(!$.current&&i!==g){const t=o.find(r=>T(r)===i||m(r)===i);t?v(m(t)):i&&v(i)}},[i,o,g,T,m]),L(()=>{function t(r){Y.current&&!Y.current.contains(r.target)&&l&&(b(!1),u&&u())}return l&&document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[l,u]),L(()=>()=>{N.current&&clearTimeout(N.current)},[]),j("div",{ref:Y,className:d(e.flex,e["flex-col"],e.relative,e["w-full"],ce),style:{...ae,position:"relative",margin:0},children:[f("div",{className:d(e.flex,e["items-center"],e.relative,e["w-full"],e["bg-white"],e.border,e["rounded-lg"],e["shadow-sm"],e["transition-all"],e["duration-200"],e["ease-in-out"],e["overflow-hidden"],{[e["border-red-500"]]:k,[e["border-gray-300"]]:!k&&!l,[e["border-blue-500"]]:!k&&l,[e["ring-2"]]:!k&&l,[e["ring-blue-200"]]:!k&&l,[e["opacity-50"]]:w,[e["cursor-not-allowed"]]:w}),style:{boxShadow:l&&!k?"0 0 0 3px rgba(59, 130, 246, 0.1)":"0 1px 2px 0 rgba(0, 0, 0, 0.05)",overflow:"hidden"},children:j("div",{className:d(e.flex,e["items-center"],e["w-full"],e.relative),style:{padding:"0.5rem 0.75rem",minWidth:0},children:[f("div",{className:d(e["mr-2"],e["flex-shrink-0"]),style:{display:"flex",alignItems:"center"},children:f(z,{nameIcon:"FaSearch",propsIcon:{size:18,color:l?"#3b82f6":"#9ca3af"}})}),f("input",{type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":l,"aria-controls":"autocomplete-list","aria-activedescendant":l&&c>=0?`autocomplete-option-${c}`:void 0,name:oe||"autocomplete-input",className:d(e["flex-1"],e["bg-transparent"],e["text-sm"],e["text-gray-700"],e["placeholder-gray-400"],e["focus:outline-none"],e["border-none"],e["focus:ring-0"],fe),placeholder:me,onChange:xe,onKeyDown:be,onFocus:we,onClick:Ie,value:g,ref:E,disabled:w,autoComplete:"off",style:{cursor:w?"not-allowed":"text",minWidth:0,flex:"1 1 0%",width:0}}),f("div",{className:d(e["flex-shrink-0"],e.flex,e["items-center"],e["justify-center"],e["cursor-pointer"]),onClick:ke,style:{marginLeft:"0.5rem",transition:"transform 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center",cursor:w?"not-allowed":"pointer"},children:l?f(z,{nameIcon:"FaChevronUp",propsIcon:{size:16,color:w?"#9ca3af":"#3b82f6"}}):f(z,{nameIcon:"FaChevronDown",propsIcon:{size:16,color:"#9ca3af"}})})]})}),Te()]})};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component';
|
|
3
|
-
export * from './autocomplete/autocomplete';
|
|
4
|
-
export * from './auto-complete-group-by/auto-complete-group-by.component';
|
|
5
|
-
export * from './auto-complete-filter-single-select/auto-complete-filter-single-select.component';
|
|
6
|
-
export * from './auto-complete-filter-multi-select-selected-top-display/auto-complete-filter-multi-select-selected-top-display.component';
|
|
7
|
-
export * from './auto-complete-filter-multi-select-multi-fields-display-drag-drop/auto-complete-filter-multi-select-multi-fields-display-drag-drop.component';
|
|
8
|
-
export * from './auto-complete-filter-group-by-multiple-select-multiple-fields-display/auto-complete-filter-group-by-multiple-select-multiple-fields-display.component';
|
|
1
|
+
"use strict";export*from"./auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component";export*from"./auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component";export*from"./autocomplete/autocomplete";export*from"./auto-complete-group-by/auto-complete-group-by.component";export*from"./auto-complete-filter-single-select/auto-complete-filter-single-select.component";export*from"./auto-complete-filter-multi-select-selected-top-display/auto-complete-filter-multi-select-selected-top-display.component";export*from"./auto-complete-filter-multi-select-multi-fields-display-drag-drop/auto-complete-filter-multi-select-multi-fields-display-drag-drop.component";export*from"./auto-complete-filter-group-by-multiple-select-multiple-fields-display/auto-complete-filter-group-by-multiple-select-multiple-fields-display.component";
|