mautourco-components 0.2.32 → 0.2.33
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.d.ts +1 -0
- package/dist/components/atoms/Inputs/Input/Input.js +2 -2
- package/dist/components/atoms/SelectedValue/SelectedValue.d.ts +3 -1
- package/dist/components/atoms/SelectedValue/SelectedValue.js +3 -3
- package/dist/components/organisms/DialogSendingMail/DialogSendingMail.d.ts +2 -1
- package/dist/components/organisms/DialogSendingMail/DialogSendingMail.js +3 -1
- package/dist/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.css +2088 -0
- package/dist/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.d.ts +17 -0
- package/dist/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.js +112 -0
- package/dist/index.d.ts +1 -0
- package/dist/styles/components/selected-value.css +18 -6
- package/package.json +1 -1
- package/src/components/atoms/Inputs/Input/Input.tsx +3 -0
- package/src/components/atoms/SelectedValue/SelectedValue.tsx +15 -12
- package/src/components/organisms/DialogSendingMail/DialogSendingMail.tsx +3 -1
- package/src/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.css +7 -0
- package/src/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.tsx +140 -0
- package/src/styles/components/selected-value.css +17 -6
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DialogSendingMailContentProps } from '../DialogSendingMailContent';
|
|
3
|
+
import { SendingMailSchema } from '../sending-mail-schema';
|
|
4
|
+
import './DialogSendingMailMultiple.css';
|
|
5
|
+
export interface SelectedQuote {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DialogSendingMailMultipleProps extends Omit<DialogSendingMailContentProps, 'onSubmit'> {
|
|
10
|
+
data: SelectedQuote[];
|
|
11
|
+
onSelected?: (selectedQuotes: SelectedQuote[]) => void;
|
|
12
|
+
onSubmit: (payload: {
|
|
13
|
+
selectedQuotes: SelectedQuote[];
|
|
14
|
+
formData: SendingMailSchema;
|
|
15
|
+
}) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const DialogSendingMailMultiple: React.FC<DialogSendingMailMultipleProps>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
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
|
+
};
|
|
23
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
+
if (ar || !(i in from)) {
|
|
26
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
+
ar[i] = from[i];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
+
};
|
|
32
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
|
+
import Checkbox from '../../../atoms/Checkbox/Checkbox';
|
|
34
|
+
import SelectedValue from '../../../atoms/SelectedValue/SelectedValue';
|
|
35
|
+
import { useEffect, useState } from 'react';
|
|
36
|
+
import { DialogSendingMailContent, } from '../DialogSendingMailContent';
|
|
37
|
+
import './DialogSendingMailMultiple.css';
|
|
38
|
+
export var DialogSendingMailMultiple = function (props) {
|
|
39
|
+
var data = props.data, onSelected = props.onSelected, onSubmit = props.onSubmit, rest = __rest(props, ["data", "onSelected", "onSubmit"]);
|
|
40
|
+
var _a = useState(false), isSelectAll = _a[0], setIsSelectAll = _a[1];
|
|
41
|
+
var _b = useState(data), remainingQuotes = _b[0], setRemainingQuotes = _b[1];
|
|
42
|
+
var _c = useState([]), selectedQuotes = _c[0], setSelectedQuotes = _c[1];
|
|
43
|
+
/**
|
|
44
|
+
* Handle remove a quote
|
|
45
|
+
*
|
|
46
|
+
* @param id - The id of the quote to remove
|
|
47
|
+
* @description If the quote is already selected, deselect it
|
|
48
|
+
* If the quote is not selected, select it
|
|
49
|
+
* If there is only one quote, select it by default
|
|
50
|
+
*/
|
|
51
|
+
var handleRemove = function (id) {
|
|
52
|
+
if (remainingQuotes.length > 1) {
|
|
53
|
+
setRemainingQuotes(remainingQuotes.filter(function (quote) { return quote.id !== id; }));
|
|
54
|
+
setSelectedQuotes(selectedQuotes.filter(function (quoteId) { return quoteId !== id; }));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Handle select a quote
|
|
59
|
+
*
|
|
60
|
+
* @param id - The id of the quote to select
|
|
61
|
+
* @description If the quote is already selected, deselect it
|
|
62
|
+
* If the quote is not selected, select it
|
|
63
|
+
* If there is only one quote, select it by default
|
|
64
|
+
*/
|
|
65
|
+
var handleSelect = function (id) {
|
|
66
|
+
if (remainingQuotes.length > 1) {
|
|
67
|
+
setSelectedQuotes(function (prev) {
|
|
68
|
+
if (prev.includes(id)) {
|
|
69
|
+
return prev.filter(function (quoteId) { return quoteId !== id; });
|
|
70
|
+
}
|
|
71
|
+
return __spreadArray(__spreadArray([], prev, true), [id], false);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Handle select all quotes
|
|
77
|
+
*
|
|
78
|
+
* @description If select all is checked, select the first quote
|
|
79
|
+
* If select all is unchecked, select all quotes
|
|
80
|
+
* If there is only one quote, select it by default
|
|
81
|
+
*/
|
|
82
|
+
var handleSelectAll = function () {
|
|
83
|
+
setIsSelectAll(!isSelectAll);
|
|
84
|
+
// If select all is checked, select the first quote
|
|
85
|
+
if (isSelectAll) {
|
|
86
|
+
setSelectedQuotes([data[0].id]);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
setSelectedQuotes(remainingQuotes.map(function (quote) { return quote.id; }));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
useEffect(function () {
|
|
93
|
+
// Select all quotes by default
|
|
94
|
+
setSelectedQuotes(data.map(function (quote) { return quote.id; }));
|
|
95
|
+
}, [data]);
|
|
96
|
+
useEffect(function () {
|
|
97
|
+
// Set the select all state based on the selected quotes and remaining quotes
|
|
98
|
+
setIsSelectAll(selectedQuotes.length === remainingQuotes.length);
|
|
99
|
+
// If there is only one quote, select it by default
|
|
100
|
+
if (remainingQuotes.length === 1) {
|
|
101
|
+
setSelectedQuotes([remainingQuotes[0].id]);
|
|
102
|
+
}
|
|
103
|
+
}, [selectedQuotes, remainingQuotes]);
|
|
104
|
+
return (_jsxs("div", { children: [_jsxs("div", { className: "selected-quotes", children: [_jsx("div", { className: "selected-quotes__list", children: remainingQuotes.map(function (item) { return (_jsx(SelectedValue, { value: item.name, color: selectedQuotes.includes(item.id) ? 'accent' : 'neutral', onSelect: function () { return handleSelect(item.id); }, onRemove: function () { return handleRemove(item.id); } }, item.id)); }) }), _jsx("div", { children: _jsx(Checkbox, { label: "Select all quotations", checked: isSelectAll || remainingQuotes.length === 1, disabled: remainingQuotes.length === 1, onChange: function () { return handleSelectAll(); }, labelPosition: "leading" }) })] }), _jsx(DialogSendingMailContent, __assign({}, rest, { onSubmit: function (data) {
|
|
105
|
+
return onSubmit({
|
|
106
|
+
selectedQuotes: remainingQuotes.filter(function (quote) {
|
|
107
|
+
return selectedQuotes.includes(quote.id);
|
|
108
|
+
}),
|
|
109
|
+
formData: data,
|
|
110
|
+
});
|
|
111
|
+
} }))] }));
|
|
112
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -115,6 +115,7 @@ export type { ToastProps } from './components/molecules/Toast/Toast';
|
|
|
115
115
|
export type { TransferDocketProps } from './components/molecules/TransferDocket/TransferDocket';
|
|
116
116
|
export type { ComparisonData, DialogComparisonProps, MultiComparisonData, } from './components/organisms/DialogComparison/DialogComparison';
|
|
117
117
|
export type { DialogDeleteConfirmProps } from './components/organisms/DialogDeleteConfirm/DialogDeleteConfirm';
|
|
118
|
+
export type { SelectedQuote } from './components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple';
|
|
118
119
|
export type { QuoteHeaderProps } from './components/organisms/QuoteHeader/QuoteHeader';
|
|
119
120
|
export type { TimelineProps, TimelineServices, } from './components/organisms/Timeline/Timeline';
|
|
120
121
|
export type { AccomodationDocket as AccomodationDocketType, ExcursionDocket as ExcursionDocketType, OtherServiceDocket as OtherServiceDocketType, ServiceDocket as ServiceDocketType, TransferDocket as TransferDocketType, } from './types/docket/services.types';
|
|
@@ -2083,8 +2083,6 @@
|
|
|
2083
2083
|
padding: var(--chip-spacing-sm-padding-y, 0.375rem) var(--chip-spacing-sm-padding-x);
|
|
2084
2084
|
border-radius: var(--chip-border-radius-pill, 1.375rem);
|
|
2085
2085
|
/* Typography is now handled by the Text component */
|
|
2086
|
-
background: var(--color-atoll-green-800);
|
|
2087
|
-
color: var(--color-white);
|
|
2088
2086
|
cursor: default;
|
|
2089
2087
|
-webkit-user-select: none;
|
|
2090
2088
|
user-select: none;
|
|
@@ -2139,21 +2137,35 @@
|
|
|
2139
2137
|
/* Size variants */
|
|
2140
2138
|
|
|
2141
2139
|
.selected-value--xs {
|
|
2142
|
-
padding: var(--chip-spacing-xs-padding-y, 0.25rem)
|
|
2140
|
+
padding: var(--chip-spacing-xs-padding-y, 0.25rem)
|
|
2141
|
+
var(--chip-spacing-xs-padding-x, 0.5rem);
|
|
2143
2142
|
gap: var(--chip-spacing-xs-gap, 0.25rem);
|
|
2144
2143
|
}
|
|
2145
2144
|
|
|
2146
2145
|
.selected-value--sm {
|
|
2147
|
-
padding: var(--chip-spacing-sm-padding-y, 0.375rem)
|
|
2146
|
+
padding: var(--chip-spacing-sm-padding-y, 0.375rem)
|
|
2147
|
+
var(--chip-spacing-sm-padding-x, 0.75rem);
|
|
2148
2148
|
gap: var(--chip-spacing-sm-gap, 0.375rem);
|
|
2149
2149
|
}
|
|
2150
2150
|
|
|
2151
2151
|
.selected-value--md {
|
|
2152
|
-
padding: var(--chip-spacing-md-padding-y, 0.5rem)
|
|
2152
|
+
padding: var(--chip-spacing-md-padding-y, 0.5rem)
|
|
2153
|
+
var(--chip-spacing-md-padding-x, 0.875rem);
|
|
2153
2154
|
gap: var(--chip-spacing-md-gap, 0.5rem);
|
|
2154
2155
|
}
|
|
2155
2156
|
|
|
2156
2157
|
.selected-value--lg {
|
|
2157
|
-
padding: var(--chip-spacing-lg-padding-y, 0.625rem)
|
|
2158
|
+
padding: var(--chip-spacing-lg-padding-y, 0.625rem)
|
|
2159
|
+
var(--chip-spacing-lg-padding-x, 1rem);
|
|
2158
2160
|
gap: var(--chip-spacing-lg-gap, 0.625rem);
|
|
2159
2161
|
}
|
|
2162
|
+
|
|
2163
|
+
.selected-value--accent {
|
|
2164
|
+
background: var(--color-atoll-green-800);
|
|
2165
|
+
color: var(--color-white);
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
.selected-value--neutral {
|
|
2169
|
+
background: var(--chip-color-neutral-filled-background);
|
|
2170
|
+
color: var(--chip-color-neutral-filled-foreground);
|
|
2171
|
+
}
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ export interface InputProps {
|
|
|
13
13
|
icon?: IconName;
|
|
14
14
|
iconPosition?: 'leading' | 'trailing';
|
|
15
15
|
type?: HTMLInputTypeAttribute;
|
|
16
|
+
id?: string;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const Input: React.FC<InputProps> = ({
|
|
@@ -27,6 +28,7 @@ const Input: React.FC<InputProps> = ({
|
|
|
27
28
|
icon,
|
|
28
29
|
iconPosition = 'trailing',
|
|
29
30
|
type = 'text',
|
|
31
|
+
id,
|
|
30
32
|
}) => {
|
|
31
33
|
const baseClasses = 'input-field';
|
|
32
34
|
const variantClasses = {
|
|
@@ -48,6 +50,7 @@ const Input: React.FC<InputProps> = ({
|
|
|
48
50
|
</span>
|
|
49
51
|
)}
|
|
50
52
|
<input
|
|
53
|
+
id={id}
|
|
51
54
|
type={type}
|
|
52
55
|
className={inputClasses}
|
|
53
56
|
placeholder={placeholder}
|
|
@@ -4,20 +4,24 @@ import { Text } from '../Typography/Typography';
|
|
|
4
4
|
|
|
5
5
|
interface SelectedValueProps {
|
|
6
6
|
value: string;
|
|
7
|
-
onRemove?: () => void;
|
|
8
7
|
className?: string;
|
|
9
8
|
iconSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
10
9
|
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
11
10
|
variant?: 'filled' | 'text';
|
|
11
|
+
color?: 'accent' | 'neutral';
|
|
12
|
+
onRemove?: () => void;
|
|
13
|
+
onSelect?: () => void;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
const SelectedValue: React.FC<SelectedValueProps> = ({
|
|
15
17
|
value,
|
|
16
|
-
onRemove,
|
|
17
18
|
className = '',
|
|
18
19
|
iconSize = 'xs',
|
|
19
20
|
size = 'md',
|
|
20
21
|
variant = 'filled',
|
|
22
|
+
color = 'accent',
|
|
23
|
+
onRemove,
|
|
24
|
+
onSelect,
|
|
21
25
|
}) => {
|
|
22
26
|
const handleRemove = (event: React.MouseEvent) => {
|
|
23
27
|
event.stopPropagation();
|
|
@@ -26,20 +30,20 @@ const SelectedValue: React.FC<SelectedValueProps> = ({
|
|
|
26
30
|
}
|
|
27
31
|
};
|
|
28
32
|
|
|
29
|
-
const classes =
|
|
33
|
+
const classes =
|
|
34
|
+
`selected-value selected-value--${size} selected-value--${color} selected-value--${variant} ${className} ${onSelect ? 'cursor-pointer' : ''}`.trim();
|
|
30
35
|
|
|
31
36
|
const getTextSize = () => {
|
|
32
37
|
return size; // Utilise directement la taille passée en prop
|
|
33
38
|
};
|
|
34
39
|
|
|
35
40
|
return (
|
|
36
|
-
<div className={classes}>
|
|
37
|
-
<Text
|
|
38
|
-
size={getTextSize() as any}
|
|
39
|
-
variant="medium"
|
|
40
|
-
leading="4"
|
|
41
|
-
className="selected-value__text"
|
|
42
|
-
>
|
|
41
|
+
<div className={classes} onClick={onSelect}>
|
|
42
|
+
<Text
|
|
43
|
+
size={getTextSize() as any}
|
|
44
|
+
variant="medium"
|
|
45
|
+
leading="4"
|
|
46
|
+
className="selected-value__text">
|
|
43
47
|
{value}
|
|
44
48
|
</Text>
|
|
45
49
|
{variant !== 'text' && onRemove && (
|
|
@@ -47,8 +51,7 @@ const SelectedValue: React.FC<SelectedValueProps> = ({
|
|
|
47
51
|
type="button"
|
|
48
52
|
className="selected-value__remove"
|
|
49
53
|
onClick={handleRemove}
|
|
50
|
-
aria-label={`Remove ${value}`}
|
|
51
|
-
>
|
|
54
|
+
aria-label={`Remove ${value}`}>
|
|
52
55
|
<Icon name="close" size={iconSize} className="selected-value__remove-icon" />
|
|
53
56
|
</button>
|
|
54
57
|
)}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DialogBookingConfirm } from '../DialogBookingConfirm';
|
|
3
3
|
import { DialogSendingMailContent } from './DialogSendingMailContent';
|
|
4
|
+
import { DialogSendingMailMultiple } from './DialogSendingMailMultiple/DialogSendingMailMultiple';
|
|
4
5
|
|
|
5
6
|
export interface DialogSendingMailProps {
|
|
6
7
|
open: boolean;
|
|
@@ -24,4 +25,5 @@ export const DialogSendingMail = (props: DialogSendingMailProps) => {
|
|
|
24
25
|
);
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
DialogSendingMail.
|
|
28
|
+
DialogSendingMail.SingleQuote = DialogSendingMailContent;
|
|
29
|
+
DialogSendingMail.MultipleQuotes = DialogSendingMailMultiple;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import Checkbox from '@/src/components/atoms/Checkbox/Checkbox';
|
|
2
|
+
import SelectedValue from '@/src/components/atoms/SelectedValue/SelectedValue';
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
DialogSendingMailContent,
|
|
6
|
+
DialogSendingMailContentProps,
|
|
7
|
+
} from '../DialogSendingMailContent';
|
|
8
|
+
import { SendingMailSchema } from '../sending-mail-schema';
|
|
9
|
+
import './DialogSendingMailMultiple.css';
|
|
10
|
+
|
|
11
|
+
export interface SelectedQuote {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DialogSendingMailMultipleProps extends Omit<
|
|
17
|
+
DialogSendingMailContentProps,
|
|
18
|
+
'onSubmit'
|
|
19
|
+
> {
|
|
20
|
+
data: SelectedQuote[];
|
|
21
|
+
onSelected?: (selectedQuotes: SelectedQuote[]) => void;
|
|
22
|
+
onSubmit: (payload: {
|
|
23
|
+
selectedQuotes: SelectedQuote[];
|
|
24
|
+
formData: SendingMailSchema;
|
|
25
|
+
}) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const DialogSendingMailMultiple: React.FC<DialogSendingMailMultipleProps> = (
|
|
29
|
+
props
|
|
30
|
+
) => {
|
|
31
|
+
const { data, onSelected, onSubmit, ...rest } = props;
|
|
32
|
+
|
|
33
|
+
const [isSelectAll, setIsSelectAll] = useState(false);
|
|
34
|
+
const [remainingQuotes, setRemainingQuotes] = useState<SelectedQuote[]>(data);
|
|
35
|
+
const [selectedQuotes, setSelectedQuotes] = useState<string[]>([]);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Handle remove a quote
|
|
39
|
+
*
|
|
40
|
+
* @param id - The id of the quote to remove
|
|
41
|
+
* @description If the quote is already selected, deselect it
|
|
42
|
+
* If the quote is not selected, select it
|
|
43
|
+
* If there is only one quote, select it by default
|
|
44
|
+
*/
|
|
45
|
+
const handleRemove = (id: string) => {
|
|
46
|
+
if (remainingQuotes.length > 1) {
|
|
47
|
+
setRemainingQuotes(remainingQuotes.filter((quote) => quote.id !== id));
|
|
48
|
+
setSelectedQuotes(selectedQuotes.filter((quoteId) => quoteId !== id));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Handle select a quote
|
|
54
|
+
*
|
|
55
|
+
* @param id - The id of the quote to select
|
|
56
|
+
* @description If the quote is already selected, deselect it
|
|
57
|
+
* If the quote is not selected, select it
|
|
58
|
+
* If there is only one quote, select it by default
|
|
59
|
+
*/
|
|
60
|
+
const handleSelect = (id: string) => {
|
|
61
|
+
if (remainingQuotes.length > 1) {
|
|
62
|
+
setSelectedQuotes((prev) => {
|
|
63
|
+
if (prev.includes(id)) {
|
|
64
|
+
return prev.filter((quoteId) => quoteId !== id);
|
|
65
|
+
}
|
|
66
|
+
return [...prev, id];
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Handle select all quotes
|
|
73
|
+
*
|
|
74
|
+
* @description If select all is checked, select the first quote
|
|
75
|
+
* If select all is unchecked, select all quotes
|
|
76
|
+
* If there is only one quote, select it by default
|
|
77
|
+
*/
|
|
78
|
+
const handleSelectAll = () => {
|
|
79
|
+
setIsSelectAll(!isSelectAll);
|
|
80
|
+
// If select all is checked, select the first quote
|
|
81
|
+
if (isSelectAll) {
|
|
82
|
+
setSelectedQuotes([data[0].id]);
|
|
83
|
+
} else {
|
|
84
|
+
setSelectedQuotes(remainingQuotes.map((quote) => quote.id));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
// Select all quotes by default
|
|
90
|
+
setSelectedQuotes(data.map((quote) => quote.id));
|
|
91
|
+
}, [data]);
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
// Set the select all state based on the selected quotes and remaining quotes
|
|
95
|
+
setIsSelectAll(selectedQuotes.length === remainingQuotes.length);
|
|
96
|
+
|
|
97
|
+
// If there is only one quote, select it by default
|
|
98
|
+
if (remainingQuotes.length === 1) {
|
|
99
|
+
setSelectedQuotes([remainingQuotes[0].id]);
|
|
100
|
+
}
|
|
101
|
+
}, [selectedQuotes, remainingQuotes]);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div>
|
|
105
|
+
<div className="selected-quotes">
|
|
106
|
+
<div className="selected-quotes__list">
|
|
107
|
+
{remainingQuotes.map((item) => (
|
|
108
|
+
<SelectedValue
|
|
109
|
+
key={item.id}
|
|
110
|
+
value={item.name}
|
|
111
|
+
color={selectedQuotes.includes(item.id) ? 'accent' : 'neutral'}
|
|
112
|
+
onSelect={() => handleSelect(item.id)}
|
|
113
|
+
onRemove={() => handleRemove(item.id)}
|
|
114
|
+
/>
|
|
115
|
+
))}
|
|
116
|
+
</div>
|
|
117
|
+
<div>
|
|
118
|
+
<Checkbox
|
|
119
|
+
label="Select all quotations"
|
|
120
|
+
checked={isSelectAll || remainingQuotes.length === 1}
|
|
121
|
+
disabled={remainingQuotes.length === 1}
|
|
122
|
+
onChange={() => handleSelectAll()}
|
|
123
|
+
labelPosition="leading"
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<DialogSendingMailContent
|
|
128
|
+
{...rest}
|
|
129
|
+
onSubmit={(data) =>
|
|
130
|
+
onSubmit({
|
|
131
|
+
selectedQuotes: remainingQuotes.filter((quote) =>
|
|
132
|
+
selectedQuotes.includes(quote.id)
|
|
133
|
+
),
|
|
134
|
+
formData: data,
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
/>
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
padding: var(--chip-spacing-sm-padding-y, 0.375rem) var(--chip-spacing-sm-padding-x);
|
|
7
7
|
border-radius: var(--chip-border-radius-pill, 1.375rem);
|
|
8
8
|
/* Typography is now handled by the Text component */
|
|
9
|
-
background: var(--color-atoll-green-800);
|
|
10
|
-
color: var(--color-white);
|
|
11
9
|
cursor: default;
|
|
12
10
|
user-select: none;
|
|
13
11
|
max-width: 200px;
|
|
@@ -59,22 +57,35 @@
|
|
|
59
57
|
|
|
60
58
|
/* Size variants */
|
|
61
59
|
.selected-value--xs {
|
|
62
|
-
padding: var(--chip-spacing-xs-padding-y, 0.25rem)
|
|
60
|
+
padding: var(--chip-spacing-xs-padding-y, 0.25rem)
|
|
61
|
+
var(--chip-spacing-xs-padding-x, 0.5rem);
|
|
63
62
|
gap: var(--chip-spacing-xs-gap, 0.25rem);
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
.selected-value--sm {
|
|
67
|
-
padding: var(--chip-spacing-sm-padding-y, 0.375rem)
|
|
66
|
+
padding: var(--chip-spacing-sm-padding-y, 0.375rem)
|
|
67
|
+
var(--chip-spacing-sm-padding-x, 0.75rem);
|
|
68
68
|
gap: var(--chip-spacing-sm-gap, 0.375rem);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
.selected-value--md {
|
|
72
|
-
padding: var(--chip-spacing-md-padding-y, 0.5rem)
|
|
72
|
+
padding: var(--chip-spacing-md-padding-y, 0.5rem)
|
|
73
|
+
var(--chip-spacing-md-padding-x, 0.875rem);
|
|
73
74
|
gap: var(--chip-spacing-md-gap, 0.5rem);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
.selected-value--lg {
|
|
77
|
-
padding: var(--chip-spacing-lg-padding-y, 0.625rem)
|
|
78
|
+
padding: var(--chip-spacing-lg-padding-y, 0.625rem)
|
|
79
|
+
var(--chip-spacing-lg-padding-x, 1rem);
|
|
78
80
|
gap: var(--chip-spacing-lg-gap, 0.625rem);
|
|
79
81
|
}
|
|
80
82
|
|
|
83
|
+
.selected-value--accent {
|
|
84
|
+
background: var(--color-atoll-green-800);
|
|
85
|
+
color: var(--color-white);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.selected-value--neutral {
|
|
89
|
+
background: var(--chip-color-neutral-filled-background);
|
|
90
|
+
color: var(--chip-color-neutral-filled-foreground);
|
|
91
|
+
}
|