mautourco-components 0.2.98 → 0.2.100

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.
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from 'react';
2
3
  import Icon from '../../Icon/Icon';
3
4
  var Input = function (_a) {
4
5
  var _b = _a.variant, variant = _b === void 0 ? 'default' : _b, _c = _a.placeholder, placeholder = _c === void 0 ? 'Input text' : _c, value = _a.value, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.className, className = _e === void 0 ? '' : _e, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur, icon = _a.icon, _f = _a.iconPosition, iconPosition = _f === void 0 ? 'trailing' : _f, _g = _a.type, type = _g === void 0 ? 'text' : _g, id = _a.id;
6
+ var inputRef = useRef(null);
5
7
  var baseClasses = 'input-field';
6
8
  var variantClasses = {
7
9
  default: 'input-field--default',
@@ -11,6 +13,12 @@ var Input = function (_a) {
11
13
  disabled: 'input-field--disabled',
12
14
  };
13
15
  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', onInput: onChange, onFocus: onFocus, onBlur: onBlur }), icon && iconPosition === 'trailing' && (_jsx("span", { className: "input-icon input-icon--trailing", children: _jsx(Icon, { name: icon, size: "sm" }) }))] }));
16
+ useEffect(function () {
17
+ setTimeout(function () {
18
+ var _a;
19
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
20
+ }, 0);
21
+ }, [value]);
22
+ 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", { ref: inputRef, 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
23
  };
16
24
  export default Input;
@@ -40,5 +40,5 @@ export function DialogDeleteConfirmMultiple(props) {
40
40
  useEffect(function () {
41
41
  setIsSelectAll(selectedQuotes.length === quotes.length);
42
42
  }, [selectedQuotes, quotes]);
43
- return (_jsx(DialogDeleteConfirm.Wrapper, { onCancel: onCancel, onOk: handleDeleteQuotes, children: _jsxs("div", { className: "confirm-multiple", children: [_jsx(Checkbox, { label: "Select all quotations", checked: isSelectAll, onChange: handleSelectAllQuotes, labelPosition: "leading", className: "confirm-multiple__all" }), _jsx("ul", { className: "mb-1", children: quotes.map(function (quote) { return (_jsx("li", { children: _jsx(Checkbox, { label: quote.name, checked: selectedQuotes.includes(quote.id), onChange: function () { return handleSelectQuote(quote); }, labelPosition: "leading" }) }, quote.id)); }) }), isSelectAll && (_jsx(Toast, { text: "Caution: This would delete all quotations created.", type: "warning", showIcon: false }))] }) }));
43
+ return (_jsx(DialogDeleteConfirm.Wrapper, { onCancel: onCancel, onOk: handleDeleteQuotes, okDisabled: selectedQuotes.length === 0, children: _jsxs("div", { className: "confirm-multiple", children: [_jsx(Checkbox, { label: "Select all quotations", checked: isSelectAll, onChange: handleSelectAllQuotes, labelPosition: "leading", className: "confirm-multiple__all" }), _jsx("ul", { className: "mb-1", children: quotes.map(function (quote) { return (_jsx("li", { children: _jsx(Checkbox, { label: quote.name, checked: selectedQuotes.includes(quote.id), onChange: function () { return handleSelectQuote(quote); }, labelPosition: "leading" }) }, quote.id)); }) }), isSelectAll && (_jsx(Toast, { text: "Caution: This would delete all quotations created.", type: "warning", showIcon: false }))] }) }));
44
44
  }
@@ -6,5 +6,6 @@ export interface DialogDeleteConfirmWrapperProps {
6
6
  onOk?: () => void;
7
7
  okText?: string;
8
8
  children: React.ReactNode;
9
+ okDisabled?: boolean;
9
10
  }
10
11
  export declare function DialogDeleteConfirmWrapper(props: DialogDeleteConfirmWrapperProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Button from '../../atoms/Button/Button';
3
3
  export function DialogDeleteConfirmWrapper(props) {
4
- var onCancel = props.onCancel, _a = props.cancelText, cancelText = _a === void 0 ? 'Cancel' : _a, _b = props.okVariant, okVariant = _b === void 0 ? 'destructive' : _b, onOk = props.onOk, _c = props.okText, okText = _c === void 0 ? 'Delete' : _c, children = props.children;
5
- return (_jsxs("div", { className: "space-y-9", children: [children, _jsxs("div", { className: "grid grid-cols-2 gap-x-4", children: [_jsx(Button, { variant: "outline-secondary", onClick: onCancel, size: "sm", children: cancelText }), _jsx(Button, { variant: okVariant, onClick: onOk, size: "sm", children: okText })] })] }));
4
+ var onCancel = props.onCancel, _a = props.cancelText, cancelText = _a === void 0 ? 'Cancel' : _a, _b = props.okVariant, okVariant = _b === void 0 ? 'destructive' : _b, onOk = props.onOk, _c = props.okText, okText = _c === void 0 ? 'Delete' : _c, children = props.children, okDisabled = props.okDisabled;
5
+ return (_jsxs("div", { className: "space-y-9", children: [children, _jsxs("div", { className: "grid grid-cols-2 gap-x-4", children: [_jsx(Button, { variant: "outline-secondary", onClick: onCancel, size: "sm", children: cancelText }), _jsx(Button, { variant: okVariant, onClick: onOk, size: "sm", disabled: okDisabled, children: okText })] })] }));
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
2
+ import { useEffect, useState } from 'react';
3
3
  import Button from '../../atoms/Button/Button';
4
4
  import Input from '../../atoms/Inputs/Input/Input';
5
5
  import { Text } from '../../atoms/Typography/Typography';
@@ -10,5 +10,8 @@ export function DialogQuoteRename(props) {
10
10
  var handleQuoteNameChange = function (e) {
11
11
  setValue(e.target.value);
12
12
  };
13
- return (_jsx(DialogBookingConfirm, { open: open, setOpen: setOpen, title: "Rename Quotation", className: "!max-w-[500px]", children: _jsxs("div", { className: "space-y-9", children: [_jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "quote-name", children: _jsx(Text, { as: "span", size: "sm", children: "Quotation name" }) }), _jsx(Input, { id: "quote-name", value: value, onChange: handleQuoteNameChange })] }), _jsxs("div", { className: "grid grid-cols-2 gap-x-4 pb-2", children: [_jsx(Button, { variant: "outline-secondary", onClick: function () { return setOpen(false); }, size: "sm", children: "Cancel" }), _jsx(Button, { variant: "secondary", onClick: function () { return onSubmit(value); }, size: "sm", children: "Save changes" })] })] }) }));
13
+ useEffect(function () {
14
+ setValue(quoteName);
15
+ }, [quoteName]);
16
+ return (_jsx(DialogBookingConfirm, { open: open, setOpen: setOpen, title: "Rename Quotation", className: "!max-w-[500px]", children: _jsxs("div", { className: "space-y-9", children: [_jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "quote-name", children: _jsx(Text, { as: "span", size: "sm", children: "Quotation name" }) }), _jsx(Input, { id: "quote-name", value: value, onChange: handleQuoteNameChange, placeholder: "Enter your quote name" })] }), _jsxs("div", { className: "grid grid-cols-2 gap-x-4 pb-2", children: [_jsx(Button, { variant: "outline-secondary", onClick: function () { return setOpen(false); }, size: "sm", children: "Cancel" }), _jsx(Button, { variant: "secondary", onClick: function () { return onSubmit(value); }, size: "sm", children: "Save changes" })] })] }) }));
14
17
  }
