hi-tm 0.0.1 → 0.0.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/README.md +61 -0
- package/dist/components/Cards/AutoComplete&DropDown/ItemCard.js +2 -2
- package/dist/components/DropDowns/CreatableDropDown.d.ts +3 -0
- package/dist/components/DropDowns/CreatableDropDown.js +255 -0
- package/dist/components/Inputs/InputMultiselect.js +17 -7
- package/dist/components/Layout/Headers/HeaderLayout.js +9 -3
- package/dist/components/Layout/Sidebar.js +1 -1
- package/dist/components/Table/ModernTable/ModernTable.d.ts +4 -0
- package/dist/components/Table/ModernTable/ModernTable.js +421 -0
- package/dist/components/Table/ModernTable/ModernTableHeader.d.ts +102 -0
- package/dist/components/Table/ModernTable/ModernTableHeader.js +322 -0
- package/dist/components/Table/RtlTable/RtlTable.d.ts +5 -0
- package/dist/components/Table/RtlTable/RtlTable.js +126 -0
- package/dist/components/Table/TableHeaderDiv.js +1 -1
- package/dist/components/Table/TableRowDiv.d.ts +1 -0
- package/dist/components/Table/TableRowDiv.js +0 -1
- package/dist/components/Wrapper/Bounded.d.ts +5 -3
- package/dist/components/Wrapper/Bounded.js +6 -6
- package/dist/components/Wrapper/ModernTable/ModernTableBounded.d.ts +26 -0
- package/dist/components/Wrapper/ModernTable/ModernTableBounded.js +23 -0
- package/dist/components/Wrapper/TableBodyBoundedDiv.js +1 -1
- package/dist/components/Wrapper/TableBoundedDiv.d.ts +2 -2
- package/dist/components/Wrapper/TableBoundedDiv.js +2 -2
- package/dist/components/sections/components/Tabs/TabsComponent.js +6 -1
- package/dist/elements/Loader.d.ts +3 -0
- package/dist/elements/Loader.js +21 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +14 -1
- package/dist/styles/globals.css +100 -96
- package/dist/types/DropDown/CreatableDropDown.d.ts +57 -0
- package/dist/types/DropDown/CreatableDropDown.js +2 -0
- package/dist/types/ModernTable/index.d.ts +87 -0
- package/dist/types/ModernTable/index.js +2 -0
- package/dist/types/RtlTable/index.d.ts +73 -0
- package/dist/types/RtlTable/index.js +2 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import './styles/globals.css';
|
|
2
|
+
// Wrapper ..............................................................................................................................................................................................
|
|
3
|
+
export { default as GlobalWrapper } from './components/Wrapper/GlobalWrapper';
|
|
4
|
+
export { default as Bounded } from './components/Wrapper/Bounded';
|
|
5
|
+
export { default as ModernTableBounded } from './components/Wrapper/ModernTable/ModernTableBounded';
|
|
6
|
+
|
|
7
|
+
// Layout ..............................................................................................................................................................................................
|
|
8
|
+
export { default as HeaderLayout } from './components/Layout/Headers/HeaderLayout';
|
|
9
|
+
// export { default as FooterLayout } from './components/Layout/Footers/FooterLayout';
|
|
10
|
+
export { default as SidebarLayout } from './components/Layout/Sidebar';
|
|
11
|
+
export { default as SelectBranchHeader } from './components/Layout/Headers/HeaderSelectBranch';
|
|
12
|
+
|
|
13
|
+
export { default as RangePicker } from './components/Inputs/RangePicker';
|
|
14
|
+
export { default as TextArea } from './components/Inputs/TextArea';
|
|
15
|
+
export { default as Toggle } from './components/Inputs/Toggle';
|
|
16
|
+
|
|
17
|
+
// Inputs ..............................................................................................................................................................................................
|
|
18
|
+
export { default as InputPercent } from './components/Inputs/InputPercent';
|
|
19
|
+
export { default as TextInput } from './components/Inputs/TextInput';
|
|
20
|
+
export { default as InputSearch } from './components/Inputs/InputSearch';
|
|
21
|
+
export { default as InputCurrency } from './components/Inputs/InputCurrency';
|
|
22
|
+
export { default as InputMultiselect } from './components/Inputs/InputMultiselect';
|
|
23
|
+
export { default as InputBarcode } from './components/Inputs/InputBarcode';
|
|
24
|
+
export { default as DaysCheckBox } from './components/Inputs/DaysCheckBox';
|
|
25
|
+
// Button ..............................................................................................................................................................................................
|
|
26
|
+
export { default as Button } from './components/Inputs/Buttons/Button';
|
|
27
|
+
|
|
28
|
+
// Modal ..............................................................................................................................................................................................
|
|
29
|
+
export { default as Modal } from './components/Wrapper/Modals/Modal';
|
|
30
|
+
|
|
31
|
+
// AutoComplete ..............................................................................................................................................................................................
|
|
32
|
+
export { default as AutoComplete } from './components/AutoComplete/AutoComplete';
|
|
33
|
+
export { default as AutoCompleteMultiSelect } from './components/AutoComplete/AutoCompleteMultiSelect';
|
|
34
|
+
export { default as TreeAutoComplete } from './components/AutoComplete/TreeAutoComplete';
|
|
35
|
+
|
|
36
|
+
// Table..............................................................................................................................................................................................
|
|
37
|
+
export { default as TableBounded } from './components/Wrapper/TableBounded';
|
|
38
|
+
export { default as TableBodyBounded } from './components/Wrapper/TableBodyBounded';
|
|
39
|
+
export { default as TableHeader } from './components/Table/TableHeader';
|
|
40
|
+
export { default as TableRow } from './components/Table/TableRow';
|
|
41
|
+
|
|
42
|
+
// ModernTable..............................................................................................................................................................................................
|
|
43
|
+
export { default as ModernTable } from './components/Table/ModernTable/ModernTable';
|
|
44
|
+
export { default as ModernTableHeader } from './components/Table/ModernTable/ModernTableHeader';
|
|
45
|
+
|
|
46
|
+
// Table Div ..............................................................................................................................................................................................
|
|
47
|
+
export { default as TableHeaderDiv } from './components/Table/TableHeaderDiv';
|
|
48
|
+
export { default as TableRowDiv } from './components/Table/TableRowDiv';
|
|
49
|
+
export { default as TableBoundedDiv } from './components/Wrapper/TableBoundedDiv';
|
|
50
|
+
export { default as TableBodyBoundedDiv } from './components/Wrapper/TableBodyBoundedDiv';
|
|
51
|
+
|
|
52
|
+
// Pagination ......................................................................................................................................................................................
|
|
53
|
+
export { default as PaginationPrimary } from './components/Pagination/PaginationPrimary';
|
|
54
|
+
export { default as DropDownItemsPerPage } from './components/DropDowns/DropDownItemsPerPage';
|
|
55
|
+
|
|
56
|
+
// DropDown
|
|
57
|
+
export { default as DropDown } from './components/DropDowns/DropDown';
|
|
58
|
+
export { default as DropDownMultiSelect } from './components/DropDowns/DropDownMultiSelect';
|
|
59
|
+
|
|
60
|
+
// Tab..........................................................................................................
|
|
61
|
+
export { default as Tabs } from './components/Tabs/Tabs';
|
|
@@ -6,7 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ItemCard = ({ data, handleSelectItem }) => {
|
|
9
|
-
return (react_1.default.createElement("li", { className:
|
|
10
|
-
react_1.default.createElement("p", { className:
|
|
9
|
+
return (react_1.default.createElement("li", { className: "flex w-full cursor-pointer flex-row items-center justify-between text-nowrap rounded-md px-2 py-1 hover:bg-blue-100", onClick: () => handleSelectItem(data) },
|
|
10
|
+
react_1.default.createElement("p", { className: "w-full " }, data.content)));
|
|
11
11
|
};
|
|
12
12
|
exports.default = ItemCard;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CreatableSelectProps } from '../../types/DropDown/CreatableDropDown';
|
|
3
|
+
export default function CreatableSelect({ options, value, onChange, onCreateOption, placeholder, isLoading, isDisabled, isClearable, isCreatable, noOptionsMessage, noResultsFound, loadingMessage, createOptionMessage, className, tailwindStyle, iconSrc, fetchOptions, }: CreatableSelectProps): React.JSX.Element;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.default = CreatableSelect;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
// Default Tailwind styles
|
|
39
|
+
const defaultStyles = {
|
|
40
|
+
container: '',
|
|
41
|
+
trigger: 'flex items-center border rounded-md px-3 py-2 bg-white cursor-pointer',
|
|
42
|
+
input: 'w-full outline-none',
|
|
43
|
+
dropdown: 'absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-60 overflow-y-auto',
|
|
44
|
+
option: 'py-2 px-3 cursor-pointer flex items-center',
|
|
45
|
+
selectedOption: 'font-medium',
|
|
46
|
+
highlightedOption: 'bg-blue-100',
|
|
47
|
+
createOption: 'flex items-center gap-2 py-2 px-3 cursor-pointer hover:bg-blue-50',
|
|
48
|
+
loadingState: 'flex items-center justify-center py-2 text-gray-500',
|
|
49
|
+
noOptions: 'py-2 px-3 text-gray-500',
|
|
50
|
+
noResults: 'py-4 px-3 text-gray-500 flex flex-col items-center justify-center gap-2',
|
|
51
|
+
clearButton: 'p-1 rounded-full hover:bg-gray-100',
|
|
52
|
+
icon: 'w-4 h-4 text-gray-400',
|
|
53
|
+
separator: 'h-4 border-l mx-2', // Style for the vertical line separator
|
|
54
|
+
};
|
|
55
|
+
// Helper function to render different icon types
|
|
56
|
+
const renderIcon = (icon, className = '') => {
|
|
57
|
+
if (typeof icon === 'string') {
|
|
58
|
+
return react_1.default.createElement("img", { src: icon || '/placeholder.svg', alt: "", className: className });
|
|
59
|
+
}
|
|
60
|
+
else if (typeof icon === 'object' && 'src' in icon) {
|
|
61
|
+
return react_1.default.createElement("img", { src: icon.src || '/placeholder.svg', alt: icon.alt || '', className: className });
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return icon;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
// Helper function to render the no results message
|
|
68
|
+
const renderNoResults = (noResults, className, searchIcon) => {
|
|
69
|
+
if (!noResults) {
|
|
70
|
+
return (react_1.default.createElement("div", { className: className },
|
|
71
|
+
renderIcon(searchIcon, 'w-6 h-6 mb-1'),
|
|
72
|
+
react_1.default.createElement("span", null, "No results found")));
|
|
73
|
+
}
|
|
74
|
+
if (typeof noResults === 'string') {
|
|
75
|
+
return react_1.default.createElement("div", { className: className }, noResults);
|
|
76
|
+
}
|
|
77
|
+
else if (typeof noResults === 'object' && 'text' in noResults) {
|
|
78
|
+
return (react_1.default.createElement("div", { className: className },
|
|
79
|
+
noResults.icon
|
|
80
|
+
? renderIcon(noResults.icon, 'w-6 h-6 mb-1')
|
|
81
|
+
: renderIcon(searchIcon, 'w-6 h-6 mb-1'),
|
|
82
|
+
react_1.default.createElement("span", null, noResults.text)));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return noResults;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function CreatableSelect({ options = [], value, onChange, onCreateOption, placeholder = 'Select...', isLoading = false, isDisabled = false, isClearable = true, isCreatable = true, noOptionsMessage = 'No options available', noResultsFound, loadingMessage = 'Loading...', createOptionMessage = 'Create option', className = '', tailwindStyle = {}, iconSrc, fetchOptions, }) {
|
|
89
|
+
const styles = {
|
|
90
|
+
...defaultStyles,
|
|
91
|
+
...tailwindStyle,
|
|
92
|
+
};
|
|
93
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
94
|
+
const [inputValue, setInputValue] = (0, react_1.useState)('');
|
|
95
|
+
const [filteredOptions, setFilteredOptions] = (0, react_1.useState)(options ?? []);
|
|
96
|
+
const [highlightedIndex, setHighlightedIndex] = (0, react_1.useState)(0);
|
|
97
|
+
const [internalLoading, setInternalLoading] = (0, react_1.useState)(false);
|
|
98
|
+
const [hasSearched, setHasSearched] = (0, react_1.useState)(false);
|
|
99
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
100
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
101
|
+
(0, react_1.useEffect)(() => {
|
|
102
|
+
if (inputValue === '') {
|
|
103
|
+
setFilteredOptions(options ?? []);
|
|
104
|
+
setHasSearched(false);
|
|
105
|
+
}
|
|
106
|
+
}, [options, inputValue]);
|
|
107
|
+
(0, react_1.useEffect)(() => {
|
|
108
|
+
const handler = (e) => {
|
|
109
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
110
|
+
setIsOpen(false);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
document.addEventListener('click', handler);
|
|
114
|
+
return () => {
|
|
115
|
+
document.removeEventListener('click', handler);
|
|
116
|
+
};
|
|
117
|
+
}, []);
|
|
118
|
+
const handleInputChange = async (e) => {
|
|
119
|
+
const value = e.target.value;
|
|
120
|
+
setInputValue(value);
|
|
121
|
+
setIsOpen(true);
|
|
122
|
+
if (fetchOptions && value.trim() !== '') {
|
|
123
|
+
setInternalLoading(true);
|
|
124
|
+
setHasSearched(true);
|
|
125
|
+
try {
|
|
126
|
+
const newOptions = await fetchOptions(value);
|
|
127
|
+
setFilteredOptions(newOptions);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
console.error('Error fetching options:', error);
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
setInternalLoading(false);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else if (value.trim() === '') {
|
|
137
|
+
setFilteredOptions(options ?? []);
|
|
138
|
+
setHasSearched(false);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const handleKeyDown = (e) => {
|
|
142
|
+
if (isDisabled)
|
|
143
|
+
return;
|
|
144
|
+
switch (e.key) {
|
|
145
|
+
case 'Enter':
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
if (isOpen) {
|
|
148
|
+
if (filteredOptions.length > 0 && highlightedIndex < filteredOptions.length) {
|
|
149
|
+
onChange(filteredOptions[highlightedIndex]);
|
|
150
|
+
}
|
|
151
|
+
else if (isCreatable &&
|
|
152
|
+
inputValue &&
|
|
153
|
+
!filteredOptions.some((o) => o.label === inputValue)) {
|
|
154
|
+
handleCreateOption();
|
|
155
|
+
}
|
|
156
|
+
setIsOpen(false);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
setIsOpen(true);
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
case 'Escape':
|
|
163
|
+
setIsOpen(false);
|
|
164
|
+
break;
|
|
165
|
+
case 'ArrowUp':
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
if (isOpen) {
|
|
168
|
+
setHighlightedIndex((prev) => (prev > 0 ? prev - 1 : filteredOptions.length - 1));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
setIsOpen(true);
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case 'ArrowDown':
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
if (isOpen) {
|
|
177
|
+
setHighlightedIndex((prev) => (prev < filteredOptions.length - 1 ? prev + 1 : 0));
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
setIsOpen(true);
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const handleCreateOption = async () => {
|
|
186
|
+
if (!inputValue.trim() || !isCreatable || !onCreateOption)
|
|
187
|
+
return;
|
|
188
|
+
setInternalLoading(true);
|
|
189
|
+
try {
|
|
190
|
+
await onCreateOption(inputValue);
|
|
191
|
+
const newOption = { label: inputValue, value: inputValue.toLowerCase().replace(/\s+/g, '-') };
|
|
192
|
+
onChange(newOption);
|
|
193
|
+
setInputValue('');
|
|
194
|
+
setHasSearched(false);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
console.error('Error creating option:', error);
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
setInternalLoading(false);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const toggleDropdown = () => {
|
|
204
|
+
if (!isDisabled) {
|
|
205
|
+
setIsOpen((prev) => !prev);
|
|
206
|
+
if (!isOpen && inputRef.current) {
|
|
207
|
+
inputRef.current.focus();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const clearValue = (e) => {
|
|
212
|
+
e.stopPropagation();
|
|
213
|
+
onChange(null);
|
|
214
|
+
setInputValue('');
|
|
215
|
+
setHasSearched(false);
|
|
216
|
+
};
|
|
217
|
+
const selectOption = (option) => {
|
|
218
|
+
onChange(option);
|
|
219
|
+
setInputValue('');
|
|
220
|
+
setIsOpen(false);
|
|
221
|
+
setHasSearched(false);
|
|
222
|
+
};
|
|
223
|
+
const showLoading = isLoading || internalLoading;
|
|
224
|
+
return (react_1.default.createElement("div", { ref: containerRef, className: `relative w-full ${className} ${styles.container}`, onKeyDown: handleKeyDown },
|
|
225
|
+
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 },
|
|
226
|
+
value ? (react_1.default.createElement("div", { className: "flex-grow truncate" }, value.label)) : (react_1.default.createElement("input", { ref: inputRef, type: "text", className: `${styles.input} ${isDisabled ? 'bg-gray-100' : ''}`, placeholder: placeholder, value: inputValue, onChange: handleInputChange, disabled: isDisabled, onClick: (e) => e.stopPropagation() })),
|
|
227
|
+
react_1.default.createElement("div", { className: "flex items-center gap-1" },
|
|
228
|
+
showLoading && renderIcon(iconSrc.loading, `animate-spin ${styles.icon}`),
|
|
229
|
+
value && isClearable && !isDisabled && !showLoading && (react_1.default.createElement("button", { onClick: clearValue, className: styles.clearButton }, renderIcon(iconSrc.clear, styles.icon))),
|
|
230
|
+
styles.separator && react_1.default.createElement("div", { className: styles.separator }),
|
|
231
|
+
isOpen
|
|
232
|
+
? renderIcon(iconSrc.dropdownOpen, styles.icon)
|
|
233
|
+
: renderIcon(iconSrc.dropdownClosed, styles.icon))),
|
|
234
|
+
isOpen && (react_1.default.createElement("div", { className: styles.dropdown }, showLoading ? (react_1.default.createElement("div", { className: styles.loadingState },
|
|
235
|
+
renderIcon(iconSrc.loading, `animate-spin mr-2 ${styles.icon}`),
|
|
236
|
+
loadingMessage)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
237
|
+
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) },
|
|
238
|
+
value?.value === option.value &&
|
|
239
|
+
renderIcon(iconSrc.checkmark, 'w-4 h-4 mr-2 text-blue-500'),
|
|
240
|
+
react_1.default.createElement("span", { className: value?.value === option.value ? styles.selectedOption : '' }, option.label)))))),
|
|
241
|
+
filteredOptions.length === 0 && !inputValue && (react_1.default.createElement("div", { className: styles.noOptions }, noOptionsMessage)),
|
|
242
|
+
filteredOptions.length === 0 &&
|
|
243
|
+
inputValue &&
|
|
244
|
+
hasSearched &&
|
|
245
|
+
renderNoResults(noResultsFound, styles?.noResults, iconSrc.create),
|
|
246
|
+
isCreatable &&
|
|
247
|
+
inputValue &&
|
|
248
|
+
!options?.some((o) => o.label.toLowerCase() === inputValue.toLowerCase()) && (react_1.default.createElement("div", { className: styles.createOption, onClick: handleCreateOption },
|
|
249
|
+
renderIcon(iconSrc.create, styles.icon),
|
|
250
|
+
react_1.default.createElement("span", null,
|
|
251
|
+
createOptionMessage,
|
|
252
|
+
": \"",
|
|
253
|
+
inputValue,
|
|
254
|
+
"\"")))))))));
|
|
255
|
+
}
|
|
@@ -61,6 +61,7 @@ const InputMultiselect = ({ label, required, textError, placeholder, onChangeHan
|
|
|
61
61
|
}, }) => {
|
|
62
62
|
const [items, setItems] = (0, react_1.useState)([]);
|
|
63
63
|
const [currentValue, setCurrentValue] = (0, react_1.useState)('');
|
|
64
|
+
const [showError, setShowError] = (0, react_1.useState)(false);
|
|
64
65
|
const inputRef = (0, react_1.useRef)(null);
|
|
65
66
|
const isErrorVisible = () => {
|
|
66
67
|
return !(textError && textError.trim() !== '');
|
|
@@ -83,9 +84,16 @@ const InputMultiselect = ({ label, required, textError, placeholder, onChangeHan
|
|
|
83
84
|
e.preventDefault();
|
|
84
85
|
setItems((prevItems) => [...prevItems, currentValue.trim()]);
|
|
85
86
|
setCurrentValue('');
|
|
87
|
+
setShowError(false); // Reset error on Enter
|
|
86
88
|
}
|
|
87
89
|
propHandleKeyDown?.(e);
|
|
88
90
|
};
|
|
91
|
+
const handleBlur = (e) => {
|
|
92
|
+
if (currentValue.trim() !== '') {
|
|
93
|
+
setShowError(true); // Show error if there's unconfirmed input
|
|
94
|
+
}
|
|
95
|
+
onBlurHandler?.(e);
|
|
96
|
+
};
|
|
89
97
|
(0, react_1.useEffect)(() => {
|
|
90
98
|
onChangeHandler(items);
|
|
91
99
|
}, [items]);
|
|
@@ -93,14 +101,16 @@ const InputMultiselect = ({ label, required, textError, placeholder, onChangeHan
|
|
|
93
101
|
setItems((prevItems) => prevItems.filter((_, i) => i !== index));
|
|
94
102
|
};
|
|
95
103
|
return (react_1.default.createElement("div", { className: `${style.width} ${style.margin} relative ` },
|
|
96
|
-
react_1.default.createElement("label", { htmlFor: label, className:
|
|
97
|
-
react_1.default.createElement("p", { className:
|
|
104
|
+
react_1.default.createElement("label", { htmlFor: label, className: "flex items-center gap-2 mx-3" },
|
|
105
|
+
react_1.default.createElement("p", { className: "text-sm text-text-color-primary font-medium cursor-pointer" }, label),
|
|
98
106
|
react_1.default.createElement("span", { className: `text-red-primary font-bold ${required ? 'block' : 'hidden'}` }, "*")),
|
|
99
|
-
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()
|
|
100
|
-
|
|
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()
|
|
108
|
+
? 'border-gray-tertiary focus:border-gray-quaternary'
|
|
109
|
+
: 'border-red-primary'}` },
|
|
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" },
|
|
101
111
|
item,
|
|
102
|
-
react_1.default.createElement(image_1.default, { src: closeIconSRC, alt:
|
|
103
|
-
react_1.default.createElement("input", { ref: inputRef, type:
|
|
104
|
-
!isErrorVisible() && react_1.default.createElement("p", { className:
|
|
112
|
+
react_1.default.createElement(image_1.default, { src: closeIconSRC, alt: "close", width: 22, height: 22, onClick: () => handleRemoveItem(index), className: "inline-block cursor-pointer" })))),
|
|
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())));
|
|
105
115
|
};
|
|
106
116
|
exports.default = InputMultiselect;
|
|
@@ -224,7 +224,9 @@ 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" }))),
|
|
225
225
|
react_1.default.createElement("div", { ref: modalCloseRefuserBranchesPC, className: `relative bg-inherit ${branchNameSelected.id === 0 ? 'hidden' : 'flex'}` },
|
|
226
226
|
react_1.default.createElement("div", { onClick: handleModalShowBranches, className: "select-none-custom flex flex-row items-center justify-center gap-3" },
|
|
227
|
-
react_1.default.createElement(image_1.default, { src: `${
|
|
227
|
+
react_1.default.createElement(image_1.default, { src: `${branchNameSelected.logoName === '' || branchNameSelected.logoName === null
|
|
228
|
+
? imageDefaultSRC
|
|
229
|
+
: `${baseUrlCDN}/${branchName}/${branchNameSelected.logoName}`}`, alt: "logo.svg", width: 24, height: 24, className: `rounded-md ${userBranchesData !== undefined && userBranchesData.length === 1
|
|
228
230
|
? 'cursor-default'
|
|
229
231
|
: 'cursor-pointer'}` }),
|
|
230
232
|
react_1.default.createElement("p", { className: `${userBranchesData !== undefined && userBranchesData.length === 1
|
|
@@ -238,7 +240,9 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
238
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 ? 'scale-y-100 opacity-100' : 'scale-y-0 opacity-0'} origin-top` },
|
|
239
241
|
react_1.default.createElement("ul", { className: "flex h-auto w-full flex-col items-start justify-center gap-3 bg-inherit p-3" }, userBranchesData &&
|
|
240
242
|
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" },
|
|
241
|
-
react_1.default.createElement(image_1.default, { src: `${
|
|
243
|
+
react_1.default.createElement(image_1.default, { src: `${item.logoName === '' || item.logoName === null
|
|
244
|
+
? imageDefaultSRC
|
|
245
|
+
: `${baseUrlCDN}/${branchName}/${item.logoName}`}`, alt: "logo.svg", width: 16, height: 16, className: "rounded-xl" }),
|
|
242
246
|
react_1.default.createElement("p", { className: "select-none-custom cursor-pointer text-nowrap text-sm font-normal text-text-color-primary" }, item.name))))))),
|
|
243
247
|
react_1.default.createElement("div", { ref: modalCloseRefPC, className: "flex h-full flex-row-reverse items-center justify-center gap-4" },
|
|
244
248
|
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" },
|
|
@@ -282,7 +286,9 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
282
286
|
react_1.default.createElement(image_1.default, { src: iconsSRC.menuIconSRC, alt: "menu.svg", width: 20, height: 20, className: "h-full w-full" })),
|
|
283
287
|
react_1.default.createElement("div", { ref: modalCloseRefuserBranchesMobile, className: `relative bg-inherit ${branchNameSelected.id === 0 ? 'hidden' : 'flex'}` },
|
|
284
288
|
react_1.default.createElement("div", { onClick: handleModalShowBranches, className: "select-none-custom flex flex-row items-center justify-center gap-3" },
|
|
285
|
-
react_1.default.createElement(image_1.default, { src: `${
|
|
289
|
+
react_1.default.createElement(image_1.default, { src: `${branchNameSelected.logoName === '' || branchNameSelected.logoName === null
|
|
290
|
+
? imageDefaultSRC
|
|
291
|
+
: `${baseUrlCDN}/${branchName}/${branchNameSelected.logoName}`}`, alt: "logo.svg", width: 24, height: 24, className: `rounded-md ${userBranchesData !== undefined && userBranchesData.length === 1
|
|
286
292
|
? 'cursor-default'
|
|
287
293
|
: 'cursor-pointer'}` }),
|
|
288
294
|
react_1.default.createElement("p", { className: `${userBranchesData !== undefined && userBranchesData.length === 1
|
|
@@ -181,7 +181,7 @@ const Sidebar = ({ isOpenSidebar: isOpenSideBarProps, logoSRC, sidebarData, tabs
|
|
|
181
181
|
}, className: "flex h-11 w-full cursor-pointer flex-row items-center justify-start gap-2 rounded-none border-b border-solid border-gray-primary bg-inherit pr-3" },
|
|
182
182
|
react_1.default.createElement(image_1.default, { src: iconsSRC.closeSidebarIconSRC, alt: "closeSidebarIcon", width: 24, height: 24, className: "absolute left-tiny rotate-180" }),
|
|
183
183
|
react_1.default.createElement("p", { className: "text-base font-semibold text-text-color-primary" }, activeItemSidebar?.name)),
|
|
184
|
-
react_1.default.createElement("ul", { className: "flex w-full flex-col gap-2 px-3 pt-2" }, activeItemSidebar?.FirstSubsets?.map((item) => (react_1.default.createElement("li", { onClick: () => {
|
|
184
|
+
react_1.default.createElement("ul", { className: "flex w-full flex-col gap-2 px-3 pt-2 overflow-y-scroll" }, activeItemSidebar?.FirstSubsets?.map((item) => (react_1.default.createElement("li", { onClick: () => {
|
|
185
185
|
toggleFirstSubset(item.id);
|
|
186
186
|
setBreadCrumbs({
|
|
187
187
|
sidebar: activeItemSidebar.name,
|