mautourco-components 0.2.45 → 0.2.46
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/atoms/Inputs/Input/Input.js +1 -1
- package/dist/components/organisms/QuoteHeader/QuoteHeader.js +31 -6
- package/dist/components/organisms/Table/columns/booking-columns.js +1 -8
- package/dist/components/organisms/Table/columns/quotation-columns.js +1 -8
- package/package.json +1 -1
- package/src/components/atoms/Inputs/Input/Input.tsx +1 -1
- package/src/components/organisms/QuoteHeader/QuoteHeader.tsx +37 -6
- package/src/components/organisms/Table/columns/booking-columns.tsx +1 -17
- package/src/components/organisms/Table/columns/quotation-columns.tsx +1 -17
|
@@ -11,6 +11,6 @@ var Input = function (_a) {
|
|
|
11
11
|
disabled: 'input-field--disabled',
|
|
12
12
|
};
|
|
13
13
|
var inputClasses = "".concat(baseClasses, " ").concat(variantClasses[variant], " ").concat(icon ? "input-field--with-icon input-field--icon-".concat(iconPosition) : '', " ").concat(className).trim();
|
|
14
|
-
return (_jsxs("div", { className: "input-wrapper ".concat(icon ? 'input-wrapper--with-icon' : '').trim(), children: [icon && iconPosition === 'leading' && (_jsx("span", { className: "input-icon input-icon--leading", children: _jsx(Icon, { name: icon, size: "sm" }) })), _jsx("input", { id: id, type: type, className: inputClasses, placeholder: placeholder, value: value, disabled: disabled || variant === 'disabled',
|
|
14
|
+
return (_jsxs("div", { className: "input-wrapper ".concat(icon ? 'input-wrapper--with-icon' : '').trim(), children: [icon && iconPosition === 'leading' && (_jsx("span", { className: "input-icon input-icon--leading", children: _jsx(Icon, { name: icon, size: "sm" }) })), _jsx("input", { id: id, type: type, className: inputClasses, placeholder: placeholder, value: value, disabled: disabled || variant === 'disabled', onInput: onChange, onFocus: onFocus, onBlur: onBlur }), icon && iconPosition === 'trailing' && (_jsx("span", { className: "input-icon input-icon--trailing", children: _jsx(Icon, { name: icon, size: "sm" }) }))] }));
|
|
15
15
|
};
|
|
16
16
|
export default Input;
|
|
@@ -21,7 +21,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
import
|
|
24
|
+
import debounce from 'lodash/debounce';
|
|
25
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
25
26
|
import Button from '../../atoms/Button/Button';
|
|
26
27
|
import DropdownInput from '../../atoms/Inputs/DropdownInput/DropdownInput';
|
|
27
28
|
import Input from '../../atoms/Inputs/Input/Input';
|
|
@@ -52,6 +53,34 @@ export function QuoteHeader(props) {
|
|
|
52
53
|
search: '',
|
|
53
54
|
}), currentValue = _c[0], setCurrentValue = _c[1];
|
|
54
55
|
var _d = useState((_a = currentFilter === null || currentFilter === void 0 ? void 0 : currentFilter.search) !== null && _a !== void 0 ? _a : ''), searchValue = _d[0], setSearchValue = _d[1];
|
|
56
|
+
// Create a ref to store the debounced function
|
|
57
|
+
var debouncedFilterChangeRef = useRef(debounce(function (value) {
|
|
58
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange('search', value);
|
|
59
|
+
setCurrentValue(function (prev) { return (__assign(__assign({}, prev), { search: value })); });
|
|
60
|
+
}, 500));
|
|
61
|
+
// Update the debounced function when onFilterChange changes
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
// Cancel the previous debounced function
|
|
64
|
+
debouncedFilterChangeRef.current.cancel();
|
|
65
|
+
// Create a new debounced function
|
|
66
|
+
debouncedFilterChangeRef.current = debounce(function (value) {
|
|
67
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange('search', value);
|
|
68
|
+
setCurrentValue(function (prev) { return (__assign(__assign({}, prev), { search: value })); });
|
|
69
|
+
}, 500);
|
|
70
|
+
}, [onFilterChange]);
|
|
71
|
+
// Cleanup debounced function on unmount
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
return function () {
|
|
74
|
+
debouncedFilterChangeRef.current.cancel();
|
|
75
|
+
};
|
|
76
|
+
}, []);
|
|
77
|
+
var handleInputChange = useCallback(function (e) {
|
|
78
|
+
var value = e.target.value;
|
|
79
|
+
// Update input value immediately for responsive UI
|
|
80
|
+
setSearchValue(value);
|
|
81
|
+
// Debounce the filter change callback
|
|
82
|
+
debouncedFilterChangeRef.current(value);
|
|
83
|
+
}, []);
|
|
55
84
|
useEffect(function () {
|
|
56
85
|
if (currentFilter && Object.keys(currentFilter).length > 0) {
|
|
57
86
|
var search = currentFilter.search, rest = __rest(currentFilter, ["search"]);
|
|
@@ -63,11 +92,7 @@ export function QuoteHeader(props) {
|
|
|
63
92
|
setSearchValue('');
|
|
64
93
|
}
|
|
65
94
|
}, [currentFilter]);
|
|
66
|
-
return (_jsxs("div", { className: "quote-header", children: [_jsx(Heading, { level: 4, as: "h1", className: "quote-header__title", color: "accent", children: "Quotation & Booking" }), _jsxs("div", { className: "flex gap-4", children: [_jsx(Button, { variant: current === 'quotation' ? 'primary' : 'outline-primary', className: "quote-header__button", onClick: function () { return onNavigate('quotation'); }, children: "Quotation" }), _jsx(Button, { variant: current === 'booking' ? 'primary' : 'outline-primary', className: "quote-header__button", onClick: function () { return onNavigate('booking'); }, children: "Booking" })] }), _jsxs("div", { className: "quote-header__search-container", children: [_jsx(Input, { placeholder: "Search", icon: "search", iconPosition: "leading", className: "quote-header__search", value: searchValue, onChange: function (
|
|
67
|
-
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange('search', e.target.value);
|
|
68
|
-
setCurrentValue(__assign(__assign({}, currentValue), { search: e.target.value }));
|
|
69
|
-
setSearchValue(e.target.value);
|
|
70
|
-
} }), _jsx(Button, { variant: "primary", leadingIcon: "plus-circle", iconSize: "md", size: "sm", onClick: onNewQuote, children: "New quote" })] }), _jsx("div", { className: "quote-header__filters", children: Object.entries(filterConfig).map(function (_a) {
|
|
95
|
+
return (_jsxs("div", { className: "quote-header", children: [_jsx(Heading, { level: 4, as: "h1", className: "quote-header__title", color: "accent", children: "Quotation & Booking" }), _jsxs("div", { className: "flex gap-4", children: [_jsx(Button, { variant: current === 'quotation' ? 'primary' : 'outline-primary', className: "quote-header__button", onClick: function () { return onNavigate('quotation'); }, children: "Quotation" }), _jsx(Button, { variant: current === 'booking' ? 'primary' : 'outline-primary', className: "quote-header__button", onClick: function () { return onNavigate('booking'); }, children: "Booking" })] }), _jsxs("div", { className: "quote-header__search-container", children: [_jsx(Input, { placeholder: "Search", icon: "search", iconPosition: "leading", className: "quote-header__search", value: searchValue, onChange: handleInputChange }), _jsx(Button, { variant: "primary", leadingIcon: "plus-circle", iconSize: "md", size: "sm", onClick: onNewQuote, children: "New quote" })] }), _jsx("div", { className: "quote-header__filters", children: Object.entries(filterConfig).map(function (_a) {
|
|
71
96
|
var key = _a[0], value = _a[1];
|
|
72
97
|
return (_jsx(DropdownInput, { placeholder: value.placeholder, options: value.options, value: currentValue[key], onSelect: function (value) {
|
|
73
98
|
var _a;
|
|
@@ -30,14 +30,7 @@ export var bookingColumns = function (_a) {
|
|
|
30
30
|
width: 150,
|
|
31
31
|
cell: function (value) {
|
|
32
32
|
if (value === void 0) { value = ''; }
|
|
33
|
-
|
|
34
|
-
var regex = new RegExp("(".concat(keywords !== null && keywords !== void 0 ? keywords : '', ")"), 'gi');
|
|
35
|
-
if (regex.test(currentValue)) {
|
|
36
|
-
return (_jsx(Text, { variant: "medium", size: "sm", children: _jsx("span", { dangerouslySetInnerHTML: {
|
|
37
|
-
__html: currentValue.replace(regex, "<span class=\"text--highlight\">$1</span>"),
|
|
38
|
-
} }) }));
|
|
39
|
-
}
|
|
40
|
-
return (_jsx(Text, { variant: "medium", size: "sm", children: currentValue }));
|
|
33
|
+
return (_jsx(Text, { variant: "medium", size: "sm", children: value }));
|
|
41
34
|
},
|
|
42
35
|
},
|
|
43
36
|
{
|
|
@@ -32,14 +32,7 @@ export var quotationColumns = function (_a) {
|
|
|
32
32
|
cell: function (value, _raw, _index, childIndex) {
|
|
33
33
|
if (value === void 0) { value = ''; }
|
|
34
34
|
if (childIndex === undefined) {
|
|
35
|
-
|
|
36
|
-
var regex = new RegExp("(".concat(keywords !== null && keywords !== void 0 ? keywords : '', ")"), 'gi');
|
|
37
|
-
if (regex.test(currentValue)) {
|
|
38
|
-
return (_jsx(Text, { variant: "medium", size: "sm", children: _jsx("span", { dangerouslySetInnerHTML: {
|
|
39
|
-
__html: currentValue.replace(regex, "<span class=\"text--highlight\">$1</span>"),
|
|
40
|
-
} }) }));
|
|
41
|
-
}
|
|
42
|
-
return (_jsx(Text, { variant: "medium", size: "sm", children: currentValue }));
|
|
35
|
+
return (_jsx(Text, { variant: "medium", size: "sm", children: value }));
|
|
43
36
|
}
|
|
44
37
|
},
|
|
45
38
|
},
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import debounce from 'lodash/debounce';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
3
|
import Button from '../../atoms/Button/Button';
|
|
3
4
|
import DropdownInput from '../../atoms/Inputs/DropdownInput/DropdownInput';
|
|
4
5
|
import Input from '../../atoms/Inputs/Input/Input';
|
|
@@ -60,6 +61,40 @@ export function QuoteHeader(props: QuoteHeaderProps) {
|
|
|
60
61
|
);
|
|
61
62
|
const [searchValue, setSearchValue] = useState<string>(currentFilter?.search ?? '');
|
|
62
63
|
|
|
64
|
+
// Create a ref to store the debounced function
|
|
65
|
+
const debouncedFilterChangeRef = useRef(
|
|
66
|
+
debounce((value: string) => {
|
|
67
|
+
onFilterChange?.('search', value);
|
|
68
|
+
setCurrentValue((prev) => ({ ...prev, search: value }));
|
|
69
|
+
}, 500)
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// Update the debounced function when onFilterChange changes
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
// Cancel the previous debounced function
|
|
75
|
+
debouncedFilterChangeRef.current.cancel();
|
|
76
|
+
// Create a new debounced function
|
|
77
|
+
debouncedFilterChangeRef.current = debounce((value: string) => {
|
|
78
|
+
onFilterChange?.('search', value);
|
|
79
|
+
setCurrentValue((prev) => ({ ...prev, search: value }));
|
|
80
|
+
}, 500);
|
|
81
|
+
}, [onFilterChange]);
|
|
82
|
+
|
|
83
|
+
// Cleanup debounced function on unmount
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
return () => {
|
|
86
|
+
debouncedFilterChangeRef.current.cancel();
|
|
87
|
+
};
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
const handleInputChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
91
|
+
const value = e.target.value;
|
|
92
|
+
// Update input value immediately for responsive UI
|
|
93
|
+
setSearchValue(value);
|
|
94
|
+
// Debounce the filter change callback
|
|
95
|
+
debouncedFilterChangeRef.current(value);
|
|
96
|
+
}, []);
|
|
97
|
+
|
|
63
98
|
useEffect(() => {
|
|
64
99
|
if (currentFilter && Object.keys(currentFilter).length > 0) {
|
|
65
100
|
const { search, ...rest } = currentFilter;
|
|
@@ -97,11 +132,7 @@ export function QuoteHeader(props: QuoteHeaderProps) {
|
|
|
97
132
|
iconPosition="leading"
|
|
98
133
|
className="quote-header__search"
|
|
99
134
|
value={searchValue}
|
|
100
|
-
onChange={
|
|
101
|
-
onFilterChange?.('search', e.target.value);
|
|
102
|
-
setCurrentValue({ ...currentValue, search: e.target.value });
|
|
103
|
-
setSearchValue(e.target.value);
|
|
104
|
-
}}
|
|
135
|
+
onChange={handleInputChange}
|
|
105
136
|
/>
|
|
106
137
|
<Button
|
|
107
138
|
variant="primary"
|
|
@@ -45,25 +45,9 @@ export const bookingColumns: (params: {
|
|
|
45
45
|
key: 'agency_name',
|
|
46
46
|
width: 150,
|
|
47
47
|
cell: (value = '') => {
|
|
48
|
-
const currentValue = String(value as string);
|
|
49
|
-
const regex = new RegExp(`(${keywords ?? ''})`, 'gi');
|
|
50
|
-
if (regex.test(currentValue)) {
|
|
51
|
-
return (
|
|
52
|
-
<Text variant="medium" size="sm">
|
|
53
|
-
<span
|
|
54
|
-
dangerouslySetInnerHTML={{
|
|
55
|
-
__html: currentValue.replace(
|
|
56
|
-
regex,
|
|
57
|
-
`<span class="text--highlight">$1</span>`
|
|
58
|
-
),
|
|
59
|
-
}}
|
|
60
|
-
/>
|
|
61
|
-
</Text>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
48
|
return (
|
|
65
49
|
<Text variant="medium" size="sm">
|
|
66
|
-
{
|
|
50
|
+
{value as string}
|
|
67
51
|
</Text>
|
|
68
52
|
);
|
|
69
53
|
},
|
|
@@ -51,25 +51,9 @@ export const quotationColumns: (params: {
|
|
|
51
51
|
width: 150,
|
|
52
52
|
cell: (value = '', _raw, _index, childIndex) => {
|
|
53
53
|
if (childIndex === undefined) {
|
|
54
|
-
const currentValue = String(value as string);
|
|
55
|
-
const regex = new RegExp(`(${keywords ?? ''})`, 'gi');
|
|
56
|
-
if (regex.test(currentValue)) {
|
|
57
|
-
return (
|
|
58
|
-
<Text variant="medium" size="sm">
|
|
59
|
-
<span
|
|
60
|
-
dangerouslySetInnerHTML={{
|
|
61
|
-
__html: currentValue.replace(
|
|
62
|
-
regex,
|
|
63
|
-
`<span class="text--highlight">$1</span>`
|
|
64
|
-
),
|
|
65
|
-
}}
|
|
66
|
-
/>
|
|
67
|
-
</Text>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
54
|
return (
|
|
71
55
|
<Text variant="medium" size="sm">
|
|
72
|
-
{
|
|
56
|
+
{value as string}
|
|
73
57
|
</Text>
|
|
74
58
|
);
|
|
75
59
|
}
|