@@ -20,5 +20,5 @@ export var DesktopNav = function (_a) {
20
20
  if (!isDisabled)
21
21
  onLinkClick === null || onLinkClick === void 0 ? void 0 : onLinkClick(it);
22
22
  }, children: it.label })) }, it.label));
23
- }) }), _jsx("div", { className: "header-nav__user-section ".concat(user ? 'header-nav__user-connected-section' : ''), children: user ? (_jsx("div", { className: "header-nav__user-container", children: _jsx(UserCard, { user: user, agencies: agencies || [], selectedAgency: selectedAgency, onSelectAgency: onAgencyChange }) })) : (_jsx(Button, { size: "sm", variant: "secondary", onClick: onLogin, children: "Login" })) })] })] }));
23
+ }) }), _jsx("div", { className: "header-nav__user-section ".concat(user ? 'header-nav__user-connected-section' : ''), children: user ? (_jsxs("div", { className: "header-nav__user-container", children: [_jsx(UserCard, { user: user, agencies: agencies || [], selectedAgency: selectedAgency, onSelectAgency: onAgencyChange }), _jsx(Button, { size: "sm", variant: "secondary", onClick: onLogout, className: "header-nav__logout-button", children: "Logout" })] })) : (_jsx(Button, { size: "sm", variant: "secondary", onClick: onLogin, children: "Login" })) })] })] }));
24
24
  };
@@ -174,6 +174,11 @@
174
174
  display: flex;
175
175
  height: 100%;
176
176
  align-items: center;
177
+ gap: 0.75rem;
178
+ }
179
+
180
+ .header-nav__logout-button {
181
+ flex-shrink: 0;
177
182
  }
178
183
 
179
184
  /* ===== Mobile Nav Classes ===== */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mautourco-components",
3
- "version": "0.2.98",
3
+ "version": "0.2.100",
4
4
  "private": false,
5
5
  "description": "Bibliothèque de composants Mautourco pour le redesign",
6
6
  "main": "dist/index.js",
@@ -1,4 +1,4 @@
1
- import React, { HTMLInputTypeAttribute } from 'react';
1
+ import React, { HTMLInputTypeAttribute, useEffect, useRef } from 'react';
2
2
  import Icon, { IconName } from '../../Icon/Icon';
3
3
 
