mautourco-components 0.2.32 → 0.2.34

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.
Files changed (26) hide show
  1. package/dist/components/atoms/Inputs/Input/Input.d.ts +1 -0
  2. package/dist/components/atoms/Inputs/Input/Input.js +2 -2
  3. package/dist/components/atoms/SelectedValue/SelectedValue.d.ts +3 -1
  4. package/dist/components/atoms/SelectedValue/SelectedValue.js +3 -3
  5. package/dist/components/molecules/Toast/Toast.d.ts +2 -0
  6. package/dist/components/molecules/Toast/Toast.js +2 -2
  7. package/dist/components/organisms/DialogQuoteRename/DialogQuoteRename.d.ts +7 -0
  8. package/dist/components/organisms/DialogQuoteRename/DialogQuoteRename.js +14 -0
  9. package/dist/components/organisms/DialogSendingMail/DialogSendingMail.d.ts +2 -1
  10. package/dist/components/organisms/DialogSendingMail/DialogSendingMail.js +3 -1
  11. package/dist/components/organisms/DialogSendingMail/DialogSendingMailContent.js +1 -1
  12. package/dist/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.css +2088 -0
  13. package/dist/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.d.ts +17 -0
  14. package/dist/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.js +115 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/styles/components/selected-value.css +18 -6
  17. package/package.json +1 -1
  18. package/src/components/atoms/Inputs/Input/Input.tsx +3 -0
  19. package/src/components/atoms/SelectedValue/SelectedValue.tsx +15 -12
  20. package/src/components/molecules/Toast/Toast.tsx +8 -3
  21. package/src/components/organisms/DialogQuoteRename/DialogQuoteRename.tsx +48 -0
  22. package/src/components/organisms/DialogSendingMail/DialogSendingMail.tsx +3 -1
  23. package/src/components/organisms/DialogSendingMail/DialogSendingMailContent.tsx +1 -0
  24. package/src/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.css +7 -0
  25. package/src/components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple.tsx +143 -0
  26. 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,115 @@
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
+ if (prev.length > 1) {
70
+ return prev.filter(function (quoteId) { return quoteId !== id; });
71
+ }
72
+ return prev;
73
+ }
74
+ return __spreadArray(__spreadArray([], prev, true), [id], false);
75
+ });
76
+ }
77
+ };
78
+ /**
79
+ * Handle select all quotes
80
+ *
81
+ * @description If select all is checked, select the first quote
82
+ * If select all is unchecked, select all quotes
83
+ * If there is only one quote, select it by default
84
+ */
85
+ var handleSelectAll = function () {
86
+ setIsSelectAll(!isSelectAll);
87
+ // If select all is checked, select the first quote
88
+ if (isSelectAll) {
89
+ setSelectedQuotes([data[0].id]);
90
+ }
91
+ else {
92
+ setSelectedQuotes(remainingQuotes.map(function (quote) { return quote.id; }));
93
+ }
94
+ };
95
+ useEffect(function () {
96
+ // Select all quotes by default
97
+ setSelectedQuotes(data.map(function (quote) { return quote.id; }));
98
+ }, [data]);
99
+ useEffect(function () {
100
+ // Set the select all state based on the selected quotes and remaining quotes
101
+ setIsSelectAll(selectedQuotes.length === remainingQuotes.length);
102
+ // If there is only one quote, select it by default
103
+ if (remainingQuotes.length === 1) {
104
+ setSelectedQuotes([remainingQuotes[0].id]);
105
+ }
106
+ }, [selectedQuotes, remainingQuotes]);
107
+ 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) {
108
+ return onSubmit({
109
+ selectedQuotes: remainingQuotes.filter(function (quote) {
110
+ return selectedQuotes.includes(quote.id);
111
+ }),
112
+ formData: data,
113
+ });
114
+ } }))] }));
115
+ };
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) var(--chip-spacing-xs-padding-x, 0.5rem);
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) var(--chip-spacing-sm-padding-x, 0.75rem);
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) var(--chip-spacing-md-padding-x, 0.875rem);
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) var(--chip-spacing-lg-padding-x, 1rem);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mautourco-components",
3
- "version": "0.2.32",
3
+ "version": "0.2.34",
4
4
  "private": false,
5
5
  "description": "Bibliothèque de composants Motorco pour le redesign",
6
6
  "main": "dist/index.js",
@@ -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 = `selected-value selected-value--${size} selected-value--${variant} ${className}`.trim();
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
  )}
@@ -15,6 +15,8 @@ export interface ToastProps {
15
15
  className?: string;
16
16
  /** Icon name */
17
17
  iconName?: IconName;
18
+ /** Show icon */
19
+ showIcon?: boolean;
18
20
  }
19
21
 
