mautourco-components 0.2.42 → 0.2.44
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/molecules/ActionDropdown/ActionDropdown.js +1 -1
- package/dist/components/organisms/QuoteHeader/QuoteHeader.d.ts +3 -1
- package/dist/components/organisms/QuoteHeader/QuoteHeader.js +32 -4
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/molecules/ActionDropdown/ActionDropdown.tsx +1 -1
- package/src/components/organisms/QuoteHeader/QuoteHeader.tsx +36 -6
|
@@ -17,7 +17,7 @@ import './ActionDropdown.css';
|
|
|
17
17
|
export function ActionDropdown(props) {
|
|
18
18
|
var data = props.data, children = props.children, _a = props.maxWidth, maxWidth = _a === void 0 ? '153px' : _a;
|
|
19
19
|
var _b = useState(false), open = _b[0], setOpen = _b[1];
|
|
20
|
-
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { children: children !== null && children !== void 0 ? children : (_jsx("button", { className: "action-dropdown-trigger", children: _jsx(Icon, { name: "more-vertical" }) })) }), _jsx(PopoverContent, { className: "action-dropdown", style: { '--max-width': maxWidth }, align: "end", side: "bottom", avoidCollisions: false, children: data.map(function (item, index) {
|
|
20
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: children !== null && children !== void 0 ? children : (_jsx("button", { className: "action-dropdown-trigger", children: _jsx(Icon, { name: "more-vertical" }) })) }), _jsx(PopoverContent, { className: "action-dropdown", style: { '--max-width': maxWidth }, align: "end", side: "bottom", avoidCollisions: false, children: data.map(function (item, index) {
|
|
21
21
|
var defaultButton = (_jsx("button", { onClick: function () {
|
|
22
22
|
var _a;
|
|
23
23
|
if (item.disabled) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import './QuoteHeader.css';
|
|
2
|
+
export type FilterType = 'date' | 'clientType' | 'fileStatus' | 'search';
|
|
2
3
|
export interface QuoteHeaderProps {
|
|
3
4
|
/** Current tab */
|
|
4
5
|
current: 'quotation' | 'booking';
|
|
@@ -6,6 +7,7 @@ export interface QuoteHeaderProps {
|
|
|
6
7
|
onNavigate: (tab: 'quotation' | 'booking') => void;
|
|
7
8
|
/** Callback to create a new quote */
|
|
8
9
|
onNewQuote: () => void;
|
|
9
|
-
onFilterChange?: (filter:
|
|
10
|
+
onFilterChange?: (filter: FilterType, value: string) => void;
|
|
11
|
+
currentFilter: Record<FilterType, string>;
|
|
10
12
|
}
|
|
11
13
|
export declare function QuoteHeader(props: QuoteHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,8 +9,19 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
12
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { useState } from 'react';
|
|
24
|
+
import { useEffect, useState } from 'react';
|
|
14
25
|
import Button from '../../atoms/Button/Button';
|
|
15
26
|
import DropdownInput from '../../atoms/Inputs/DropdownInput/DropdownInput';
|
|
16
27
|
import Input from '../../atoms/Inputs/Input/Input';
|
|
@@ -32,9 +43,26 @@ var filterConfig = {
|
|
|
32
43
|
},
|
|
33
44
|
};
|
|
34
45
|
export function QuoteHeader(props) {
|
|
35
|
-
var _a
|
|
36
|
-
var _b =
|
|
37
|
-
|
|
46
|
+
var _a;
|
|
47
|
+
var _b = props.current, current = _b === void 0 ? 'quotation' : _b, currentFilter = props.currentFilter, onNavigate = props.onNavigate, onNewQuote = props.onNewQuote, onFilterChange = props.onFilterChange;
|
|
48
|
+
var _c = useState(currentFilter !== null && currentFilter !== void 0 ? currentFilter : {}), currentValue = _c[0], setCurrentValue = _c[1];
|
|
49
|
+
var _d = useState((_a = currentFilter === null || currentFilter === void 0 ? void 0 : currentFilter.search) !== null && _a !== void 0 ? _a : ''), searchValue = _d[0], setSearchValue = _d[1];
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
if (Object.keys(currentFilter !== null && currentFilter !== void 0 ? currentFilter : {}).length > 0) {
|
|
52
|
+
var search = currentFilter.search, rest = __rest(currentFilter, ["search"]);
|
|
53
|
+
setCurrentValue(rest);
|
|
54
|
+
setSearchValue(search);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
setCurrentValue({});
|
|
58
|
+
setSearchValue('');
|
|
59
|
+
}
|
|
60
|
+
}, [currentFilter]);
|
|
61
|
+
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 (e) {
|
|
62
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange('search', e.target.value);
|
|
63
|
+
setCurrentValue(__assign(__assign({}, currentValue), { search: e.target.value }));
|
|
64
|
+
setSearchValue(e.target.value);
|
|
65
|
+
} }), _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) {
|
|
38
66
|
var key = _a[0], value = _a[1];
|
|
39
67
|
return (_jsx(DropdownInput, { placeholder: value.placeholder, options: value.options, value: currentValue[key], onSelect: function (value) {
|
|
40
68
|
var _a;
|
package/dist/index.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export type { ComparisonData, DialogComparisonProps, MultiComparisonData, } from
|
|
|
119
119
|
export type { DialogDeleteConfirmProps } from './components/organisms/DialogDeleteConfirm/DialogDeleteConfirm';
|
|
120
120
|
export type { DialogQuoteRenameProps } from './components/organisms/DialogQuoteRename/DialogQuoteRename';
|
|
121
121
|
export type { SelectedQuote } from './components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple';
|
|
122
|
-
export type { QuoteHeaderProps } from './components/organisms/QuoteHeader/QuoteHeader';
|
|
122
|
+
export type { FilterType, QuoteHeaderProps, } from './components/organisms/QuoteHeader/QuoteHeader';
|
|
123
123
|
export type { TimelineProps, TimelineServices, } from './components/organisms/Timeline/Timeline';
|
|
124
124
|
export type { AccomodationDocket as AccomodationDocketType, ExcursionDocket as ExcursionDocketType, OtherServiceDocket as OtherServiceDocketType, ServiceDocket as ServiceDocketType, TransferDocket as TransferDocketType, } from './types/docket/services.types';
|
|
125
125
|
export * from './types/table';
|
package/package.json
CHANGED
|
@@ -40,7 +40,7 @@ export function ActionDropdown(props: ActionDropdownProps) {
|
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
42
|
<Popover open={open} onOpenChange={setOpen}>
|
|
43
|
-
<PopoverTrigger>
|
|
43
|
+
<PopoverTrigger asChild>
|
|
44
44
|
{children ?? (
|
|
45
45
|
<button className="action-dropdown-trigger">
|
|
46
46
|
<Icon name="more-vertical" />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
import Button from '../../atoms/Button/Button';
|
|
3
3
|
import DropdownInput from '../../atoms/Inputs/DropdownInput/DropdownInput';
|
|
4
4
|
import Input from '../../atoms/Inputs/Input/Input';
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
} from './constant';
|
|
11
11
|
import './QuoteHeader.css';
|
|
12
12
|
|
|
13
|
+
export type FilterType = 'date' | 'clientType' | 'fileStatus' | 'search';
|
|
14
|
+
|
|
13
15
|
export interface QuoteHeaderProps {
|
|
14
16
|
/** Current tab */
|
|
15
17
|
current: 'quotation' | 'booking';
|
|
@@ -20,7 +22,9 @@ export interface QuoteHeaderProps {
|
|
|
20
22
|
/** Callback to create a new quote */
|
|
21
23
|
onNewQuote: () => void;
|
|
22
24
|
|
|
23
|
-
onFilterChange?: (filter:
|
|
25
|
+
onFilterChange?: (filter: FilterType, value: string) => void;
|
|
26
|
+
|
|
27
|
+
currentFilter: Record<FilterType, string>;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
const filterConfig = {
|
|
@@ -39,8 +43,28 @@ const filterConfig = {
|
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
export function QuoteHeader(props: QuoteHeaderProps) {
|
|
42
|
-
const {
|
|
43
|
-
|
|
46
|
+
const {
|
|
47
|
+
current = 'quotation',
|
|
48
|
+
currentFilter,
|
|
49
|
+
onNavigate,
|
|
50
|
+
onNewQuote,
|
|
51
|
+
onFilterChange,
|
|
52
|
+
} = props;
|
|
53
|
+
const [currentValue, setCurrentValue] = useState<Record<FilterType, string>>(
|
|
54
|
+
currentFilter ?? {}
|
|
55
|
+
);
|
|
56
|
+
const [searchValue, setSearchValue] = useState<string>(currentFilter?.search ?? '');
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (Object.keys(currentFilter ?? {}).length > 0) {
|
|
60
|
+
const { search, ...rest } = currentFilter;
|
|
61
|
+
setCurrentValue(rest as Record<FilterType, string>);
|
|
62
|
+
setSearchValue(search);
|
|
63
|
+
} else {
|
|
64
|
+
setCurrentValue({} as Record<FilterType, string>);
|
|
65
|
+
setSearchValue('');
|
|
66
|
+
}
|
|
67
|
+
}, [currentFilter]);
|
|
44
68
|
|
|
45
69
|
return (
|
|
46
70
|
<div className="quote-header">
|
|
@@ -67,6 +91,12 @@ export function QuoteHeader(props: QuoteHeaderProps) {
|
|
|
67
91
|
icon="search"
|
|
68
92
|
iconPosition="leading"
|
|
69
93
|
className="quote-header__search"
|
|
94
|
+
value={searchValue}
|
|
95
|
+
onChange={(e) => {
|
|
96
|
+
onFilterChange?.('search', e.target.value);
|
|
97
|
+
setCurrentValue({ ...currentValue, search: e.target.value });
|
|
98
|
+
setSearchValue(e.target.value);
|
|
99
|
+
}}
|
|
70
100
|
/>
|
|
71
101
|
<Button
|
|
72
102
|
variant="primary"
|
|
@@ -83,9 +113,9 @@ export function QuoteHeader(props: QuoteHeaderProps) {
|
|
|
83
113
|
key={key}
|
|
84
114
|
placeholder={value.placeholder}
|
|
85
115
|
options={value.options}
|
|
86
|
-
value={currentValue[key]}
|
|
116
|
+
value={currentValue[key as FilterType]}
|
|
87
117
|
onSelect={(value) => {
|
|
88
|
-
onFilterChange?.(key as
|
|
118
|
+
onFilterChange?.(key as FilterType, value);
|
|
89
119
|
setCurrentValue({ ...currentValue, [key]: value });
|
|
90
120
|
}}
|
|
91
121
|
/>
|