4
4
  export interface InputProps {
@@ -30,6 +30,8 @@ const Input: React.FC<InputProps> = ({
30
30
  type = 'text',
31
31
  id,
32
32
  }) => {
33
+ const inputRef = useRef<HTMLInputElement>(null);
34
+
33
35
  const baseClasses = 'input-field';
34
36
  const variantClasses = {
35
37
  default: 'input-field--default',
@@ -42,6 +44,12 @@ const Input: React.FC<InputProps> = ({
42
44
  const inputClasses =
43
45
  `${baseClasses} ${variantClasses[variant]} ${icon ? `input-field--with-icon input-field--icon-${iconPosition}` : ''} ${className}`.trim();
44
46
 
47
+ useEffect(() => {
48
+ setTimeout(() => {
49
+ inputRef.current?.focus();
50
+ }, 0);
51
+ }, [value]);
52
+
45
53
  return (
46
54
  <div className={`input-wrapper ${icon ? 'input-wrapper--with-icon' : ''}`.trim()}>
47
55
  {icon && iconPosition === 'leading' && (
@@ -50,6 +58,7 @@ const Input: React.FC<InputProps> = ({
50
58
  </span>
51
59
  )}
52
60
  <input
61
+ ref={inputRef}
53
62
  id={id}
54
63
  type={type}
55
64
  className={inputClasses}
@@ -48,7 +48,10 @@ export function DialogDeleteConfirmMultiple(props: DialogDeleteConfirmMultiplePr
48
48
  }, [selectedQuotes, quotes]);
49
49
 
50
50
  return (
51
- <DialogDeleteConfirm.Wrapper onCancel={onCancel} onOk={handleDeleteQuotes}>
51
+ <DialogDeleteConfirm.Wrapper
52
+ onCancel={onCancel}
53
+ onOk={handleDeleteQuotes}
54
+ okDisabled={selectedQuotes.length === 0}>
52
55
  <div className="confirm-multiple">
53
56
  <Checkbox
54
57
  label="Select all quotations"
@@ -7,6 +7,7 @@ export interface DialogDeleteConfirmWrapperProps {
7
7
  onOk?: () => void;
8
8
  okText?: string;
9
9
  children: React.ReactNode;
10
+ okDisabled?: boolean;
10
11
  }
11
12
 
12
13
  export function DialogDeleteConfirmWrapper(props: DialogDeleteConfirmWrapperProps) {
@@ -17,6 +18,7 @@ export function DialogDeleteConfirmWrapper(props: DialogDeleteConfirmWrapperProp
17
18
  onOk,
18
19
  okText = 'Delete',
19
20
  children,
21
+ okDisabled,
20
22
  } = props;
21
23
  return (
22
24
  <div className="space-y-9">
@@ -25,7 +27,7 @@ export function DialogDeleteConfirmWrapper(props: DialogDeleteConfirmWrapperProp
25
27
  <Button variant="outline-secondary" onClick={onCancel} size="sm">
26
28
  {cancelText}
27
29
  </Button>
28
- <Button variant={okVariant} onClick={onOk} size="sm">
30
+ <Button variant={okVariant} onClick={onOk} size="sm" disabled={okDisabled}>
29
31
  {okText}
30
32
  </Button>
31
33
  </div>
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import Button from '../../atoms/Button/Button';
3
3
  import Input from '../../atoms/Inputs/Input/Input';
4
4
  import { Text } from '../../atoms/Typography/Typography';
@@ -19,6 +19,10 @@ export function DialogQuoteRename(props: DialogQuoteRenameProps) {
19
19
  setValue(e.target.value);
20
20
  };
21
21
 
22
+ useEffect(() => {
23
+ setValue(quoteName);
24
+ }, [quoteName]);
25
+
22
26
  return (
23
27
  <DialogBookingConfirm
24
28
  open={open}
@@ -32,7 +36,12 @@ export function DialogQuoteRename(props: DialogQuoteRenameProps) {
32
36
  Quotation name
33
37
  </Text>
34
38
  </label>
35
- <Input id="quote-name" value={value} onChange={handleQuoteNameChange} />
39
+ <Input
40
+ id="quote-name"
41
+ value={value}
42
+ onChange={handleQuoteNameChange}
43
+ placeholder="Enter your quote name"
44
+ />
36
45
  </div>
37
46
  <div className="grid grid-cols-2 gap-x-4 pb-2">
38
47
  <Button variant="outline-secondary" onClick={() => setOpen(false)} size="sm">
@@ -121,6 +121,13 @@ export const DesktopNav: React.FC<DesktopNavProps> = ({
121
121
  selectedAgency={selectedAgency}
122
122
  onSelectAgency={onAgencyChange}
123
123
  />
124
+ <Button
125
+ size="sm"
126
+ variant="secondary"
127
+ onClick={onLogout}
128
+ className="header-nav__logout-button">
129
+ Logout
130
+ </Button>
124
131
  </div>
125
132
  ) : (
126
133
  <Button size="sm" variant="secondary" onClick={onLogin}>
@@ -72,7 +72,11 @@
72
72
  }
73
73
 
74
74
  .header-nav__user-container {
75
- @apply flex items-center h-full;
75
+ @apply flex items-center h-full gap-3;
76
+ }
77
+
78
+ .header-nav__logout-button {
79
+ @apply shrink-0;
76
80
  }
77
81
 
78
82
  /* ===== Mobile Nav Classes ===== */