mautourco-components 0.2.44 → 0.2.45

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.
@@ -8,6 +8,6 @@ export interface QuoteHeaderProps {
8
8
  /** Callback to create a new quote */
9
9
  onNewQuote: () => void;
10
10
  onFilterChange?: (filter: FilterType, value: string) => void;
11
- currentFilter: Record<FilterType, string>;
11
+ currentFilter?: Record<FilterType, string>;
12
12
  }
13
13
  export declare function QuoteHeader(props: QuoteHeaderProps): import("react/jsx-runtime").JSX.Element;
@@ -45,10 +45,15 @@ var filterConfig = {
45
45
  export function QuoteHeader(props) {
46
46
  var _a;
47
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];
48
+ var _c = useState(currentFilter || {
49
+ date: '',
50
+ clientType: '',
51
+ fileStatus: '',
52
+ search: '',
53
+ }), currentValue = _c[0], setCurrentValue = _c[1];
49
54
  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
55
  useEffect(function () {
51
- if (Object.keys(currentFilter !== null && currentFilter !== void 0 ? currentFilter : {}).length > 0) {
56
+ if (currentFilter && Object.keys(currentFilter).length > 0) {
52
57
  var search = currentFilter.search, rest = __rest(currentFilter, ["search"]);
53
58
  setCurrentValue(rest);
54
59
  setSearchValue(search);
@@ -11,6 +11,11 @@
11
11
  }
12
12
  }
13
13
 
14
+ .text--highlight {
15
+ background-color: var(--color-amber-100);
16
+ font-weight: 700;
17
+ }
18
+
14
19
  .table {
15
20
  width: 100%;
16
21
  border-collapse: collapse;
@@ -2,6 +2,6 @@ import { ActionDropdownType } from '@/src/types/table';
2
2
  import { BookingListItem } from '@/src/types/table/booking.types';
3
3
  import { ColumnType } from '../TableCell';
4
4
  export declare const bookingColumns: (params: {
5
- onExpand: (value?: BookingListItem) => void;
6
- onAction: (action: ActionDropdownType) => void;
5
+ onAction?: (action: ActionDropdownType) => void;
6
+ keywords?: string;
7
7
  }) => ColumnType<BookingListItem>[];
@@ -6,19 +6,39 @@ import { DateDisplay } from '../../../molecules/DateDisplay/DateDisplay';
6
6
  import { PaxChips } from '../../../molecules/PaxChips/PaxChips';
7
7
  import { actionDropdownData } from '../constant';
8
8
  export var bookingColumns = function (_a) {
9
- var onExpand = _a.onExpand, onAction = _a.onAction;
9
+ var onAction = _a.onAction, _b = _a.keywords, keywords = _b === void 0 ? '' : _b;
10
10
  return [
11
11
  {
12
12
  header: 'Quote nb.',
13
13
  key: 'booking_id',
14
14
  width: 150,
15
- cell: function (value) { return (_jsx(Text, { variant: "medium", size: "sm", children: value })); },
15
+ cell: function (value) {
16
+ if (value === void 0) { value = ''; }
17
+ var currentValue = String(value);
18
+ var regex = new RegExp("(".concat(keywords !== null && keywords !== void 0 ? keywords : '', ")"), 'gi');
19
+ if (regex.test(currentValue)) {
20
+ return (_jsx(Text, { variant: "medium", size: "sm", children: _jsx("span", { dangerouslySetInnerHTML: {
21
+ __html: currentValue.replace(regex, "<span class=\"text--highlight\">$1</span>"),
22
+ } }) }));
23
+ }
24
+ return (_jsx(Text, { variant: "medium", size: "sm", children: currentValue }));
25
+ },
16
26
  },
17
27
  {
18
28
  header: 'Client name',
19
29
  key: 'agency_name',
20
30
  width: 150,
21
- cell: function (value) { return (_jsx(Text, { variant: "medium", size: "sm", children: value })); },
31
+ cell: function (value) {
32
+ if (value === void 0) { value = ''; }
33
+ var currentValue = String(value);
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 }));
41
+ },
22
42
  },
23
43
  {
24
44
  header: 'Type',
@@ -61,7 +81,7 @@ export var bookingColumns = function (_a) {
61
81
  key: 'actions',
62
82
  width: 232,
63
83
  cell: function (_value, raw) {
64
- return (_jsx("div", { children: _jsxs("div", { className: "flex items-center gap-x-8", children: [_jsxs("div", { className: "flex items-center gap-x-3", children: [_jsx(Button, { variant: "secondary", size: "sm", className: "w-[89px]", children: "Proforma" }), _jsx(Button, { variant: "outline-secondary", size: "sm", className: "w-[89px]", children: "Voucher" })] }), _jsx(ActionDropdown, { data: actionDropdownData(onAction) })] }) }));
84
+ return (_jsx("div", { children: _jsxs("div", { className: "flex items-center gap-x-8", children: [_jsxs("div", { className: "flex items-center gap-x-3", children: [_jsx(Button, { variant: "secondary", size: "sm", className: "w-[89px]", children: "Proforma" }), _jsx(Button, { variant: "outline-secondary", size: "sm", className: "w-[89px]", children: "Voucher" })] }), _jsx(ActionDropdown, { data: actionDropdownData(onAction !== null && onAction !== void 0 ? onAction : (function () { })) })] }) }));
65
85
  },
66
86
  },
67
87
  ];
@@ -1,17 +1,18 @@
1
1
  declare const columns: {
2
2
  quotation: (params: {
3
- onExpand: (value?: import("../../../..").QuotationListItem) => void;
4
- onAction: (data: {
3
+ onExpand?: (value?: import("../../../..").QuotationListItem) => void;
4
+ onAction?: (data: {
5
5
  isChild?: boolean;
6
6
  quote: import("../../../..").QuotationListItem;
7
7
  }) => (action: import("../../../..").ActionDropdownType) => void;
8
+ keywords?: string;
8
9
  }) => import("../TableCell").ColumnType<import("../../../..").QuotationListItem>[];
9
10
  detailResume: (params?: {
10
11
  onRemove?: (value: import("../../../..").DetailResumeItem, index?: number) => void;
11
12
  }) => import("../TableCell").ColumnType<import("../../../..").DetailResumeItem>[];
12
13
  booking: (params: {
13
- onExpand: (value?: import("../../../../types/table/booking.types").BookingListItem) => void;
14
- onAction: (action: import("../../../..").ActionDropdownType) => void;
14
+ onAction?: (action: import("../../../..").ActionDropdownType) => void;
15
+ keywords?: string;
15
16
  }) => import("../TableCell").ColumnType<import("../../../../types/table/booking.types").BookingListItem>[];
16
17
  bookingCancelService: (params?: {
17
18
  onRemove?: (value: import("../../../..").DetailResumeItem, index?: number, childIndex?: number) => void;
@@ -2,9 +2,10 @@ import { ActionDropdownType } from '@/src/types/table/action-dropdown-type.types
2
2
  import { QuotationListItem } from '@/src/types/table/quotation.types';
3
3
  import { ColumnType } from '../TableCell';
4
4
  export declare const quotationColumns: (params: {
5
- onExpand: (value?: QuotationListItem) => void;
6
- onAction: (data: {
5
+ onExpand?: (value?: QuotationListItem) => void;
6
+ onAction?: (data: {
7
7
  isChild?: boolean;
8
8
  quote: QuotationListItem;
9
9
  }) => (action: ActionDropdownType) => void;
10
+ keywords?: string;
10
11
  }) => ColumnType<QuotationListItem>[];
@@ -7,20 +7,40 @@ import { DateDisplay } from '../../../molecules/DateDisplay/DateDisplay';
7
7
  import { cn } from '../../../../lib/utils';
8
8
  import { actionDropdownData, chipVariant, clientTypeMap } from '../constant';
9
9
  export var quotationColumns = function (_a) {
10
- var onExpand = _a.onExpand, onAction = _a.onAction;
10
+ var onExpand = _a.onExpand, onAction = _a.onAction, _b = _a.keywords, keywords = _b === void 0 ? '' : _b;
11
11
  return [
12
12
  {
13
13
  header: 'Quote nb.',
14
14
  key: 'file_nb',
15
15
  width: 150,
16
- cell: function (value) { return (_jsx(Text, { variant: "medium", size: "sm", children: value })); },
16
+ cell: function (value) {
17
+ if (value === void 0) { value = ''; }
18
+ var currentValue = String(value);
19
+ var regex = new RegExp("(".concat(keywords !== null && keywords !== void 0 ? keywords : '', ")"), 'gi');
20
+ if (regex.test(currentValue)) {
21
+ return (_jsx(Text, { variant: "medium", size: "sm", children: _jsx("span", { dangerouslySetInnerHTML: {
22
+ __html: currentValue.replace(regex, "<span class=\"text--highlight\">$1</span>"),
23
+ } }) }));
24
+ }
25
+ return (_jsx(Text, { variant: "medium", size: "sm", children: currentValue }));
26
+ },
17
27
  },
18
28
  {
19
29
  header: 'Client name',
20
30
  key: 'agency_name',
21
31
  width: 150,
22
32
  cell: function (value, _raw, _index, childIndex) {
23
- return childIndex === undefined && (_jsx(Text, { variant: "medium", size: "sm", children: value }));
33
+ if (value === void 0) { value = ''; }
34
+ if (childIndex === undefined) {
35
+ var currentValue = String(value);
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 }));
43
+ }
24
44
  },
25
45
  },
26
46
  {
@@ -70,12 +90,12 @@ export var quotationColumns = function (_a) {
70
90
  key: 'actions',
71
91
  width: 232,
72
92
  cell: function (_value, raw, _index, childIndex) {
73
- var _a;
93
+ var _a, _b;
74
94
  var hasChildren = raw.children && raw.children.length > 0;
75
95
  var isExpanded = (_a = raw.children) === null || _a === void 0 ? void 0 : _a.some(function (child) { return child.visible; });
76
96
  var buttonLabel = isExpanded ? 'See less' : 'See more';
77
97
  var isOnRequest = raw.status.toLowerCase() === 'on request';
78
- return (_jsx("div", { children: hasChildren ? (_jsx(Button, { variant: "outline-primary", size: "sm", trailingIcon: "chevron-down", className: cn('table__button', isExpanded && 'table__button-expanded'), onClick: function () { return onExpand(raw); }, children: buttonLabel })) : (_jsxs("div", { className: "flex items-center gap-x-8", children: [_jsx(Button, { variant: isOnRequest ? 'outline-secondary' : 'secondary', size: "sm", className: "table__button", children: isOnRequest ? 'Request to book' : 'Book now' }), _jsx(ActionDropdown, { data: actionDropdownData(onAction({ isChild: childIndex !== undefined, quote: raw })) })] })) }));
98
+ return (_jsx("div", { children: hasChildren ? (_jsx(Button, { variant: "outline-primary", size: "sm", trailingIcon: "chevron-down", className: cn('table__button', isExpanded && 'table__button-expanded'), onClick: function () { return onExpand === null || onExpand === void 0 ? void 0 : onExpand(raw); }, children: buttonLabel })) : (_jsxs("div", { className: "flex items-center gap-x-8", children: [_jsx(Button, { variant: isOnRequest ? 'outline-secondary' : 'secondary', size: "sm", className: "table__button", children: isOnRequest ? 'Request to book' : 'Book now' }), _jsx(ActionDropdown, { data: actionDropdownData((_b = onAction === null || onAction === void 0 ? void 0 : onAction({ isChild: childIndex !== undefined, quote: raw })) !== null && _b !== void 0 ? _b : (function () { })) })] })) }));
79
99
  },
80
100
  },
81
101
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mautourco-components",
3
- "version": "0.2.44",
3
+ "version": "0.2.45",
4
4
  "private": false,
5
5
  "description": "Bibliothèque de composants Motorco pour le redesign",
6
6
  "main": "dist/index.js",
@@ -24,7 +24,7 @@ export interface QuoteHeaderProps {
24
24
 
25
25
  onFilterChange?: (filter: FilterType, value: string) => void;
26
26
 
27
- currentFilter: Record<FilterType, string>;
27
+ currentFilter?: Record<FilterType, string>;
28
28
  }
29
29
 
30
30
  const filterConfig = {
@@ -51,12 +51,17 @@ export function QuoteHeader(props: QuoteHeaderProps) {
51
51
  onFilterChange,
52
52
  } = props;
53
53
  const [currentValue, setCurrentValue] = useState<Record<FilterType, string>>(
54
- currentFilter ?? {}
54
+ currentFilter || {
55
+ date: '',
56
+ clientType: '',
57
+ fileStatus: '',
58
+ search: '',
59
+ }
55
60
  );
56
61
  const [searchValue, setSearchValue] = useState<string>(currentFilter?.search ?? '');
57
62
 
58
63
  useEffect(() => {
59
- if (Object.keys(currentFilter ?? {}).length > 0) {
64
+ if (currentFilter && Object.keys(currentFilter).length > 0) {
60
65
  const { search, ...rest } = currentFilter;
61
66
  setCurrentValue(rest as Record<FilterType, string>);
62
67
  setSearchValue(search);
@@ -7,6 +7,11 @@
7
7
  }
8
8
  }
9
9
 
10
+ .text--highlight {
11
+ background-color: var(--color-amber-100);
12
+ font-weight: 700;
13
+ }
14
+
10
15
  .table {
11
16
  width: 100%;
12
17
  border-collapse: collapse;
@@ -9,28 +9,64 @@ import { ColumnType } from '../TableCell';
9
9
  import { actionDropdownData } from '../constant';
10
10
 
11
11
  export const bookingColumns: (params: {
12
- onExpand: (value?: BookingListItem) => void;
13
- onAction: (action: ActionDropdownType) => void;
14
- }) => ColumnType<BookingListItem>[] = ({ onExpand, onAction }) => [
12
+ onAction?: (action: ActionDropdownType) => void;
13
+ keywords?: string;
14
+ }) => ColumnType<BookingListItem>[] = ({ onAction, keywords = '' }) => [
15
15
  {
16
16
  header: 'Quote nb.',
17
17
  key: 'booking_id',
18
18
  width: 150,
19
- cell: (value) => (
20
- <Text variant="medium" size="sm">
21
- {value as string}
22
- </Text>
23
- ),
19
+ cell: (value = '') => {
20
+ const currentValue = String(value as string);
21
+ const regex = new RegExp(`(${keywords ?? ''})`, 'gi');
22
+ if (regex.test(currentValue)) {
23
+ return (
24
+ <Text variant="medium" size="sm">
25
+ <span
26
+ dangerouslySetInnerHTML={{
27
+ __html: currentValue.replace(
28
+ regex,
29
+ `<span class="text--highlight">$1</span>`
30
+ ),
31
+ }}
32
+ />
33
+ </Text>
34
+ );
35
+ }
36
+ return (
37
+ <Text variant="medium" size="sm">
38
+ {currentValue}
39
+ </Text>
40
+ );
41
+ },
24
42
  },
25
43
  {
26
44
  header: 'Client name',
27
45
  key: 'agency_name',
28
46
  width: 150,
29
- cell: (value) => (
30
- <Text variant="medium" size="sm">
31
- {value as string}
32
- </Text>
33
- ),
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
+ return (
65
+ <Text variant="medium" size="sm">
66
+ {currentValue}
67
+ </Text>
68
+ );
69
+ },
34
70
  },
35
71
  {
36
72
  header: 'Type',
@@ -92,7 +128,7 @@ export const bookingColumns: (params: {
92
128
  Voucher
93
129
  </Button>
94
130
  </div>
95
- <ActionDropdown data={actionDropdownData(onAction)} />
131
+ <ActionDropdown data={actionDropdownData(onAction ?? (() => {}))} />
96
132
  </div>
97
133
  </div>
98
134
  );
@@ -10,32 +10,70 @@ import { ColumnType } from '../TableCell';
10
10
  import { actionDropdownData, chipVariant, clientTypeMap } from '../constant';
11
11
 
12
12
  export const quotationColumns: (params: {
13
- onExpand: (value?: QuotationListItem) => void;
14
- onAction: (data: {
13
+ onExpand?: (value?: QuotationListItem) => void;
14
+ onAction?: (data: {
15
15
  isChild?: boolean;
16
16
  quote: QuotationListItem;
17
17
  }) => (action: ActionDropdownType) => void;
18
- }) => ColumnType<QuotationListItem>[] = ({ onExpand, onAction }) => [
18
+ keywords?: string;
19
+ }) => ColumnType<QuotationListItem>[] = ({ onExpand, onAction, keywords = '' }) => [
19
20
  {
20
21
  header: 'Quote nb.',
21
22
  key: 'file_nb',
22
23
  width: 150,
23
- cell: (value) => (
24
- <Text variant="medium" size="sm">
25
- {value as string}
26
- </Text>
27
- ),
24
+ cell: (value = '') => {
25
+ const currentValue = String(value as string);
26
+ const regex = new RegExp(`(${keywords ?? ''})`, 'gi');
27
+ if (regex.test(currentValue)) {
28
+ return (
29
+ <Text variant="medium" size="sm">
30
+ <span
31
+ dangerouslySetInnerHTML={{
32
+ __html: currentValue.replace(
33
+ regex,
34
+ `<span class="text--highlight">$1</span>`
35
+ ),
36
+ }}
37
+ />
38
+ </Text>
39
+ );
40
+ }
41
+ return (
42
+ <Text variant="medium" size="sm">
43
+ {currentValue}
44
+ </Text>
45
+ );
46
+ },
28
47
  },
29
48
  {
30
49
  header: 'Client name',
31
50
  key: 'agency_name',
32
51
  width: 150,
33
- cell: (value, _raw, _index, childIndex) =>
34
- childIndex === undefined && (
35
- <Text variant="medium" size="sm">
36
- {value as string}
37
- </Text>
38
- ),
52
+ cell: (value = '', _raw, _index, childIndex) => {
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
+ return (
71
+ <Text variant="medium" size="sm">
72
+ {currentValue}
73
+ </Text>
74
+ );
75
+ }
76
+ },
39
77
  },
40
78
  {
41
79
  header: 'File status',
@@ -138,7 +176,7 @@ export const quotationColumns: (params: {
138
176
  size="sm"
139
177
  trailingIcon="chevron-down"
140
178
  className={cn('table__button', isExpanded && 'table__button-expanded')}
141
- onClick={() => onExpand(raw)}>
179
+ onClick={() => onExpand?.(raw)}>
142
180
  {buttonLabel}
143
181
  </Button>
144
182
  ) : (
@@ -151,7 +189,8 @@ export const quotationColumns: (params: {
151
189
  </Button>
152
190
  <ActionDropdown
153
191
  data={actionDropdownData(
154
- onAction({ isChild: childIndex !== undefined, quote: raw })
192
+ onAction?.({ isChild: childIndex !== undefined, quote: raw }) ??
193
+ (() => {})
155
194
  )}
156
195
  />
157
196
  </div>