react-restyle-components 0.3.66 → 0.3.68
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/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.d.ts +100 -12
- 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.d.ts.map +1 -1
- 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 +85 -51
- 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.d.ts +108 -7
- 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.d.ts.map +1 -1
- 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 +154 -60
- package/lib/src/core-components/src/components/AutoComplete/autocomplete/autocomplete.d.ts +104 -6
- package/lib/src/core-components/src/components/AutoComplete/autocomplete/autocomplete.d.ts.map +1 -1
- package/lib/src/core-components/src/components/AutoComplete/autocomplete/autocomplete.js +261 -71
- package/lib/src/core-components/src/components/Loader/loader.component.d.ts +13 -1
- package/lib/src/core-components/src/components/Loader/loader.component.d.ts.map +1 -1
- package/lib/src/core-components/src/components/Loader/loader.component.js +134 -3
- package/lib/src/core-components/src/components/check-box/checkBox.component.d.ts.map +1 -1
- package/lib/src/core-components/src/components/check-box/checkBox.component.js +2 -2
- package/lib/src/core-components/src/components/date-picker/date-picker.component.js +2 -2
- package/lib/src/core-components/src/components/radio/radio.component.js +2 -2
- package/lib/src/core-components/src/components/stepper/stepper.component.d.ts +54 -6
- package/lib/src/core-components/src/components/stepper/stepper.component.d.ts.map +1 -1
- package/lib/src/core-components/src/components/stepper/stepper.component.js +127 -19
- package/lib/src/core-components/src/components/timer/timer.component.js +2 -2
- package/lib/src/core-components/src/tc.global.css +7 -1
- package/lib/src/core-components/src/tc.module.css +3 -1036
- package/package.json +1 -1
- package/lib/src/core-components/src/library/assets/svg/CheckedBox.svg +0 -14
- package/lib/src/core-components/src/library/assets/svg/DownArrow.svg +0 -14
- package/lib/src/core-components/src/library/assets/svg/UnCheckbox.svg +0 -3
- package/lib/src/core-components/src/library/assets/svg/UpArrow.svg +0 -14
- package/lib/src/core-components/src/library/assets/svg/checkedRadio.svg +0 -13
- package/lib/src/core-components/src/library/assets/svg/datePicker.svg +0 -3
- package/lib/src/core-components/src/library/assets/svg/index.d.ts +0 -10
- package/lib/src/core-components/src/library/assets/svg/index.d.ts.map +0 -1
- package/lib/src/core-components/src/library/assets/svg/index.js +0 -28
- package/lib/src/core-components/src/library/assets/svg/timer copy.svg +0 -3
- package/lib/src/core-components/src/library/assets/svg/timer.svg +0 -3
- package/lib/src/core-components/src/library/assets/svg/uncheckRadio.svg +0 -3
|
@@ -1,108 +1,298 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
|
+
import { Icon } from '../../';
|
|
3
4
|
import s from '../../../tc.module.css';
|
|
4
5
|
import { cn } from '../../../utils';
|
|
5
|
-
const
|
|
6
|
-
export const Autocomplete = ({ value = '', onValueChange, options = [], }) => {
|
|
7
|
-
|
|
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
|
+
});
|
|
8
35
|
const [filteredOptions, setFilteredOptions] = useState(options);
|
|
9
36
|
const [shouldShowList, setShouldShowList] = useState(false);
|
|
10
37
|
const [searchValue, setSearchValue] = useState(value);
|
|
11
38
|
const inputRef = useRef(null);
|
|
12
39
|
const listRef = useRef(null);
|
|
40
|
+
// Filter function
|
|
41
|
+
const filterOptions = useCallback((searchValue) => {
|
|
42
|
+
if (!filterEnabled)
|
|
43
|
+
return options;
|
|
44
|
+
if (searchValue.length < minCharacters)
|
|
45
|
+
return options;
|
|
46
|
+
if (filterFn) {
|
|
47
|
+
return options.filter((option) => filterFn(option, searchValue));
|
|
48
|
+
}
|
|
49
|
+
const lowerSearch = caseSensitive
|
|
50
|
+
? searchValue
|
|
51
|
+
: searchValue.toLowerCase();
|
|
52
|
+
return options.filter((option) => {
|
|
53
|
+
const label = getOptionLabel(option);
|
|
54
|
+
const matchText = caseSensitive ? label : label.toLowerCase();
|
|
55
|
+
return matchText.indexOf(lowerSearch) > -1;
|
|
56
|
+
});
|
|
57
|
+
}, [
|
|
58
|
+
options,
|
|
59
|
+
filterEnabled,
|
|
60
|
+
caseSensitive,
|
|
61
|
+
filterFn,
|
|
62
|
+
minCharacters,
|
|
63
|
+
getOptionLabel,
|
|
64
|
+
]);
|
|
13
65
|
const onInputChange = useCallback((event) => {
|
|
14
66
|
const input = event.target.value;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
setFilteredOptions(options);
|
|
67
|
+
// Call onInputValueChange callback
|
|
68
|
+
if (onInputValueChange) {
|
|
69
|
+
onInputValueChange(input);
|
|
21
70
|
}
|
|
71
|
+
// Filter options
|
|
72
|
+
const filtered = filterOptions(input);
|
|
73
|
+
setFilteredOptions(filtered);
|
|
22
74
|
setActiveOption(0);
|
|
23
75
|
setShouldShowList(true);
|
|
24
76
|
setSearchValue(input);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const onOptionClick = useCallback((event) => {
|
|
33
|
-
const symbol = event.currentTarget.innerText || event.currentTarget.textContent || '';
|
|
77
|
+
// Auto-select first option if enabled
|
|
78
|
+
if (autoSelectFirst && filtered.length > 0) {
|
|
79
|
+
onValueChange(filtered[0]);
|
|
80
|
+
}
|
|
81
|
+
}, [filterOptions, onInputValueChange, onValueChange, autoSelectFirst]);
|
|
82
|
+
const handleOptionSelect = useCallback((option, index) => {
|
|
83
|
+
const label = getOptionLabel(option);
|
|
34
84
|
setShouldShowList(false);
|
|
35
85
|
setActiveOption(0);
|
|
36
86
|
setFilteredOptions([]);
|
|
37
|
-
setSearchValue(
|
|
38
|
-
onValueChange(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
]);
|
|
87
|
+
setSearchValue(label);
|
|
88
|
+
onValueChange(option);
|
|
89
|
+
if (onSelect) {
|
|
90
|
+
onSelect(option);
|
|
91
|
+
}
|
|
92
|
+
if (onClose) {
|
|
93
|
+
onClose();
|
|
94
|
+
}
|
|
95
|
+
}, [onValueChange, onSelect, onClose]);
|
|
96
|
+
const onOptionClick = useCallback((event) => {
|
|
97
|
+
const index = parseInt(event.currentTarget.getAttribute('data-index') || '0', 10);
|
|
98
|
+
const option = filteredOptions[index];
|
|
99
|
+
if (option) {
|
|
100
|
+
handleOptionSelect(option, index);
|
|
101
|
+
}
|
|
102
|
+
}, [filteredOptions, handleOptionSelect]);
|
|
46
103
|
const onKeyDown = useCallback((event) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
104
|
+
if (!keyboardEnabled)
|
|
105
|
+
return;
|
|
106
|
+
const key = event.key;
|
|
107
|
+
const keyCode = event.keyCode;
|
|
108
|
+
// Arrow Up
|
|
109
|
+
if (keyCode === 38 || key === 'ArrowUp') {
|
|
50
110
|
event.preventDefault();
|
|
51
|
-
if (activeOption
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
setSearchValue(filteredOptions[activeOption - 1]);
|
|
57
|
-
setActiveOption(activeOption - 1);
|
|
111
|
+
if (activeOption > 0) {
|
|
112
|
+
const newIndex = activeOption - 1;
|
|
113
|
+
const option = filteredOptions[newIndex];
|
|
114
|
+
setActiveOption(newIndex);
|
|
115
|
+
setSearchValue(getOptionLabel(option));
|
|
58
116
|
listRef.current?.scroll({
|
|
59
|
-
top:
|
|
117
|
+
top: itemHeight * newIndex,
|
|
118
|
+
behavior: 'smooth',
|
|
60
119
|
});
|
|
61
120
|
}
|
|
121
|
+
return;
|
|
62
122
|
}
|
|
63
|
-
|
|
64
|
-
|
|
123
|
+
// Arrow Down
|
|
124
|
+
if (keyCode === 40 || key === 'ArrowDown') {
|
|
65
125
|
event.preventDefault();
|
|
66
|
-
if (activeOption
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
setSearchValue(filteredOptions[activeOption + 1]);
|
|
72
|
-
setActiveOption(activeOption + 1);
|
|
126
|
+
if (activeOption < filteredOptions.length - 1) {
|
|
127
|
+
const newIndex = activeOption + 1;
|
|
128
|
+
const option = filteredOptions[newIndex];
|
|
129
|
+
setActiveOption(newIndex);
|
|
130
|
+
setSearchValue(getOptionLabel(option));
|
|
73
131
|
listRef.current?.scroll({
|
|
74
|
-
top:
|
|
132
|
+
top: itemHeight * newIndex,
|
|
133
|
+
behavior: 'smooth',
|
|
75
134
|
});
|
|
76
135
|
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// Enter to select
|
|
139
|
+
if ((keyCode === 13 || key === 'Enter') && enterToSelect) {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
if (filteredOptions.length > 0 && activeOption >= 0) {
|
|
142
|
+
const option = filteredOptions[activeOption];
|
|
143
|
+
handleOptionSelect(option, activeOption);
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
77
146
|
}
|
|
78
|
-
|
|
79
|
-
|
|
147
|
+
// Escape to close
|
|
148
|
+
if ((keyCode === 27 || key === 'Escape') && escapeToClose) {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
setShouldShowList(false);
|
|
151
|
+
if (onClose) {
|
|
152
|
+
onClose();
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// Other select keys
|
|
157
|
+
if (selectKeys.includes(key) &&
|
|
158
|
+
filteredOptions.length > 0 &&
|
|
159
|
+
activeOption >= 0) {
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
const option = filteredOptions[activeOption];
|
|
162
|
+
handleOptionSelect(option, activeOption);
|
|
163
|
+
}
|
|
164
|
+
// Close keys
|
|
165
|
+
if (closeKeys.includes(key)) {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
setShouldShowList(false);
|
|
168
|
+
if (onClose) {
|
|
169
|
+
onClose();
|
|
170
|
+
}
|
|
80
171
|
}
|
|
81
172
|
}, [
|
|
82
|
-
|
|
83
|
-
setSearchValue,
|
|
84
|
-
filteredOptions,
|
|
173
|
+
keyboardEnabled,
|
|
85
174
|
activeOption,
|
|
86
|
-
|
|
175
|
+
filteredOptions,
|
|
176
|
+
itemHeight,
|
|
177
|
+
enterToSelect,
|
|
178
|
+
escapeToClose,
|
|
179
|
+
selectKeys,
|
|
180
|
+
closeKeys,
|
|
181
|
+
handleOptionSelect,
|
|
182
|
+
onClose,
|
|
87
183
|
]);
|
|
184
|
+
const handleInputFocus = useCallback(() => {
|
|
185
|
+
if (showOnFocus && !shouldShowList) {
|
|
186
|
+
setShouldShowList(true);
|
|
187
|
+
if (onOpen) {
|
|
188
|
+
onOpen();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}, [showOnFocus, shouldShowList, onOpen]);
|
|
192
|
+
const handleInputClick = useCallback(() => {
|
|
193
|
+
if (showOnClick && !shouldShowList) {
|
|
194
|
+
setShouldShowList(true);
|
|
195
|
+
if (onOpen) {
|
|
196
|
+
onOpen();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}, [showOnClick, shouldShowList, onOpen]);
|
|
88
200
|
const renderList = () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
201
|
+
if (!shouldShowList)
|
|
202
|
+
return null;
|
|
203
|
+
return (_jsxs("div", { className: cn(s['absolute'], s['w-full'], s['mt-1'], s['rounded-lg'], s['bg-white'], s['border'], s['border-gray-200'], s['shadow-lg'], s['overflow-hidden'], 'animate-fade-in'), style: {
|
|
204
|
+
zIndex,
|
|
205
|
+
animation: 'fadeIn 0.15s ease-out',
|
|
206
|
+
transformOrigin: 'top',
|
|
207
|
+
}, children: [_jsx("style", { children: `
|
|
208
|
+
@keyframes fadeIn {
|
|
209
|
+
from {
|
|
210
|
+
opacity: 0;
|
|
211
|
+
transform: translateY(-8px) scale(0.98);
|
|
212
|
+
}
|
|
213
|
+
to {
|
|
214
|
+
opacity: 1;
|
|
215
|
+
transform: translateY(0) scale(1);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
` }), filteredOptions.length > 0 ? (_jsx("ul", { role: "listbox", className: cn(s['flex'], s['flex-col'], s['py-1'], s['w-full'], s['overflow-y-auto'], s['overflow-x-hidden']), id: "autocomplete-list", ref: listRef, style: {
|
|
219
|
+
maxHeight: maxHeight || '300px',
|
|
220
|
+
scrollbarWidth: 'thin',
|
|
221
|
+
}, children: filteredOptions.map((option, index) => {
|
|
222
|
+
const isActive = highlightActive && index === activeOption;
|
|
223
|
+
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, 'hover:bg-blue-50', 'hover:text-blue-700');
|
|
224
|
+
if (isActive && highlightActive) {
|
|
225
|
+
itemClassName = cn(itemClassName, s['bg-blue-50'], s['text-blue-700'], s['font-medium'], 'border-l-4', 'border-blue-500', activeOptionClassName);
|
|
226
|
+
}
|
|
227
|
+
return (_jsx("li", { className: itemClassName, role: "option", "aria-selected": isActive, id: `autocomplete-option-${index}`, "data-index": index, onClick: onOptionClick, onMouseEnter: () => setActiveOption(index), style: {
|
|
228
|
+
transition: 'background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease',
|
|
229
|
+
}, children: renderOption ? (renderOption(option, index, isActive)) : (_jsx("span", { className: cn(s['text-gray-700'], s['select-none']), children: getOptionLabel(option) })) }, index));
|
|
230
|
+
}) })) : (_jsx("div", { className: cn(s['flex'], s['flex-col'], s['items-center'], s['justify-center'], s['py-8'], s['px-4'], s['text-center']), children: renderEmptyState ? (renderEmptyState()) : (_jsxs(_Fragment, { children: [_jsx(Icon, { nameIcon: "FaSearch", propsIcon: {
|
|
231
|
+
size: 32,
|
|
232
|
+
color: '#9ca3af',
|
|
233
|
+
} }), _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" })] })) }))] }));
|
|
96
234
|
};
|
|
235
|
+
// Update filtered options when options change
|
|
97
236
|
useEffect(() => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
237
|
+
const filtered = filterOptions(searchValue);
|
|
238
|
+
setFilteredOptions(filtered);
|
|
239
|
+
// Update active option if current value is not in filtered options
|
|
240
|
+
if (filtered.length > 0) {
|
|
241
|
+
const currentIndex = filtered.findIndex((opt) => getOptionValue(opt) === value || getOptionLabel(opt) === value);
|
|
242
|
+
if (currentIndex !== -1 && currentIndex !== activeOption) {
|
|
243
|
+
setActiveOption(currentIndex);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}, [options, searchValue, filterOptions, value, activeOption]);
|
|
247
|
+
// Auto-focus and auto-select first option on mount
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
if (autoFocus) {
|
|
250
|
+
setTimeout(() => {
|
|
251
|
+
inputRef.current?.focus();
|
|
252
|
+
inputRef.current?.select();
|
|
253
|
+
}, 0);
|
|
254
|
+
}
|
|
255
|
+
if (autoSelectFirst && filteredOptions.length > 0 && !value) {
|
|
256
|
+
onValueChange(filteredOptions[0]);
|
|
257
|
+
}
|
|
258
|
+
}, [autoFocus, autoSelectFirst, filteredOptions, value, onValueChange]);
|
|
259
|
+
// Update search value when value prop changes
|
|
260
|
+
useEffect(() => {
|
|
261
|
+
if (value !== searchValue) {
|
|
262
|
+
const matchingOption = options.find((opt) => getOptionValue(opt) === value || getOptionLabel(opt) === value);
|
|
263
|
+
if (matchingOption) {
|
|
264
|
+
setSearchValue(getOptionLabel(matchingOption));
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
setSearchValue(value);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}, [value, options, searchValue]);
|
|
271
|
+
return (_jsxs("div", { className: cn(s['flex'], s['flex-col'], s['relative'], s['w-full'], className), style: style, 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'], {
|
|
272
|
+
[s['border-red-500']]: hasError,
|
|
273
|
+
[s['border-gray-300']]: !hasError && !shouldShowList,
|
|
274
|
+
'border-blue-500': !hasError && shouldShowList,
|
|
275
|
+
'ring-2': !hasError && shouldShowList,
|
|
276
|
+
'ring-blue-200': !hasError && shouldShowList,
|
|
277
|
+
[s['opacity-50']]: disabled,
|
|
278
|
+
[s['cursor-not-allowed']]: disabled,
|
|
279
|
+
'hover:border-gray-400': !hasError && !disabled && !shouldShowList,
|
|
280
|
+
}), style: {
|
|
281
|
+
boxShadow: shouldShowList && !hasError
|
|
282
|
+
? '0 0 0 3px rgba(59, 130, 246, 0.1)'
|
|
283
|
+
: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
284
|
+
}, children: _jsxs("div", { className: cn(s['flex'], s['items-center'], s['px-3'], s['py-2']), children: [_jsx("div", { className: cn(s['mr-2'], s['flex-shrink-0']), children: _jsx(Icon, { nameIcon: "FaSearch", propsIcon: {
|
|
285
|
+
size: 18,
|
|
286
|
+
color: shouldShowList ? '#3b82f6' : '#9ca3af',
|
|
287
|
+
} }) }), _jsx("input", { type: "text", role: "combobox", "aria-autocomplete": "list", "aria-expanded": shouldShowList, "aria-controls": "autocomplete-list", "aria-activedescendant": shouldShowList && activeOption >= 0
|
|
288
|
+
? `autocomplete-option-${activeOption}`
|
|
289
|
+
: undefined, name: name || 'autocomplete-input', className: cn(s['flex'], s['flex-1'], s['w-full'], 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: {
|
|
290
|
+
cursor: disabled ? 'not-allowed' : 'text',
|
|
291
|
+
} }), _jsx("div", { className: cn(s['ml-2'], s['flex-shrink-0']), style: { transition: 'transform 0.2s ease' }, children: shouldShowList ? (_jsx(Icon, { nameIcon: "FaChevronUp", propsIcon: {
|
|
292
|
+
size: 16,
|
|
293
|
+
color: '#3b82f6',
|
|
294
|
+
} })) : (_jsx(Icon, { nameIcon: "FaChevronDown", propsIcon: {
|
|
295
|
+
size: 16,
|
|
296
|
+
color: '#9ca3af',
|
|
297
|
+
} })) })] }) }), renderList()] }));
|
|
108
298
|
};
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
export type LoaderVariant = 'spinner' | 'dots' | 'bars' | 'pulse';
|
|
2
|
+
export type LoaderSize = 'sm' | 'md' | 'lg';
|
|
1
3
|
export interface LoadingAnimateSpinProps {
|
|
4
|
+
/** Wrapper className for positioning */
|
|
2
5
|
classWarper?: string;
|
|
6
|
+
/** Additional className for the loader element */
|
|
3
7
|
className?: string;
|
|
8
|
+
/** Variant of loader: spinner, dots, bars, or pulse */
|
|
9
|
+
variant?: LoaderVariant;
|
|
10
|
+
/** Size of the loader: sm, md, or lg */
|
|
11
|
+
size?: LoaderSize;
|
|
12
|
+
/** Color variant - uses CSS classes from tc.module.css */
|
|
13
|
+
color?: 'blue' | 'green' | 'gray' | 'primary';
|
|
14
|
+
/** Accessibility label */
|
|
15
|
+
'aria-label'?: string;
|
|
4
16
|
}
|
|
5
|
-
export declare const LoadingAnimateSpin: ({ classWarper, className, }: LoadingAnimateSpinProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const LoadingAnimateSpin: ({ classWarper, className, variant, size, color, "aria-label": ariaLabel, }: LoadingAnimateSpinProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
18
|
//# sourceMappingURL=loader.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.component.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/Loader/loader.component.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.component.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/Loader/loader.component.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,wCAAwC;IACxC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IAC9C,0BAA0B;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAuCD,eAAO,MAAM,kBAAkB,+EAO5B,uBAAuB,4CA8LzB,CAAC"}
|
|
@@ -1,6 +1,137 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import s from '../../tc.module.css';
|
|
3
3
|
import { cn } from '../../utils';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const sizeClasses = {
|
|
5
|
+
sm: {
|
|
6
|
+
wrapper: cn(s['w-4'], s['h-4']),
|
|
7
|
+
spinner: cn(s['w-4'], s['h-4']),
|
|
8
|
+
dots: cn(s['w-1'], s['h-1']),
|
|
9
|
+
bars: cn(s['w-1'], s['h-6']),
|
|
10
|
+
pulse: cn(s['w-4'], s['h-4']),
|
|
11
|
+
},
|
|
12
|
+
md: {
|
|
13
|
+
wrapper: cn(s['w-8'], s['h-8']),
|
|
14
|
+
spinner: cn(s['w-8'], s['h-8']),
|
|
15
|
+
dots: cn(s['w-2'], s['h-2']),
|
|
16
|
+
bars: cn(s['w-1'], s['h-8']),
|
|
17
|
+
pulse: cn(s['w-8'], s['h-8']),
|
|
18
|
+
},
|
|
19
|
+
lg: {
|
|
20
|
+
wrapper: cn(s['w-10'], s['h-10']),
|
|
21
|
+
spinner: cn(s['w-10'], s['h-10']),
|
|
22
|
+
dots: cn(s['w-3'], s['h-3']),
|
|
23
|
+
bars: cn(s['w-2'], s['h-10']),
|
|
24
|
+
pulse: cn(s['w-10'], s['h-10']),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const getColorValue = (color) => {
|
|
28
|
+
const colors = {
|
|
29
|
+
blue: 'rgb(59 130 246)',
|
|
30
|
+
green: 'rgb(34 197 94)',
|
|
31
|
+
gray: 'rgb(156 163 175)',
|
|
32
|
+
primary: 'rgb(59 130 246)',
|
|
33
|
+
};
|
|
34
|
+
return colors[color] || colors.blue;
|
|
35
|
+
};
|
|
36
|
+
export const LoadingAnimateSpin = ({ classWarper = '', className = '', variant = 'spinner', size = 'md', color = 'blue', 'aria-label': ariaLabel = 'Loading', }) => {
|
|
37
|
+
const sizeConfig = sizeClasses[size];
|
|
38
|
+
const renderSpinner = () => {
|
|
39
|
+
const colorValue = getColorValue(color);
|
|
40
|
+
// Extract RGB values for opacity border - making it more subtle
|
|
41
|
+
const rgbMatch = colorValue.match(/\d+/g);
|
|
42
|
+
const baseBorderColor = rgbMatch
|
|
43
|
+
? `rgba(${rgbMatch[0]}, ${rgbMatch[1]}, ${rgbMatch[2]}, 0.15)`
|
|
44
|
+
: 'rgba(255, 255, 255, 0.15)';
|
|
45
|
+
return (_jsxs("div", { className: cn(s['flex'], s['flex-col'], s['items-center'], s['justify-center'], className), "aria-label": ariaLabel, role: "status", children: [_jsx("div", { className: cn(sizeConfig.spinner, s['rounded-full'], s['animate-spin']), style: {
|
|
46
|
+
width: '4rem',
|
|
47
|
+
height: '4rem',
|
|
48
|
+
borderWidth: '10px',
|
|
49
|
+
borderStyle: 'solid',
|
|
50
|
+
borderTopColor: colorValue,
|
|
51
|
+
borderRightColor: colorValue,
|
|
52
|
+
borderBottomColor: baseBorderColor,
|
|
53
|
+
borderLeftColor: baseBorderColor,
|
|
54
|
+
animation: 'spin 1s linear infinite',
|
|
55
|
+
} }), _jsx("p", { className: cn(s['mt-4'], s['text-white'], s['text-lg'], s['font-semibold'], s['animate-pulse']), style: {
|
|
56
|
+
marginTop: '1rem',
|
|
57
|
+
color: colorValue,
|
|
58
|
+
fontSize: '1.125rem',
|
|
59
|
+
fontWeight: 600,
|
|
60
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
61
|
+
}, children: "Loading..." })] }));
|
|
62
|
+
};
|
|
63
|
+
const renderDots = () => {
|
|
64
|
+
const colorValue = getColorValue(color);
|
|
65
|
+
return (_jsx("div", { className: cn(s['flex'], s['gap-2'], s['items-center'], className), "aria-label": ariaLabel, role: "status", children: [0, 1, 2].map((i) => (_jsx("div", { className: cn(sizeConfig.dots, s['rounded-full']), style: {
|
|
66
|
+
backgroundColor: colorValue,
|
|
67
|
+
animation: `bounce 1.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite`,
|
|
68
|
+
animationDelay: `${i * 0.16}s`,
|
|
69
|
+
animationFillMode: 'both',
|
|
70
|
+
} }, i))) }));
|
|
71
|
+
};
|
|
72
|
+
const renderBars = () => {
|
|
73
|
+
const colorValue = getColorValue(color);
|
|
74
|
+
return (_jsx("div", { className: cn(s['flex'], s['gap-1'], s['items-center'], className), "aria-label": ariaLabel, role: "status", children: [0, 1, 2].map((i) => (_jsx("div", { className: cn(sizeConfig.bars, s.rounded), style: {
|
|
75
|
+
backgroundColor: colorValue,
|
|
76
|
+
borderRadius: '0.125rem',
|
|
77
|
+
animation: `pulse 1.2s ease-in-out infinite`,
|
|
78
|
+
animationDelay: `${i * 0.15}s`,
|
|
79
|
+
animationFillMode: 'both',
|
|
80
|
+
} }, i))) }));
|
|
81
|
+
};
|
|
82
|
+
const renderPulse = () => {
|
|
83
|
+
const colorValue = getColorValue(color);
|
|
84
|
+
return (_jsx("div", { className: cn(sizeConfig.pulse, s['rounded-full'], className), style: {
|
|
85
|
+
backgroundColor: colorValue,
|
|
86
|
+
animation: `pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite`,
|
|
87
|
+
animationFillMode: 'both',
|
|
88
|
+
}, "aria-label": ariaLabel, role: "status" }));
|
|
89
|
+
};
|
|
90
|
+
const renderLoader = () => {
|
|
91
|
+
switch (variant) {
|
|
92
|
+
case 'dots':
|
|
93
|
+
return renderDots();
|
|
94
|
+
case 'bars':
|
|
95
|
+
return renderBars();
|
|
96
|
+
case 'pulse':
|
|
97
|
+
return renderPulse();
|
|
98
|
+
case 'spinner':
|
|
99
|
+
default:
|
|
100
|
+
return renderSpinner();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return (_jsxs("div", { className: cn(s['absolute'], s['inset-0'], s['flex'], s['justify-center'], s['items-center'], classWarper), children: [_jsx("style", { children: `
|
|
104
|
+
@keyframes spin {
|
|
105
|
+
from {
|
|
106
|
+
transform: rotate(0deg);
|
|
107
|
+
}
|
|
108
|
+
to {
|
|
109
|
+
transform: rotate(360deg);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
@keyframes pulse {
|
|
113
|
+
0% {
|
|
114
|
+
opacity: 1;
|
|
115
|
+
transform: scale(1);
|
|
116
|
+
}
|
|
117
|
+
50% {
|
|
118
|
+
opacity: 0.5;
|
|
119
|
+
transform: scale(0.95);
|
|
120
|
+
}
|
|
121
|
+
100% {
|
|
122
|
+
opacity: 1;
|
|
123
|
+
transform: scale(1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
@keyframes bounce {
|
|
127
|
+
0%, 100% {
|
|
128
|
+
transform: translateY(0) scale(1);
|
|
129
|
+
opacity: 1;
|
|
130
|
+
}
|
|
131
|
+
50% {
|
|
132
|
+
transform: translateY(-10px) scale(1.1);
|
|
133
|
+
opacity: 0.8;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
` }), renderLoader()] }));
|
|
6
137
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkBox.component.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/check-box/checkBox.component.tsx"],"names":[],"mappings":"AAMA,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,QAAQ,wDAOlB,aAAa,
|
|
1
|
+
{"version":3,"file":"checkBox.component.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/check-box/checkBox.component.tsx"],"names":[],"mappings":"AAMA,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,QAAQ,wDAOlB,aAAa,4CAoCf,CAAC"}
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import s from '../../tc.module.css';
|
|
4
4
|
import { cn } from '../../utils';
|
|
5
|
-
import { UnCheckbox, CheckedBox } from '../../library/assets/svg';
|
|
6
5
|
import { InputWrapper } from '../Form/form.component';
|
|
6
|
+
import { Icon } from '..';
|
|
7
7
|
export const CheckBox = ({ title = 'Banks', data = [{ title: 'SBI Bank', checked: false }], className, fill = '#E7503D', stroke = '#E7503D', onChange, }) => {
|
|
8
8
|
const [list, setList] = useState(data);
|
|
9
9
|
const width = 20;
|
|
@@ -16,5 +16,5 @@ export const CheckBox = ({ title = 'Banks', data = [{ title: 'SBI Bank', checked
|
|
|
16
16
|
});
|
|
17
17
|
setList(result);
|
|
18
18
|
onChange(result?.filter((item) => item.checked));
|
|
19
|
-
}, children: [_jsx("div", { className: cn(s.flex, s['
|
|
19
|
+
}, children: [_jsx("div", { className: cn(s.flex, s['gap-2']), children: item.checked ? (_jsx(Icon, { nameIcon: "ImCheckboxChecked" })) : (_jsx(Icon, { nameIcon: "ImCheckboxUnchecked" })) }), _jsx("span", { className: cn(s['text-sm'], s['font-medium'], s['ml-2']), children: item?.title })] }, index))) }));
|
|
20
20
|
};
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState, forwardRef } from 'react';
|
|
3
3
|
import DatePicker from 'react-datepicker';
|
|
4
4
|
import 'react-datepicker/dist/react-datepicker.css';
|
|
5
|
-
import {
|
|
5
|
+
import { Icon } from '..';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import { InputWrapper } from '../Form/form.component';
|
|
8
8
|
import s from '../../tc.module.css';
|
|
@@ -10,7 +10,7 @@ import { cn } from '../../utils';
|
|
|
10
10
|
export const DatePickerComp = ({ title = 'Title', className, disable, value, showFormat = 'yyyy-MM-dd', placeholder = 'Select Date', }) => {
|
|
11
11
|
const [pickedDate, setPickedDate] = useState(value && dayjs(value).toDate());
|
|
12
12
|
const CustomInput = forwardRef((props, ref) => {
|
|
13
|
-
return (_jsxs("div", { onClick: !disable && props.onClick, ref: ref, className: cn(s['border-gray-light'], s['place-items-center'], s['border'], s['rounded-md'], s['px-2'], s.flex), children: [_jsx("label", { className: cn(s['mr-3'], s['font-arimaRegular'], s['text-primaryCharcoal'], s['text-lg']), children: props.value || props.placeholder }), _jsx(
|
|
13
|
+
return (_jsxs("div", { onClick: !disable && props.onClick, ref: ref, className: cn(s['border-gray-light'], s['place-items-center'], s['border'], s['rounded-md'], s['px-2'], s.flex), children: [_jsx("label", { className: cn(s['mr-3'], s['font-arimaRegular'], s['text-primaryCharcoal'], s['text-lg']), children: props.value || props.placeholder }), _jsx(Icon, { nameIcon: "ImCalendar" })] }));
|
|
14
14
|
});
|
|
15
15
|
CustomInput.displayName = 'CustomInput';
|
|
16
16
|
const handleChanges = (date) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { Icon } from '..';
|
|
4
4
|
import { InputWrapper } from '../Form/form.component';
|
|
5
5
|
import s from '../../tc.module.css';
|
|
6
6
|
import { cn } from '../../utils';
|
|
@@ -16,5 +16,5 @@ export const Radio = ({ title = 'Source', data = [], className, onChange, }) =>
|
|
|
16
16
|
});
|
|
17
17
|
setList(result);
|
|
18
18
|
onChange(result?.find((item) => item.checked));
|
|
19
|
-
}, children: _jsxs("div", { className: cn(s['flex'], s['flex-row'], s['gap-1'], s['items-center']), children: [item.checked ? (_jsx(
|
|
19
|
+
}, children: _jsxs("div", { className: cn(s['flex'], s['flex-row'], s['gap-1'], s['items-center']), children: [item.checked ? (_jsx(Icon, { nameIcon: "ImRadioChecked" })) : (_jsx(Icon, { nameIcon: "ImRadioUnchecked" })), _jsx("span", { className: cn(s['text-4xs']), children: item?.title })] }) }, index))) }) }));
|
|
20
20
|
};
|