20
22
  /**
@@ -31,13 +33,16 @@ const Toast: React.FC<ToastProps> = ({
31
33
  type = 'informational',
32
34
  className = '',
33
35
  iconName = 'badge-alert',
36
+ showIcon = true,
34
37
  }) => {
35
38
  return (
36
39
  <div className={`toast toast--${type} ${className}`.trim()}>
37
40
  <div className="toast__container">
38
- <div className="toast__icon-wrapper">
39
- <Icon name={iconName} size="md" className="toast__icon" />
40
- </div>
41
+ {showIcon && (
42
+ <div className="toast__icon-wrapper">
43
+ <Icon name={iconName} size="md" className="toast__icon" />
44
+ </div>
45
+ )}
41
46
  <Text size="sm" variant="bold" leading="5" className="toast__text">
42
47
  {text}
43
48
  </Text>
@@ -0,0 +1,48 @@
1
+ import React, { useState } from 'react';
2
+ import Button from '../../atoms/Button/Button';
3
+ import Input from '../../atoms/Inputs/Input/Input';
4
+ import { Text } from '../../atoms/Typography/Typography';
5
+ import { DialogBookingConfirm } from '../DialogBookingConfirm';
6
+
7
+ export interface DialogQuoteRenameProps {
8
+ open: boolean;
9
+ setOpen: (open: boolean) => void;
10
+ quoteName: string;
11
+ onSubmit: (quoteName: string) => void;
12
+ }
13
+
14
+ export const DialogQuoteRename = (props: DialogQuoteRenameProps) => {
15
+ const { open, setOpen, quoteName, onSubmit } = props;
16
+ const [value, setValue] = useState(quoteName);
17
+
18
+ const handleQuoteNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
19
+ setValue(e.target.value);
20
+ };
21
+
22
+ return (
23
+ <DialogBookingConfirm
24
+ open={open}
25
+ setOpen={setOpen}
26
+ title="Rename Quotation"
27
+ className="!max-w-[500px]">
28
+ <div className="space-y-9">
29
+ <div className="space-y-2">
30
+ <label htmlFor="quote-name">
31
+ <Text as="span" size="sm">
32
+ Quotation name
33
+ </Text>
34
+ </label>
35
+ <Input id="quote-name" value={value} onChange={handleQuoteNameChange} />
36
+ </div>
37
+ <div className="grid grid-cols-2 gap-x-4 pb-2">
38
+ <Button variant="outline-secondary" onClick={() => setOpen(false)} size="sm">
39
+ Cancel
40
+ </Button>
41
+ <Button variant="secondary" onClick={() => onSubmit(value)} size="sm">
42
+ Save changes
43
+ </Button>
44
+ </div>
45
+ </div>
46
+ </DialogBookingConfirm>
47
+ );
48
+ };
@@ -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.Content = DialogSendingMailContent;
28
+ DialogSendingMail.SingleQuote = DialogSendingMailContent;
29
+ DialogSendingMail.MultipleQuotes = DialogSendingMailMultiple;
@@ -97,6 +97,7 @@ export const DialogSendingMailContent: React.FC<DialogSendingMailContentProps> =
97
97
  </Button>
98
98
  </div>
99
99
  <Toast
100
+ showIcon={false}
100
101
  type="warning"
101
102
  className="mt-8"
102
103
  text="Disclaimer: Email formatting may appear distorted in certain older email clients (e.g Outlook Classic ). Content will remain intact, but the visual layout may differ from the original"
@@ -0,0 +1,7 @@
1
+ .selected-quotes {
2
+ @apply flex justify-between items-center mb-8;
3
+ }
4
+
5
+ .selected-quotes__list {
6
+ @apply flex gap-x-2;
7
+ }
@@ -0,0 +1,143 @@
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
+ if (prev.length > 1) {
65
+ return prev.filter((quoteId) => quoteId !== id);
66
+ }
67
+ return prev;
68
+ }
69
+ return [...prev, id];
70
+ });
71
+ }
72
+ };
73
+
74
+ /**
75
+ * Handle select all quotes
76
+ *
77
+ * @description If select all is checked, select the first quote
78
+ * If select all is unchecked, select all quotes
79
+ * If there is only one quote, select it by default
80
+ */
81
+ const handleSelectAll = () => {
82
+ setIsSelectAll(!isSelectAll);
83
+ // If select all is checked, select the first quote
84
+ if (isSelectAll) {
85
+ setSelectedQuotes([data[0].id]);
86
+ } else {
87
+ setSelectedQuotes(remainingQuotes.map((quote) => quote.id));
88
+ }
89
+ };
90
+
91
+ useEffect(() => {
92
+ // Select all quotes by default
93
+ setSelectedQuotes(data.map((quote) => quote.id));
94
+ }, [data]);
95
+
96
+ useEffect(() => {
97
+ // Set the select all state based on the selected quotes and remaining quotes
98
+ setIsSelectAll(selectedQuotes.length === remainingQuotes.length);
99
+
100
+ // If there is only one quote, select it by default
101
+ if (remainingQuotes.length === 1) {
102
+ setSelectedQuotes([remainingQuotes[0].id]);
103
+ }
104
+ }, [selectedQuotes, remainingQuotes]);
105
+
106
+ return (
107
+ <div>
108
+ <div className="selected-quotes">
109
+ <div className="selected-quotes__list">
110
+ {remainingQuotes.map((item) => (
111
+ <SelectedValue
112
+ key={item.id}
113
+ value={item.name}
114
+ color={selectedQuotes.includes(item.id) ? 'accent' : 'neutral'}
115
+ onSelect={() => handleSelect(item.id)}
116
+ onRemove={() => handleRemove(item.id)}
117
+ />
118
+ ))}
119
+ </div>
120
+ <div>
121
+ <Checkbox
122
+ label="Select all quotations"
123
+ checked={isSelectAll || remainingQuotes.length === 1}
124
+ disabled={remainingQuotes.length === 1}
125
+ onChange={() => handleSelectAll()}
126
+ labelPosition="leading"
127
+ />
128
+ </div>
129
+ </div>
130
+ <DialogSendingMailContent
131
+ {...rest}
132
+ onSubmit={(data) =>
133
+ onSubmit({
134
+ selectedQuotes: remainingQuotes.filter((quote) =>
135
+ selectedQuotes.includes(quote.id)
136
+ ),
137
+ formData: data,
138
+ })
139
+ }
140
+ />
141
+ </div>
142
+ );
143
+ };
@@ -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) var(--chip-spacing-xs-padding-x, 0.5rem);
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) var(--chip-spacing-sm-padding-x, 0.75rem);
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) var(--chip-spacing-md-padding-x, 0.875rem);
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) var(--chip-spacing-lg-padding-x, 1rem);
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
+ }