hi-tm 0.4.0 → 0.4.2
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/components/DropDowns/CreatableDropDown.d.ts +3 -2
- package/dist/components/DropDowns/CreatableDropDown.js +91 -92
- package/dist/components/Inputs/InputMultiselect.d.ts +17 -1
- package/dist/components/Inputs/InputMultiselect.js +36 -38
- package/dist/components/Layout/Headers/HeaderLayout.d.ts +2 -2
- package/dist/components/Layout/Headers/HeaderLayout.js +47 -35
- package/dist/types/DropDown/CreatableDropDown.d.ts +6 -16
- package/dist/types/Inputs/InputMultiselectType.d.ts +1 -2
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
export default function CreatableSelect
|
|
2
|
+
import type { CreatableSelectProps } from '../../types/DropDown/CreatableDropDown';
|
|
3
|
+
export default function CreatableSelect({ options, value, onChange, onClick, // New prop for handling selection
|
|
4
|
+
onCreateOption, placeholder, isLoading, isDisabled, isClearable, isCreatable, isMultiSelect, noOptionsMessage, noResultsFound, loadingMessage, createOptionMessage, className, tailwindStyle, iconSrc, fetchOptions, label, onAddClick, }: CreatableSelectProps): React.JSX.Element;
|
|
@@ -58,8 +58,7 @@ const renderIcon = (icon, className = '') => {
|
|
|
58
58
|
return react_1.default.createElement("img", { src: icon || '/placeholder.svg', alt: "", className: className });
|
|
59
59
|
}
|
|
60
60
|
else if (typeof icon === 'object' && 'src' in icon) {
|
|
61
|
-
|
|
62
|
-
return react_1.default.createElement("img", { src: img.src || '/placeholder.svg', alt: img.alt || '', className: className });
|
|
61
|
+
return react_1.default.createElement("img", { src: icon.src || '/placeholder.svg', alt: icon.alt || '', className: className });
|
|
63
62
|
}
|
|
64
63
|
else {
|
|
65
64
|
return icon;
|
|
@@ -75,62 +74,50 @@ const renderNoResults = (noResults, className, searchIcon) => {
|
|
|
75
74
|
if (typeof noResults === 'string') {
|
|
76
75
|
return react_1.default.createElement("div", { className: className }, noResults);
|
|
77
76
|
}
|
|
78
|
-
else if (typeof noResults === 'object' &&
|
|
79
|
-
const withText = noResults;
|
|
77
|
+
else if (typeof noResults === 'object' && 'text' in noResults) {
|
|
80
78
|
return (react_1.default.createElement("div", { className: className },
|
|
81
|
-
|
|
82
|
-
? renderIcon(
|
|
79
|
+
noResults.icon
|
|
80
|
+
? renderIcon(noResults.icon, 'w-6 h-6 mb-1')
|
|
83
81
|
: renderIcon(searchIcon, 'w-6 h-6 mb-1'),
|
|
84
|
-
react_1.default.createElement("span", null,
|
|
82
|
+
react_1.default.createElement("span", null, noResults.text)));
|
|
85
83
|
}
|
|
86
84
|
else {
|
|
87
85
|
return noResults;
|
|
88
86
|
}
|
|
89
87
|
};
|
|
90
|
-
function CreatableSelect({ options = [], value, onChange, onClick,
|
|
91
|
-
|
|
88
|
+
function CreatableSelect({ options = [], value, onChange, onClick, // New prop for handling selection
|
|
89
|
+
onCreateOption, placeholder = 'Select...', isLoading = false, isDisabled = false, isClearable = true, isCreatable = true, isMultiSelect = false, noOptionsMessage = 'No options available', noResultsFound, loadingMessage = 'Loading...', createOptionMessage = 'Create option', className = '', tailwindStyle = {}, iconSrc, fetchOptions, label, onAddClick, }) {
|
|
90
|
+
const styles = {
|
|
92
91
|
...defaultStyles,
|
|
93
92
|
...tailwindStyle,
|
|
94
|
-
}
|
|
95
|
-
// Derivers for label/value to support arbitrary option shapes
|
|
96
|
-
const deriveLabel = (0, react_1.useCallback)((option) => {
|
|
97
|
-
if (getOptionLabel)
|
|
98
|
-
return getOptionLabel(option);
|
|
99
|
-
const anyOption = option;
|
|
100
|
-
const label = anyOption.label ?? anyOption.content ?? anyOption.value;
|
|
101
|
-
return String(label ?? '');
|
|
102
|
-
}, [getOptionLabel]);
|
|
103
|
-
const deriveValue = (0, react_1.useCallback)((option) => {
|
|
104
|
-
if (getOptionValue)
|
|
105
|
-
return getOptionValue(option);
|
|
106
|
-
const anyOption = option;
|
|
107
|
-
const base = anyOption.value ?? anyOption.label ?? anyOption.content;
|
|
108
|
-
const str = String(base ?? deriveLabel(option));
|
|
109
|
-
return str;
|
|
110
|
-
}, [getOptionValue, deriveLabel]);
|
|
93
|
+
};
|
|
111
94
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
112
95
|
const [inputValue, setInputValue] = (0, react_1.useState)('');
|
|
113
96
|
const [filteredOptions, setFilteredOptions] = (0, react_1.useState)(options ?? []);
|
|
114
97
|
const [highlightedIndex, setHighlightedIndex] = (0, react_1.useState)(0);
|
|
115
98
|
const [internalLoading, setInternalLoading] = (0, react_1.useState)(false);
|
|
116
99
|
const [hasSearched, setHasSearched] = (0, react_1.useState)(false);
|
|
117
|
-
const [selectedValues, setSelectedValues] = (0, react_1.useState)(Array.isArray(value) && isMultiSelect
|
|
100
|
+
const [selectedValues, setSelectedValues] = (0, react_1.useState)(Array.isArray(value) && isMultiSelect
|
|
101
|
+
? value
|
|
102
|
+
: value
|
|
103
|
+
? [value]
|
|
104
|
+
: []);
|
|
118
105
|
const containerRef = (0, react_1.useRef)(null);
|
|
119
106
|
const inputRef = (0, react_1.useRef)(null);
|
|
120
|
-
// Sync options into filtered list when not searching
|
|
121
107
|
(0, react_1.useEffect)(() => {
|
|
108
|
+
console.log('Options prop changed:', options); // Debugging log
|
|
109
|
+
// Only update filteredOptions when options change if we're not in the middle of a search
|
|
122
110
|
if (!hasSearched) {
|
|
123
111
|
setFilteredOptions(options ?? []);
|
|
124
112
|
}
|
|
125
113
|
}, [options, hasSearched]);
|
|
126
|
-
// Reset filtered list when input cleared
|
|
127
114
|
(0, react_1.useEffect)(() => {
|
|
128
115
|
if (inputValue === '') {
|
|
116
|
+
console.log('Input value is empty, resetting filtered options'); // Debugging log
|
|
129
117
|
setFilteredOptions(options ?? []);
|
|
130
118
|
setHasSearched(false);
|
|
131
119
|
}
|
|
132
120
|
}, [options, inputValue]);
|
|
133
|
-
// Close on outside click
|
|
134
121
|
(0, react_1.useEffect)(() => {
|
|
135
122
|
const handler = (e) => {
|
|
136
123
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -142,37 +129,47 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
|
|
|
142
129
|
document.removeEventListener('click', handler);
|
|
143
130
|
};
|
|
144
131
|
}, []);
|
|
145
|
-
const handleInputChange =
|
|
146
|
-
const
|
|
147
|
-
setInputValue(
|
|
132
|
+
const handleInputChange = async (e) => {
|
|
133
|
+
const value = e.target.value;
|
|
134
|
+
setInputValue(value);
|
|
148
135
|
setIsOpen(true);
|
|
149
|
-
|
|
136
|
+
// Pass the input event to onChange
|
|
137
|
+
if (onChange) {
|
|
150
138
|
onChange(e);
|
|
151
|
-
|
|
139
|
+
}
|
|
140
|
+
if (fetchOptions && value.trim() !== '') {
|
|
152
141
|
setInternalLoading(true);
|
|
153
142
|
setHasSearched(true);
|
|
154
143
|
try {
|
|
155
|
-
const newOptions = await fetchOptions(
|
|
156
|
-
setFilteredOptions(newOptions
|
|
144
|
+
const newOptions = await fetchOptions(value);
|
|
145
|
+
setFilteredOptions(newOptions);
|
|
157
146
|
}
|
|
158
|
-
catch {
|
|
147
|
+
catch (error) {
|
|
148
|
+
console.error('Error fetching options:', error);
|
|
159
149
|
}
|
|
160
150
|
finally {
|
|
161
151
|
setInternalLoading(false);
|
|
162
152
|
}
|
|
163
153
|
}
|
|
164
|
-
else if (
|
|
154
|
+
else if (value.trim() === '') {
|
|
165
155
|
setFilteredOptions(options ?? []);
|
|
166
156
|
setHasSearched(false);
|
|
167
157
|
}
|
|
168
158
|
else {
|
|
169
|
-
|
|
170
|
-
const
|
|
159
|
+
// Filter options to only show items that match the search text
|
|
160
|
+
const searchText = String(value).trim();
|
|
161
|
+
const filtered = (options ?? []).filter((option) => {
|
|
162
|
+
// Check for label, content, or value properties
|
|
163
|
+
const optionLabel = String(option.label || option.content || '');
|
|
164
|
+
return optionLabel.toLowerCase().includes(searchText.toLowerCase());
|
|
165
|
+
});
|
|
166
|
+
console.log('Search text:', searchText);
|
|
167
|
+
console.log('Filtered options:', filtered);
|
|
171
168
|
setFilteredOptions(filtered);
|
|
172
169
|
setHasSearched(true);
|
|
173
170
|
}
|
|
174
|
-
}
|
|
175
|
-
const handleKeyDown = (
|
|
171
|
+
};
|
|
172
|
+
const handleKeyDown = (e) => {
|
|
176
173
|
if (isDisabled)
|
|
177
174
|
return;
|
|
178
175
|
switch (e.key) {
|
|
@@ -184,7 +181,7 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
|
|
|
184
181
|
}
|
|
185
182
|
else if (isCreatable &&
|
|
186
183
|
inputValue &&
|
|
187
|
-
!filteredOptions.some((o) =>
|
|
184
|
+
!filteredOptions.some((o) => o.label === inputValue)) {
|
|
188
185
|
handleCreateOption();
|
|
189
186
|
}
|
|
190
187
|
setIsOpen(false);
|
|
@@ -215,86 +212,87 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
|
|
|
215
212
|
}
|
|
216
213
|
break;
|
|
217
214
|
}
|
|
218
|
-
}
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
if (onClick) {
|
|
222
|
-
onClick(isMultiSelect ? next ?? [] : next ? next[0] : null);
|
|
223
|
-
}
|
|
224
|
-
if (onValueChange) {
|
|
225
|
-
onValueChange(isMultiSelect ? next ?? [] : next ? next[0] : null);
|
|
226
|
-
}
|
|
227
|
-
}, [onClick, onValueChange, isMultiSelect]);
|
|
228
|
-
const handleCreateOption = (0, react_1.useCallback)(async () => {
|
|
229
|
-
if (!inputValue.trim() || !isCreatable)
|
|
215
|
+
};
|
|
216
|
+
const handleCreateOption = async () => {
|
|
217
|
+
if (!inputValue.trim() || !isCreatable || !onCreateOption)
|
|
230
218
|
return;
|
|
231
219
|
setInternalLoading(true);
|
|
232
220
|
try {
|
|
233
|
-
|
|
221
|
+
await onCreateOption(inputValue);
|
|
222
|
+
// Create value without toLowerCase
|
|
234
223
|
const safeInputValue = String(inputValue);
|
|
235
|
-
const
|
|
224
|
+
const newOption = {
|
|
236
225
|
label: safeInputValue,
|
|
237
|
-
content: safeInputValue,
|
|
226
|
+
content: safeInputValue, // Add content property for compatibility
|
|
238
227
|
value: safeInputValue.replace(/\s+/g, '-'),
|
|
239
228
|
};
|
|
240
|
-
|
|
241
|
-
selectOption(optionToAdd);
|
|
229
|
+
selectOption(newOption);
|
|
242
230
|
setInputValue('');
|
|
243
231
|
setHasSearched(false);
|
|
244
232
|
}
|
|
245
|
-
catch {
|
|
233
|
+
catch (error) {
|
|
234
|
+
console.error('Error creating option:', error);
|
|
246
235
|
}
|
|
247
236
|
finally {
|
|
248
237
|
setInternalLoading(false);
|
|
249
238
|
}
|
|
250
|
-
}
|
|
251
|
-
const toggleDropdown = (
|
|
239
|
+
};
|
|
240
|
+
const toggleDropdown = () => {
|
|
252
241
|
if (!isDisabled) {
|
|
253
242
|
setIsOpen((prev) => !prev);
|
|
254
243
|
if (!isOpen && inputRef.current) {
|
|
255
244
|
inputRef.current.focus();
|
|
256
245
|
}
|
|
257
246
|
}
|
|
258
|
-
}
|
|
259
|
-
const clearValue = (
|
|
247
|
+
};
|
|
248
|
+
const clearValue = (e, option) => {
|
|
260
249
|
e.stopPropagation();
|
|
261
|
-
const
|
|
262
|
-
setSelectedValues(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
250
|
+
const newValues = selectedValues.filter((val) => val.value !== option.value);
|
|
251
|
+
setSelectedValues(newValues);
|
|
252
|
+
// Use onClick instead of onChange for selection updates
|
|
253
|
+
if (onClick) {
|
|
254
|
+
onClick(isMultiSelect ? newValues : newValues[0] || null);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const selectOption = (option) => {
|
|
266
258
|
if (isMultiSelect) {
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
269
|
-
|
|
259
|
+
const newValues = [...selectedValues];
|
|
260
|
+
if (!newValues.some((val) => val.value === option.value)) {
|
|
261
|
+
newValues.push(option);
|
|
262
|
+
}
|
|
263
|
+
setSelectedValues(newValues);
|
|
264
|
+
// Use onClick instead of onChange for selection updates
|
|
265
|
+
if (onClick) {
|
|
266
|
+
onClick(newValues);
|
|
270
267
|
}
|
|
271
|
-
setSelectedValues(next);
|
|
272
|
-
emitSelection(next);
|
|
273
268
|
}
|
|
274
269
|
else {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
270
|
+
setSelectedValues([option]);
|
|
271
|
+
// Use onClick instead of onChange for selection updates
|
|
272
|
+
if (onClick) {
|
|
273
|
+
onClick(option);
|
|
274
|
+
}
|
|
278
275
|
}
|
|
279
276
|
setInputValue('');
|
|
280
277
|
setIsOpen(false);
|
|
281
278
|
setHasSearched(false);
|
|
282
|
-
}
|
|
279
|
+
};
|
|
283
280
|
const showLoading = isLoading || internalLoading;
|
|
284
|
-
const handleAddIconClick = (
|
|
281
|
+
const handleAddIconClick = (e) => {
|
|
285
282
|
e.stopPropagation();
|
|
286
283
|
if (onAddClick) {
|
|
284
|
+
// Pass the required argument to onAddClick
|
|
287
285
|
onAddClick(true);
|
|
288
286
|
}
|
|
289
|
-
}
|
|
287
|
+
};
|
|
290
288
|
return (react_1.default.createElement("div", { ref: containerRef, className: `relative w-full ${className} ${styles.container}`, onKeyDown: handleKeyDown },
|
|
291
289
|
label && react_1.default.createElement("label", { className: "block text-sm font-medium text-gray-700 mb-1" }, label),
|
|
292
290
|
react_1.default.createElement("div", { className: `${styles.trigger} ${isDisabled ? 'bg-gray-100 cursor-not-allowed' : ''} ${isOpen ? 'border-blue-500 ring-2 ring-blue-100' : 'border-gray-300'}`, onClick: toggleDropdown },
|
|
293
291
|
react_1.default.createElement("div", { className: "flex-grow flex items-center overflow-x-auto no-scrollbar" },
|
|
294
292
|
react_1.default.createElement("div", { className: "flex items-center gap-2 flex-nowrap" },
|
|
295
293
|
selectedValues.length > 0 &&
|
|
296
|
-
selectedValues.map((val) => (react_1.default.createElement("div", { key:
|
|
297
|
-
react_1.default.createElement("span", { className: "truncate" },
|
|
294
|
+
selectedValues.map((val) => (react_1.default.createElement("div", { key: val.value, className: "flex-shrink-0 flex items-center bg-gray-200 rounded-md px-2 py-1" },
|
|
295
|
+
react_1.default.createElement("span", { className: "truncate" }, val.label || val.content),
|
|
298
296
|
react_1.default.createElement("button", { onClick: (e) => clearValue(e, val), className: styles.clearButton }, renderIcon(iconSrc.clear, styles.icon))))),
|
|
299
297
|
react_1.default.createElement("input", { ref: inputRef, type: "text", className: `${styles.input} ${isDisabled ? 'bg-gray-100' : ''} min-w-[80px] flex-shrink-0`, placeholder: selectedValues.length > 0 ? '' : placeholder, value: inputValue, onChange: handleInputChange, disabled: isDisabled, onClick: (e) => e.stopPropagation() }))),
|
|
300
298
|
react_1.default.createElement("div", { className: "flex-shrink-0 flex items-center gap-1 ml-2" },
|
|
@@ -307,23 +305,24 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
|
|
|
307
305
|
isOpen && (react_1.default.createElement("div", { className: styles.dropdown }, showLoading ? (react_1.default.createElement("div", { className: styles.loadingState },
|
|
308
306
|
renderIcon(iconSrc.loading, `animate-spin mr-2 ${styles.icon}`),
|
|
309
307
|
loadingMessage)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
310
|
-
filteredOptions.length > 0 && (react_1.default.createElement(react_1.default.Fragment, null, filteredOptions.map((option, index) => (react_1.default.createElement("div", { key:
|
|
311
|
-
selectedValues.some((val) =>
|
|
308
|
+
filteredOptions.length > 0 && (react_1.default.createElement(react_1.default.Fragment, null, filteredOptions.map((option, index) => (react_1.default.createElement("div", { key: option.value, className: `${styles.option} ${index === highlightedIndex ? styles.highlightedOption : 'hover:bg-gray-50'}`, onClick: () => selectOption(option), onMouseEnter: () => setHighlightedIndex(index) },
|
|
309
|
+
selectedValues.some((val) => val.value === option.value) &&
|
|
312
310
|
renderIcon(iconSrc.checkmark, 'w-4 h-4 mr-2 text-blue-500'),
|
|
313
|
-
react_1.default.createElement("span", { className: selectedValues.some((val) =>
|
|
311
|
+
react_1.default.createElement("span", { className: selectedValues.some((val) => val.value === option.value)
|
|
314
312
|
? styles.selectedOption
|
|
315
|
-
: '' },
|
|
313
|
+
: '' }, option.label || option.content || option.value)))))),
|
|
316
314
|
filteredOptions.length === 0 && !inputValue && (react_1.default.createElement("div", { className: styles.noOptions }, noOptionsMessage)),
|
|
317
315
|
filteredOptions.length === 0 &&
|
|
318
316
|
inputValue &&
|
|
319
317
|
hasSearched &&
|
|
320
|
-
renderNoResults(noResultsFound, styles
|
|
318
|
+
renderNoResults(noResultsFound, styles?.noResults, iconSrc.create),
|
|
321
319
|
isCreatable &&
|
|
322
320
|
inputValue &&
|
|
323
|
-
!options?.some((o) =>
|
|
321
|
+
!options?.some((o) => (o.label || o.content) === inputValue) && (react_1.default.createElement("div", { className: styles.createOption, onClick: handleCreateOption },
|
|
324
322
|
renderIcon(iconSrc.create, styles.icon),
|
|
325
323
|
react_1.default.createElement("span", null,
|
|
326
324
|
createOptionMessage,
|
|
327
|
-
": ",
|
|
328
|
-
inputValue
|
|
325
|
+
": \"",
|
|
326
|
+
inputValue,
|
|
327
|
+
"\"")))))))));
|
|
329
328
|
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InputMultiselectProps } from '../../types/Inputs/InputMultiselectType';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} label - The label for the input field.
|
|
5
|
+
* @param {boolean} required - Indicates whether the input is required.
|
|
6
|
+
* @param {string | undefined} textError - The error message to display if validation fails.
|
|
7
|
+
* @param {string} placeholder - The placeholder text for the input field.
|
|
8
|
+
* @param {Function} onChangeHandler - Callback function triggered when the list of items changes.
|
|
9
|
+
* @param {boolean} autoComplete - Specifies whether autocomplete is enabled for the input field.
|
|
10
|
+
* @param {string[]} value - The initial list of selected items. => string[]
|
|
11
|
+
* @param {boolean} autoFocus - Determines whether the input should autofocus on render.
|
|
12
|
+
* @param {Function | undefined} onFocusHandler - Callback function triggered when the input gains focus.
|
|
13
|
+
* @param {Function | undefined} onKeyUpHandler - Callback function triggered when a key is released while the input is focused.
|
|
14
|
+
* @param {Function | undefined} handleKeyDown - Callback function triggered when a key is pressed while the input is focused.
|
|
15
|
+
* @param {Function | undefined} onBlurHandler - Callback function triggered when the input loses focus.
|
|
16
|
+
* @param {string} closeIconSRC - The source URL for the close icon image.
|
|
17
|
+
* @param {string} [width=w-full] - The width of the input container, with a default value of 'w-full'.
|
|
18
|
+
*/
|
|
19
|
+
declare const InputMultiselect: ({ label, required, textError, placeholder, onChangeHandler, autoComplete, value, autoFocus, onFocusHandler, onKeyUpHandler, handleKeyDown: propHandleKeyDown, onBlurHandler, closeIconSRC, style, }: InputMultiselectProps) => React.JSX.Element;
|
|
4
20
|
export default InputMultiselect;
|
|
@@ -39,48 +39,52 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
const react_1 = __importStar(require("react"));
|
|
41
41
|
const image_1 = __importDefault(require("next/image"));
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} label - The label for the input field.
|
|
44
|
+
* @param {boolean} required - Indicates whether the input is required.
|
|
45
|
+
* @param {string | undefined} textError - The error message to display if validation fails.
|
|
46
|
+
* @param {string} placeholder - The placeholder text for the input field.
|
|
47
|
+
* @param {Function} onChangeHandler - Callback function triggered when the list of items changes.
|
|
48
|
+
* @param {boolean} autoComplete - Specifies whether autocomplete is enabled for the input field.
|
|
49
|
+
* @param {string[]} value - The initial list of selected items. => string[]
|
|
50
|
+
* @param {boolean} autoFocus - Determines whether the input should autofocus on render.
|
|
51
|
+
* @param {Function | undefined} onFocusHandler - Callback function triggered when the input gains focus.
|
|
52
|
+
* @param {Function | undefined} onKeyUpHandler - Callback function triggered when a key is released while the input is focused.
|
|
53
|
+
* @param {Function | undefined} handleKeyDown - Callback function triggered when a key is pressed while the input is focused.
|
|
54
|
+
* @param {Function | undefined} onBlurHandler - Callback function triggered when the input loses focus.
|
|
55
|
+
* @param {string} closeIconSRC - The source URL for the close icon image.
|
|
56
|
+
* @param {string} [width=w-full] - The width of the input container, with a default value of 'w-full'.
|
|
57
|
+
*/
|
|
58
|
+
const InputMultiselect = ({ label, required, textError, placeholder, onChangeHandler, autoComplete, value, autoFocus, onFocusHandler, onKeyUpHandler, handleKeyDown: propHandleKeyDown, onBlurHandler, closeIconSRC, style = {
|
|
43
59
|
margin: 'mt-[-6px]',
|
|
44
60
|
width: 'w-full',
|
|
45
61
|
}, }) => {
|
|
46
62
|
const [items, setItems] = (0, react_1.useState)([]);
|
|
47
63
|
const [currentValue, setCurrentValue] = (0, react_1.useState)('');
|
|
48
64
|
const [showError, setShowError] = (0, react_1.useState)(false);
|
|
65
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
49
66
|
const isErrorVisible = () => {
|
|
50
|
-
|
|
51
|
-
return (textError && textError.trim() !== '') || showError;
|
|
67
|
+
return !(textError && textError.trim() !== '');
|
|
52
68
|
};
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
if (showError && currentValue.trim() !== '') {
|
|
58
|
-
return 'برای ثبت بارکد کلید Enter را فشار دهید';
|
|
69
|
+
(0, react_1.useEffect)(() => {
|
|
70
|
+
if (inputRef.current) {
|
|
71
|
+
inputRef.current.value = currentValue;
|
|
59
72
|
}
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
// Initialize items from value prop only once
|
|
73
|
+
}, [currentValue]);
|
|
63
74
|
(0, react_1.useEffect)(() => {
|
|
64
|
-
if (value && value.length > 0
|
|
75
|
+
if (value && value.length > 0) {
|
|
65
76
|
setItems(value);
|
|
66
77
|
}
|
|
67
|
-
}, [value
|
|
78
|
+
}, [value]);
|
|
68
79
|
const handleChange = (e) => {
|
|
69
80
|
setCurrentValue(e.target.value);
|
|
70
|
-
// Hide error when user starts typing
|
|
71
|
-
if (showError) {
|
|
72
|
-
setShowError(false);
|
|
73
|
-
}
|
|
74
81
|
};
|
|
75
82
|
const handleKeyDown = (e) => {
|
|
76
83
|
if (e.key === 'Enter' && currentValue.trim() !== '') {
|
|
77
84
|
e.preventDefault();
|
|
78
|
-
|
|
79
|
-
setItems(newItems);
|
|
85
|
+
setItems((prevItems) => [...prevItems, currentValue.trim()]);
|
|
80
86
|
setCurrentValue('');
|
|
81
87
|
setShowError(false); // Reset error on Enter
|
|
82
|
-
// Call onChangeHandler directly here instead of in useEffect
|
|
83
|
-
onChangeHandler(newItems);
|
|
84
88
|
}
|
|
85
89
|
propHandleKeyDown?.(e);
|
|
86
90
|
};
|
|
@@ -90,29 +94,23 @@ const InputMultiselect = ({ label, required, textError, placeholder, onChangeHan
|
|
|
90
94
|
}
|
|
91
95
|
onBlurHandler?.(e);
|
|
92
96
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const newItems = prevItems.filter((_, i) => i !== index);
|
|
100
|
-
// Call onChangeHandler directly here
|
|
101
|
-
onChangeHandler(newItems);
|
|
102
|
-
return newItems;
|
|
103
|
-
});
|
|
104
|
-
}, [onChangeHandler]);
|
|
97
|
+
(0, react_1.useEffect)(() => {
|
|
98
|
+
onChangeHandler(items);
|
|
99
|
+
}, [items]);
|
|
100
|
+
const handleRemoveItem = (index) => {
|
|
101
|
+
setItems((prevItems) => prevItems.filter((_, i) => i !== index));
|
|
102
|
+
};
|
|
105
103
|
return (react_1.default.createElement("div", { className: `${style.width} ${style.margin} relative ` },
|
|
106
104
|
react_1.default.createElement("label", { htmlFor: label, className: "flex items-center gap-2 mx-3" },
|
|
107
105
|
react_1.default.createElement("p", { className: "text-sm text-text-color-primary font-medium cursor-pointer" }, label),
|
|
108
106
|
react_1.default.createElement("span", { className: `text-red-primary font-bold ${required ? 'block' : 'hidden'}` }, "*")),
|
|
109
107
|
react_1.default.createElement("div", { className: `w-full h-10 flex gap-1 items-center justify-between bg-inherit outline-none border rounded-lg text-sm px-2 ${isErrorVisible()
|
|
110
|
-
? 'border-
|
|
111
|
-
: 'border-
|
|
108
|
+
? 'border-gray-tertiary focus:border-gray-quaternary'
|
|
109
|
+
: 'border-red-primary'}` },
|
|
112
110
|
items.map((item, index) => (react_1.default.createElement("span", { key: index, className: "bg-gray-secondary text-text-color-primary px-2 py-1 rounded flex items-center justify-center gap-1" },
|
|
113
111
|
item,
|
|
114
112
|
react_1.default.createElement(image_1.default, { src: closeIconSRC, alt: "close", width: 22, height: 22, onClick: () => handleRemoveItem(index), className: "inline-block cursor-pointer" })))),
|
|
115
|
-
react_1.default.createElement("input", { ref: inputRef, type: "text",
|
|
116
|
-
isErrorVisible() && react_1.default.createElement("p", { className: "text-sm mt-1 text-red-primary" },
|
|
113
|
+
react_1.default.createElement("input", { ref: inputRef, type: "text", id: label, placeholder: items.length === 0 ? placeholder : '', onChange: handleChange, autoComplete: autoComplete ? 'on' : 'off', autoFocus: autoFocus, className: "outline-none bg-inherit flex-grow", required: required, onFocus: onFocusHandler, onKeyUp: onKeyUpHandler, onKeyDown: handleKeyDown, onBlur: handleBlur })),
|
|
114
|
+
!isErrorVisible() && react_1.default.createElement("p", { className: "text-sm mt-1 text-red-primary" }, textError?.trim())));
|
|
117
115
|
};
|
|
118
116
|
exports.default = InputMultiselect;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { HeaderLayoutProps } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { HeaderLayoutProps } from "../../../types/Layout/Headers/HeaderLayout";
|
|
3
3
|
/**
|
|
4
4
|
* The component accepts the following props:
|
|
5
5
|
* @param branchName - User's branch name to use in the logo URL.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
"use client";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -123,17 +123,17 @@ const ModalSearchContentInHeader_1 = __importDefault(require("../../sections/com
|
|
|
123
123
|
* ```
|
|
124
124
|
* @param refreshPageHandler - Function to refresh the page when the refresh icon is clicked.
|
|
125
125
|
*/
|
|
126
|
-
const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, userLastName, logOutText, logOutHandler, modalData, modalItemOnClickHandler, iconsSRC, cdnURL, userBranchesData, selectBranchHandler, sidebarData, searchIconSRC, searchItemHandler, refreshPageHandler, brandNameText, languages, changeLanguageHandler, onLogoClickHandler }) => {
|
|
126
|
+
const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, userLastName, logOutText, logOutHandler, modalData, modalItemOnClickHandler, iconsSRC, cdnURL, userBranchesData, selectBranchHandler, sidebarData, searchIconSRC, searchItemHandler, refreshPageHandler, brandNameText, languages, changeLanguageHandler, onLogoClickHandler, }) => {
|
|
127
127
|
const [isShowModalSearch, setIsShowModalSearch] = (0, react_1.useState)(false);
|
|
128
128
|
const [isOpenModal, setIsOpenModal] = (0, react_1.useState)(false);
|
|
129
129
|
const [isOpenModalBranches, setIsOpenModalBranches] = (0, react_1.useState)(false);
|
|
130
130
|
const [isOpenLanguageModal, setIsOpenLanguageModal] = (0, react_1.useState)(false);
|
|
131
131
|
const [branchNameSelected, setBranchNameSelected] = (0, react_1.useState)({
|
|
132
132
|
id: 0,
|
|
133
|
-
name:
|
|
134
|
-
urlName:
|
|
135
|
-
imageName:
|
|
136
|
-
logoName:
|
|
133
|
+
name: "",
|
|
134
|
+
urlName: "",
|
|
135
|
+
imageName: "",
|
|
136
|
+
logoName: "",
|
|
137
137
|
});
|
|
138
138
|
const modalCloseRefPC = (0, react_1.useRef)(null);
|
|
139
139
|
const modalCloseRefMobile = (0, react_1.useRef)(null);
|
|
@@ -177,9 +177,9 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
177
177
|
setIsOpenModal(false);
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
|
-
document.addEventListener(
|
|
180
|
+
document.addEventListener("click", handleClickOutside);
|
|
181
181
|
return () => {
|
|
182
|
-
document.removeEventListener(
|
|
182
|
+
document.removeEventListener("click", handleClickOutside);
|
|
183
183
|
};
|
|
184
184
|
}, []);
|
|
185
185
|
(0, react_1.useEffect)(() => {
|
|
@@ -191,9 +191,9 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
191
191
|
setIsOpenModalBranches(false);
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
|
-
document.addEventListener(
|
|
194
|
+
document.addEventListener("click", handleClickOutsideBranches);
|
|
195
195
|
return () => {
|
|
196
|
-
document.removeEventListener(
|
|
196
|
+
document.removeEventListener("click", handleClickOutsideBranches);
|
|
197
197
|
};
|
|
198
198
|
}, []);
|
|
199
199
|
(0, react_1.useEffect)(() => {
|
|
@@ -205,9 +205,9 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
205
205
|
setIsOpenLanguageModal(false);
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
|
-
document.addEventListener(
|
|
208
|
+
document.addEventListener("click", handleClickOutsideLanguage);
|
|
209
209
|
return () => {
|
|
210
|
-
document.removeEventListener(
|
|
210
|
+
document.removeEventListener("click", handleClickOutsideLanguage);
|
|
211
211
|
};
|
|
212
212
|
}, []);
|
|
213
213
|
const baseUrlCDN = cdnURL !== undefined ? cdnURL : process.env.NEXT_PUBLIC_IMAGE_BASE_URL;
|
|
@@ -224,23 +224,29 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
224
224
|
react_1.default.createElement(image_1.default, { src: iconsSRC.logoSRC, alt: "logo", width: 40, height: 40, className: "select-none-custom h-10 w-10", onClick: () => {
|
|
225
225
|
onLogoClickHandler();
|
|
226
226
|
} }))),
|
|
227
|
-
react_1.default.createElement("div", { ref: modalCloseRefuserBranchesPC, className: `relative bg-inherit ${branchNameSelected?.id === 0 ?
|
|
227
|
+
react_1.default.createElement("div", { ref: modalCloseRefuserBranchesPC, className: `relative bg-inherit ${branchNameSelected?.id === 0 ? "hidden" : "flex"}` },
|
|
228
228
|
react_1.default.createElement("div", { onClick: handleModalShowBranches, className: "select-none-custom flex flex-row items-center justify-center gap-3" },
|
|
229
229
|
react_1.default.createElement(image_1.default, { src: `${baseUrlCDN}/${branchName}/${branchNameSelected.logoName}`, alt: "logo.svg", width: 24, height: 24, className: `rounded-md ${userBranchesData !== undefined && userBranchesData.length === 1
|
|
230
|
-
?
|
|
231
|
-
:
|
|
230
|
+
? "cursor-default"
|
|
231
|
+
: "cursor-pointer"}` }),
|
|
232
232
|
react_1.default.createElement("p", { className: `${userBranchesData !== undefined && userBranchesData.length === 1
|
|
233
|
-
?
|
|
234
|
-
:
|
|
233
|
+
? "cursor-default"
|
|
234
|
+
: "cursor-pointer"}` }, branchNameSelected.name),
|
|
235
235
|
react_1.default.createElement(image_1.default, { src: iconsSRC.arrowSRC, alt: "arrow.svg", width: 16, height: 16, className: `customTransition ${userBranchesData !== undefined && userBranchesData.length === 1
|
|
236
|
-
?
|
|
236
|
+
? "hidden"
|
|
237
237
|
: isOpenModalBranches
|
|
238
|
-
?
|
|
239
|
-
:
|
|
240
|
-
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-0 top-[30px] z-60 w-auto rounded-lg bg-white-color p-tiny ${isOpenModalBranches
|
|
238
|
+
? "flex rotate-180 cursor-pointer"
|
|
239
|
+
: "flex rotate-0 cursor-pointer"}` })),
|
|
240
|
+
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-0 top-[30px] z-60 w-auto rounded-lg bg-white-color p-tiny ${isOpenModalBranches
|
|
241
|
+
? "scale-y-100 opacity-100"
|
|
242
|
+
: "scale-y-0 opacity-0"} origin-top` },
|
|
241
243
|
react_1.default.createElement("ul", { className: "flex h-auto w-full flex-col items-start justify-center gap-3 bg-inherit p-3" }, userBranchesData &&
|
|
242
244
|
userBranchesData.map((item) => (react_1.default.createElement("li", { onClick: () => selectItemBranchHandler(item), key: item?.id, className: "customTransition flex w-full flex-row items-center justify-end gap-2 rounded-tiny px-5 py-2 text-text-color-primary hover:bg-gray-primary" },
|
|
243
|
-
react_1.default.createElement(image_1.default, { src:
|
|
245
|
+
react_1.default.createElement(image_1.default, { src: branchNameSelected.logoName === " " ||
|
|
246
|
+
branchNameSelected.logoName === null ||
|
|
247
|
+
branchNameSelected.logoName === undefined
|
|
248
|
+
? "/defaultImage.jpg"
|
|
249
|
+
: `${baseUrlCDN}/${branchName}/${branchNameSelected.imageName}`, alt: "logo.svg", width: 16, height: 16, className: "rounded-xl" }),
|
|
244
250
|
react_1.default.createElement("p", { className: "select-none-custom cursor-pointer text-nowrap text-sm font-normal text-text-color-primary" }, item.name))))))),
|
|
245
251
|
react_1.default.createElement("div", { ref: modalCloseRefPC, className: "flex h-full flex-row-reverse items-center justify-center gap-4" },
|
|
246
252
|
react_1.default.createElement("div", { onClick: handleModalShow, className: "border-primaryBorderColor relative flex cursor-pointer flex-row items-center justify-center gap-1 rounded-lg border border-solid p-tiny" },
|
|
@@ -249,8 +255,8 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
249
255
|
react_1.default.createElement("div", { className: "flex flex-row items-center justify-center gap-1" },
|
|
250
256
|
react_1.default.createElement("p", { className: "select-none-custom" }, userFirstName),
|
|
251
257
|
react_1.default.createElement("p", { className: "select-none-custom" }, userLastName)),
|
|
252
|
-
react_1.default.createElement(image_1.default, { src: iconsSRC.arrowSRC, alt: "arrow-down.svg", width: 10, height: 10, className: `select-none-custom customTransition ${isOpenModal ?
|
|
253
|
-
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-2 top-[40px] z-60 w-[216px] rounded-lg bg-white-color p-tiny ${isOpenModal ?
|
|
258
|
+
react_1.default.createElement(image_1.default, { src: iconsSRC.arrowSRC, alt: "arrow-down.svg", width: 10, height: 10, className: `select-none-custom customTransition ${isOpenModal ? "rotate-180" : "rotate-0"}` })),
|
|
259
|
+
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-2 top-[40px] z-60 w-[216px] rounded-lg bg-white-color p-tiny ${isOpenModal ? "scale-y-100 opacity-100" : "scale-y-0 opacity-0"} origin-top` },
|
|
254
260
|
react_1.default.createElement("ul", { className: "flex h-full w-full flex-col items-start justify-center gap-3 p-3" },
|
|
255
261
|
modalData &&
|
|
256
262
|
modalData.map((item) => (react_1.default.createElement("li", { onClick: () => {
|
|
@@ -275,25 +281,29 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
275
281
|
react_1.default.createElement("div", { ref: modalCloseRefLanguagePC, className: "relative" },
|
|
276
282
|
react_1.default.createElement("div", { className: "cursor-pointer", onClick: handleLanguageModalShow },
|
|
277
283
|
react_1.default.createElement(image_1.default, { src: iconsSRC.languageIconSRC, alt: "language.svg", width: 20, height: 20, className: "customTransition h-5 w-5 hover:scale-125" })),
|
|
278
|
-
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute -right-[38px] top-[35px] z-[80000] w-fit rounded-lg bg-white-color p-tiny ${isOpenLanguageModal
|
|
284
|
+
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute -right-[38px] top-[35px] z-[80000] w-fit rounded-lg bg-white-color p-tiny ${isOpenLanguageModal
|
|
285
|
+
? "scale-y-100 opacity-100"
|
|
286
|
+
: "scale-y-0 opacity-0"} origin-top` },
|
|
279
287
|
react_1.default.createElement("ul", { className: "flex h-auto w-full flex-col items-start justify-end gap-3 p-3" }, languages.map((language) => (react_1.default.createElement("li", { key: language?.id, onClick: () => selectLanguageHandler(language), className: "customTransition flex w-full flex-row items-center justify-between gap-2 rounded-tiny px-5 py-2 text-text-color-primary hover:bg-gray-primary" },
|
|
280
288
|
react_1.default.createElement(image_1.default, { src: language.flagIcon, alt: `${language.showName}-flag`, width: 16, height: 16, className: "rounded-sm" }),
|
|
281
289
|
react_1.default.createElement("p", { className: "select-none-custom w-full cursor-pointer text-nowrap text-sm font-normal text-text-color-primary" }, language.showName)))))))))),
|
|
282
290
|
react_1.default.createElement("header", { style: { zIndex: 100 }, className: "flex h-11 w-full flex-row items-center justify-between bg-back-ground-color-primary px-5 xl:hidden fixed top-0 z-layout" },
|
|
283
291
|
react_1.default.createElement("div", { onClick: sidebarHandler, className: "border-primaryBorderColor flex h-8 w-9 cursor-pointer flex-row items-center justify-center rounded-lg border border-solid p-1" },
|
|
284
292
|
react_1.default.createElement(image_1.default, { src: iconsSRC.menuIconSRC, alt: "menu.svg", width: 20, height: 20, className: "h-full w-full" })),
|
|
285
|
-
react_1.default.createElement("div", { ref: modalCloseRefuserBranchesMobile, className: `relative bg-inherit ${branchNameSelected?.id === 0 ?
|
|
293
|
+
react_1.default.createElement("div", { ref: modalCloseRefuserBranchesMobile, className: `relative bg-inherit ${branchNameSelected?.id === 0 ? "hidden" : "flex"}` },
|
|
286
294
|
react_1.default.createElement("div", { onClick: handleModalShowBranches, className: "select-none-custom flex flex-row items-center justify-center gap-3" },
|
|
287
295
|
react_1.default.createElement(image_1.default, { src: `${baseUrlCDN}/${branchName}/${branchNameSelected.logoName}`, alt: "logo.svg", width: 24, height: 24, className: `rounded-md ${userBranchesData !== undefined && userBranchesData.length === 1
|
|
288
|
-
?
|
|
289
|
-
:
|
|
296
|
+
? "cursor-default"
|
|
297
|
+
: "cursor-pointer"}` }),
|
|
290
298
|
react_1.default.createElement("p", { className: `${userBranchesData !== undefined && userBranchesData.length === 1
|
|
291
|
-
?
|
|
292
|
-
:
|
|
299
|
+
? "cursor-default"
|
|
300
|
+
: "cursor-pointer"}` }, branchNameSelected.name),
|
|
293
301
|
react_1.default.createElement(image_1.default, { src: iconsSRC.arrowSRC, alt: "arrow.svg", width: 16, height: 16, className: `${userBranchesData !== undefined && userBranchesData.length === 1
|
|
294
|
-
?
|
|
295
|
-
:
|
|
296
|
-
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-0 top-[40px] z-60 w-auto rounded-lg bg-white-color p-tiny ${isOpenModalBranches
|
|
302
|
+
? "hidden"
|
|
303
|
+
: "flex cursor-pointer"}` })),
|
|
304
|
+
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-0 top-[40px] z-60 w-auto rounded-lg bg-white-color p-tiny ${isOpenModalBranches
|
|
305
|
+
? "scale-y-100 opacity-100"
|
|
306
|
+
: "scale-y-0 opacity-0"} origin-top` },
|
|
297
307
|
react_1.default.createElement("ul", { className: "flex h-auto w-full flex-col items-start justify-center gap-3 bg-inherit p-3" }, userBranchesData &&
|
|
298
308
|
userBranchesData.map((item) => (react_1.default.createElement("li", { onClick: () => selectItemBranchHandler(item), key: item?.id, className: "customTransition flex w-full flex-row items-center justify-end gap-2 rounded-tiny px-5 py-2 text-text-color-primary hover:bg-gray-primary" },
|
|
299
309
|
react_1.default.createElement(image_1.default, { src: `${baseUrlCDN}/${branchName}/${item.logoName}`, alt: "logo.svg", width: 16, height: 16, className: "rounded-xl" }),
|
|
@@ -307,13 +317,15 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
307
317
|
react_1.default.createElement("div", { ref: modalCloseRefLanguageMobile, className: "relative" },
|
|
308
318
|
react_1.default.createElement("div", { className: "customTransition mr-2 cursor-pointer hover:scale-125", onClick: handleLanguageModalShow },
|
|
309
319
|
react_1.default.createElement(image_1.default, { src: iconsSRC.languageIconSRC, alt: "language.svg", width: 28, height: 28, className: "h-8 w-8" })),
|
|
310
|
-
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute -right-[29px] top-[40px] z-[80000] w-fit rounded-lg bg-white-color p-tiny ${isOpenLanguageModal
|
|
320
|
+
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute -right-[29px] top-[40px] z-[80000] w-fit rounded-lg bg-white-color p-tiny ${isOpenLanguageModal
|
|
321
|
+
? "scale-y-100 opacity-100"
|
|
322
|
+
: "scale-y-0 opacity-0"} origin-top` },
|
|
311
323
|
react_1.default.createElement("ul", { className: "flex h-auto w-full flex-col items-start justify-center gap-3 p-3" }, languages.map((language) => (react_1.default.createElement("li", { key: language?.id, onClick: () => selectLanguageHandler(language), className: "customTransition flex w-full flex-row items-center justify-between gap-2 rounded-tiny px-5 py-2 text-text-color-primary hover:bg-gray-primary" },
|
|
312
324
|
react_1.default.createElement(image_1.default, { src: language.flagIcon, alt: `${language.showName}-flag`, width: 16, height: 16, className: "rounded-sm" }),
|
|
313
325
|
react_1.default.createElement("p", { className: "select-none-custom w-full cursor-pointer text-nowrap text-sm font-normal text-text-color-primary" }, language.showName))))))),
|
|
314
326
|
react_1.default.createElement("div", { onClick: handleModalShow, className: "mr-2 flex h-8 w-10 cursor-pointer flex-row items-center justify-center rounded-lg border border-solid border-border-color-primary bg-inherit" },
|
|
315
327
|
react_1.default.createElement(image_1.default, { src: iconsSRC.iconProfileUserSRC, alt: "profile.svg", width: 18, height: 18 })),
|
|
316
|
-
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-4 top-10 z-60 w-[182px] rounded-lg bg-white-color p-tiny ${isOpenModal ?
|
|
328
|
+
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-4 top-10 z-60 w-[182px] rounded-lg bg-white-color p-tiny ${isOpenModal ? "scale-y-100 opacity-100" : "scale-y-0 opacity-0"} origin-top` },
|
|
317
329
|
react_1.default.createElement("ul", { className: "flex h-full w-full flex-col items-start justify-center gap-3 p-3" },
|
|
318
330
|
modalData.length > 0 &&
|
|
319
331
|
modalData.map((item) => (react_1.default.createElement("li", { onClick: () => {
|
|
@@ -30,13 +30,6 @@ export interface TailwindStyleProps extends React.CSSProperties {
|
|
|
30
30
|
separator?: string;
|
|
31
31
|
spinAnimation?: string;
|
|
32
32
|
}
|
|
33
|
-
export type BaseOption = {
|
|
34
|
-
label?: string;
|
|
35
|
-
value?: string;
|
|
36
|
-
content?: string;
|
|
37
|
-
} & Record<string, unknown>;
|
|
38
|
-
export type OptionLabelGetter<T> = (option: T) => string;
|
|
39
|
-
export type OptionValueGetter<T> = (option: T) => string;
|
|
40
33
|
export type SelectOption = {
|
|
41
34
|
label: string;
|
|
42
35
|
value: string;
|
|
@@ -46,13 +39,12 @@ export type NoResultsType = ReactNode | string | {
|
|
|
46
39
|
icon?: IconType;
|
|
47
40
|
text: string;
|
|
48
41
|
};
|
|
49
|
-
export type CreatableSelectProps
|
|
50
|
-
options:
|
|
51
|
-
value:
|
|
42
|
+
export type CreatableSelectProps = {
|
|
43
|
+
options: SelectOption[] | null;
|
|
44
|
+
value: SelectOption | SelectOption[] | null;
|
|
52
45
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
53
|
-
onClick?: (value:
|
|
54
|
-
|
|
55
|
-
onCreateOption?: (inputValue: string) => Promise<T | void> | T | void;
|
|
46
|
+
onClick?: (value: SelectOption | SelectOption[] | null) => void;
|
|
47
|
+
onCreateOption?: (inputValue: string) => Promise<void> | void;
|
|
56
48
|
placeholder?: string;
|
|
57
49
|
isLoading?: boolean;
|
|
58
50
|
isDisabled?: boolean;
|
|
@@ -66,9 +58,7 @@ export type CreatableSelectProps<T = SelectOption> = {
|
|
|
66
58
|
tailwindStyle?: TailwindStyleProps;
|
|
67
59
|
label?: string;
|
|
68
60
|
iconSrc: IconSourceProps;
|
|
69
|
-
fetchOptions?: (inputValue: string) => Promise<
|
|
61
|
+
fetchOptions?: (inputValue: string) => Promise<SelectOption[]>;
|
|
70
62
|
onAddClick: (e: boolean) => void;
|
|
71
63
|
isMultiSelect?: boolean;
|
|
72
|
-
getOptionLabel?: OptionLabelGetter<T>;
|
|
73
|
-
getOptionValue?: OptionValueGetter<T>;
|
|
74
64
|
};
|
|
@@ -6,13 +6,12 @@ export interface InputMultiselectProps {
|
|
|
6
6
|
autoComplete: boolean;
|
|
7
7
|
autoFocus: boolean;
|
|
8
8
|
value: string[] | null;
|
|
9
|
-
onChangeHandler:
|
|
9
|
+
onChangeHandler: any;
|
|
10
10
|
onFocusHandler?: (event: React.FocusEvent) => void;
|
|
11
11
|
onKeyUpHandler?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
12
12
|
handleKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
13
13
|
onBlurHandler?: (event: React.FocusEvent) => void;
|
|
14
14
|
closeIconSRC: string;
|
|
15
|
-
inputRef?: React.RefObject<HTMLInputElement>;
|
|
16
15
|
style?: {
|
|
17
16
|
width?: string;
|
|
18
17
|
margin?: string;
|