@freightos/freightwind 1.0.0 → 1.1.0
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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/cjs/components/alert.js +33 -16
- package/dist/cjs/components/avatar.js +53 -58
- package/dist/cjs/components/badge.js +42 -18
- package/dist/cjs/components/button.js +35 -24
- package/dist/cjs/components/checkbox.js +21 -3
- package/dist/cjs/components/chip.js +67 -9
- package/dist/cjs/components/message.js +38 -0
- package/dist/cjs/components/pop-confirm.js +86 -0
- package/dist/cjs/components/radio-button-group.js +31 -35
- package/dist/cjs/components/radio-group.js +2 -1
- package/dist/cjs/components/slider.js +14 -6
- package/dist/cjs/components/switch.js +29 -10
- package/dist/cjs/components/tooltip.js +40 -11
- package/dist/cjs/index.js +38 -84
- package/dist/cjs/lib/icon-utils.js +5 -0
- package/dist/cjs/{components/aspect-ratio.js → lib/use-stable-id.js} +7 -4
- package/dist/cjs/lib/utils.js +18 -1
- package/dist/esm/components/alert.js +34 -17
- package/dist/esm/components/avatar.js +53 -22
- package/dist/esm/components/badge.js +45 -19
- package/dist/esm/components/button.js +36 -25
- package/dist/esm/components/checkbox.js +22 -4
- package/dist/esm/components/chip.js +34 -9
- package/dist/esm/components/message.js +34 -0
- package/dist/esm/components/pop-confirm.js +51 -0
- package/dist/esm/components/radio-button-group.js +31 -33
- package/dist/esm/components/radio-group.js +2 -1
- package/dist/esm/components/slider.js +14 -6
- package/dist/esm/components/switch.js +30 -11
- package/dist/esm/components/tooltip.js +40 -7
- package/dist/esm/index.js +18 -66
- package/dist/esm/lib/icon-utils.js +1 -0
- package/dist/esm/lib/use-stable-id.js +6 -0
- package/dist/esm/lib/utils.js +18 -1
- package/dist/types/components/alert.d.ts +5 -5
- package/dist/types/components/avatar.d.ts +14 -19
- package/dist/types/components/badge.d.ts +22 -8
- package/dist/types/components/button.d.ts +15 -9
- package/dist/types/components/checkbox.d.ts +8 -2
- package/dist/types/components/chip.d.ts +14 -8
- package/dist/types/components/message.d.ts +14 -0
- package/dist/types/components/pop-confirm.d.ts +28 -0
- package/dist/types/components/radio-button-group.d.ts +19 -14
- package/dist/types/components/slider.d.ts +10 -2
- package/dist/types/components/switch.d.ts +7 -6
- package/dist/types/components/tooltip.d.ts +9 -6
- package/dist/types/index.d.ts +25 -61
- package/dist/types/lib/icon-utils.d.ts +1 -0
- package/dist/types/lib/use-stable-id.d.ts +1 -0
- package/package.json +62 -54
- package/tokens.css +387 -0
- package/dist/cjs/components/accordion.js +0 -57
- package/dist/cjs/components/breadcrumb.js +0 -65
- package/dist/cjs/components/calendar.js +0 -106
- package/dist/cjs/components/card.js +0 -59
- package/dist/cjs/components/chart.js +0 -176
- package/dist/cjs/components/collapsible.js +0 -43
- package/dist/cjs/components/command.js +0 -73
- package/dist/cjs/components/context-menu.js +0 -83
- package/dist/cjs/components/country-select.js +0 -155
- package/dist/cjs/components/date-picker.js +0 -59
- package/dist/cjs/components/date-range-picker.js +0 -59
- package/dist/cjs/components/date-time-picker.js +0 -106
- package/dist/cjs/components/dialog.js +0 -70
- package/dist/cjs/components/drawer.js +0 -68
- package/dist/cjs/components/dropdown-menu.js +0 -85
- package/dist/cjs/components/empty.js +0 -42
- package/dist/cjs/components/file-preview.js +0 -73
- package/dist/cjs/components/form.js +0 -106
- package/dist/cjs/components/inline-edit.js +0 -83
- package/dist/cjs/components/input-group.js +0 -70
- package/dist/cjs/components/input-otp.js +0 -58
- package/dist/cjs/components/input.js +0 -57
- package/dist/cjs/components/label.js +0 -45
- package/dist/cjs/components/menubar.js +0 -96
- package/dist/cjs/components/navigation-menu.js +0 -68
- package/dist/cjs/components/pagination.js +0 -65
- package/dist/cjs/components/phone-input.js +0 -218
- package/dist/cjs/components/popover.js +0 -49
- package/dist/cjs/components/progress.js +0 -43
- package/dist/cjs/components/resizable.js +0 -47
- package/dist/cjs/components/rich-text-editor.js +0 -152
- package/dist/cjs/components/route.js +0 -47
- package/dist/cjs/components/scroll-area.js +0 -48
- package/dist/cjs/components/select.js +0 -71
- package/dist/cjs/components/separator.js +0 -43
- package/dist/cjs/components/sheet.js +0 -245
- package/dist/cjs/components/skeleton.js +0 -8
- package/dist/cjs/components/sonner.js +0 -25
- package/dist/cjs/components/spinner.js +0 -25
- package/dist/cjs/components/stepper.js +0 -99
- package/dist/cjs/components/steps.js +0 -127
- package/dist/cjs/components/table.js +0 -66
- package/dist/cjs/components/tabs.js +0 -51
- package/dist/cjs/components/textarea.js +0 -44
- package/dist/cjs/components/time-picker.js +0 -110
- package/dist/cjs/components/toast.js +0 -75
- package/dist/cjs/components/toaster.js +0 -12
- package/dist/cjs/components/toggle-group.js +0 -58
- package/dist/cjs/components/toggle.js +0 -62
- package/dist/cjs/hooks/use-toast.js +0 -166
- package/dist/cjs/lib/countryUtils.js +0 -93
- package/dist/esm/components/accordion.js +0 -18
- package/dist/esm/components/aspect-ratio.js +0 -3
- package/dist/esm/components/breadcrumb.js +0 -23
- package/dist/esm/components/calendar.js +0 -70
- package/dist/esm/components/card.js +0 -18
- package/dist/esm/components/chart.js +0 -135
- package/dist/esm/components/collapsible.js +0 -5
- package/dist/esm/components/command.js +0 -29
- package/dist/esm/components/context-menu.js +0 -33
- package/dist/esm/components/country-select.js +0 -118
- package/dist/esm/components/date-picker.js +0 -23
- package/dist/esm/components/date-range-picker.js +0 -23
- package/dist/esm/components/date-time-picker.js +0 -70
- package/dist/esm/components/dialog.js +0 -24
- package/dist/esm/components/drawer.js +0 -23
- package/dist/esm/components/dropdown-menu.js +0 -35
- package/dist/esm/components/empty.js +0 -6
- package/dist/esm/components/file-preview.js +0 -69
- package/dist/esm/components/form.js +0 -63
- package/dist/esm/components/inline-edit.js +0 -47
- package/dist/esm/components/input-group.js +0 -63
- package/dist/esm/components/input-otp.js +0 -19
- package/dist/esm/components/input.js +0 -21
- package/dist/esm/components/label.js +0 -9
- package/dist/esm/components/menubar.js +0 -45
- package/dist/esm/components/navigation-menu.js +0 -24
- package/dist/esm/components/pagination.js +0 -23
- package/dist/esm/components/phone-input.js +0 -181
- package/dist/esm/components/popover.js +0 -10
- package/dist/esm/components/progress.js +0 -7
- package/dist/esm/components/resizable.js +0 -9
- package/dist/esm/components/rich-text-editor.js +0 -145
- package/dist/esm/components/route.js +0 -11
- package/dist/esm/components/scroll-area.js +0 -11
- package/dist/esm/components/select.js +0 -26
- package/dist/esm/components/separator.js +0 -7
- package/dist/esm/components/sheet.js +0 -197
- package/dist/esm/components/skeleton.js +0 -6
- package/dist/esm/components/sonner.js +0 -22
- package/dist/esm/components/spinner.js +0 -21
- package/dist/esm/components/stepper.js +0 -57
- package/dist/esm/components/steps.js +0 -80
- package/dist/esm/components/table.js +0 -22
- package/dist/esm/components/tabs.js +0 -12
- package/dist/esm/components/textarea.js +0 -8
- package/dist/esm/components/time-picker.js +0 -74
- package/dist/esm/components/toast.js +0 -33
- package/dist/esm/components/toaster.js +0 -9
- package/dist/esm/components/toggle-group.js +0 -21
- package/dist/esm/components/toggle.js +0 -25
- package/dist/esm/hooks/use-toast.js +0 -128
- package/dist/esm/lib/countryUtils.js +0 -87
- package/dist/styles.css +0 -152
- package/dist/types/components/accordion.d.ts +0 -11
- package/dist/types/components/aspect-ratio.d.ts +0 -3
- package/dist/types/components/breadcrumb.d.ts +0 -19
- package/dist/types/components/calendar.d.ts +0 -7
- package/dist/types/components/card.d.ts +0 -11
- package/dist/types/components/chart.d.ts +0 -66
- package/dist/types/components/collapsible.d.ts +0 -5
- package/dist/types/components/command.d.ts +0 -80
- package/dist/types/components/context-menu.d.ts +0 -27
- package/dist/types/components/country-select.d.ts +0 -17
- package/dist/types/components/date-picker.d.ts +0 -9
- package/dist/types/components/date-range-picker.d.ts +0 -10
- package/dist/types/components/date-time-picker.d.ts +0 -10
- package/dist/types/components/dialog.d.ts +0 -23
- package/dist/types/components/drawer.d.ts +0 -22
- package/dist/types/components/dropdown-menu.d.ts +0 -27
- package/dist/types/components/empty.d.ts +0 -6
- package/dist/types/components/file-preview.d.ts +0 -9
- package/dist/types/components/form.d.ts +0 -23
- package/dist/types/components/inline-edit.d.ts +0 -10
- package/dist/types/components/input-group.d.ts +0 -16
- package/dist/types/components/input-otp.d.ts +0 -34
- package/dist/types/components/input.d.ts +0 -9
- package/dist/types/components/label.d.ts +0 -5
- package/dist/types/components/menubar.d.ts +0 -28
- package/dist/types/components/navigation-menu.d.ts +0 -12
- package/dist/types/components/pagination.d.ts +0 -29
- package/dist/types/components/phone-input.d.ts +0 -20
- package/dist/types/components/popover.d.ts +0 -9
- package/dist/types/components/progress.d.ts +0 -4
- package/dist/types/components/resizable.d.ts +0 -23
- package/dist/types/components/rich-text-editor.d.ts +0 -8
- package/dist/types/components/route.d.ts +0 -10
- package/dist/types/components/scroll-area.d.ts +0 -5
- package/dist/types/components/select.d.ts +0 -13
- package/dist/types/components/separator.d.ts +0 -4
- package/dist/types/components/sheet.d.ts +0 -49
- package/dist/types/components/skeleton.d.ts +0 -2
- package/dist/types/components/sonner.d.ts +0 -4
- package/dist/types/components/spinner.d.ts +0 -8
- package/dist/types/components/stepper.d.ts +0 -17
- package/dist/types/components/steps.d.ts +0 -64
- package/dist/types/components/table.d.ts +0 -14
- package/dist/types/components/tabs.d.ts +0 -7
- package/dist/types/components/textarea.d.ts +0 -3
- package/dist/types/components/time-picker.d.ts +0 -10
- package/dist/types/components/toast.d.ts +0 -15
- package/dist/types/components/toaster.d.ts +0 -1
- package/dist/types/components/toggle-group.d.ts +0 -12
- package/dist/types/components/toggle.d.ts +0 -12
- package/dist/types/hooks/use-toast.d.ts +0 -44
- package/dist/types/lib/countryUtils.d.ts +0 -20
- package/tailwind-preset.js +0 -70
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Freightos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @freightos/freightwind
|
|
2
|
+
|
|
3
|
+
FreightWind Design System — React UI components for Freightos applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @freightos/freightwind @freightos/icons
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Button, Alert, Badge } from '@freightos/freightwind';
|
|
15
|
+
import '@freightos/freightwind/tokens.css';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Components require Tailwind CSS v4 with the FDS design tokens loaded via `tokens.css`.
|
|
19
|
+
|
|
20
|
+
## Peer Dependencies
|
|
21
|
+
|
|
22
|
+
- `react` >= 18
|
|
23
|
+
- `react-dom` >= 18
|
|
24
|
+
- `@freightos/icons` >= 1.0.0
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT
|
|
@@ -37,40 +37,57 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
37
|
exports.Alert = void 0;
|
|
38
38
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
39
|
const icons_1 = require("@freightos/icons");
|
|
40
|
+
const react_1 = require("motion/react");
|
|
40
41
|
const React = __importStar(require("react"));
|
|
41
42
|
const utils_1 = require("../lib/utils");
|
|
42
43
|
const alertConfig = {
|
|
43
44
|
info: {
|
|
44
45
|
icon: icons_1.IconInfoCircled,
|
|
45
|
-
borderColor: 'border-l-fds-blue',
|
|
46
|
-
iconColor: 'text-fds-blue',
|
|
46
|
+
borderColor: 'border-l-fds-blue-30',
|
|
47
|
+
iconColor: 'text-fds-blue-30',
|
|
47
48
|
},
|
|
48
49
|
success: {
|
|
49
50
|
icon: icons_1.IconCheckCircled,
|
|
50
|
-
borderColor: 'border-l-fds-green',
|
|
51
|
-
iconColor: 'text-fds-green',
|
|
51
|
+
borderColor: 'border-l-fds-green-30',
|
|
52
|
+
iconColor: 'text-fds-green-30',
|
|
52
53
|
},
|
|
53
54
|
warning: {
|
|
54
|
-
icon: icons_1.
|
|
55
|
-
borderColor: 'border-l-fds-
|
|
56
|
-
iconColor: 'text-fds-
|
|
55
|
+
icon: icons_1.IconRisk,
|
|
56
|
+
borderColor: 'border-l-fds-yellow-30',
|
|
57
|
+
iconColor: 'text-fds-yellow-30',
|
|
57
58
|
},
|
|
58
59
|
error: {
|
|
59
60
|
icon: icons_1.IconNegativeCircled,
|
|
60
|
-
borderColor: 'border-l-fds-red',
|
|
61
|
-
iconColor: 'text-fds-red',
|
|
61
|
+
borderColor: 'border-l-fds-red-30',
|
|
62
|
+
iconColor: 'text-fds-red-30',
|
|
63
|
+
},
|
|
64
|
+
special: {
|
|
65
|
+
icon: icons_1.IconInfoCircled,
|
|
66
|
+
borderColor: 'border-l-fds-purple-1',
|
|
67
|
+
iconColor: 'text-fds-purple-1',
|
|
62
68
|
},
|
|
63
69
|
};
|
|
64
|
-
const Alert = ({
|
|
70
|
+
const Alert = ({ variant = 'info', title, message, closable = false, onClose, callToAction, }) => {
|
|
65
71
|
const [visible, setVisible] = React.useState(true);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const config = alertConfig[type];
|
|
72
|
+
const [closing, setClosing] = React.useState(false);
|
|
73
|
+
const config = alertConfig[variant];
|
|
69
74
|
const Icon = config.icon;
|
|
75
|
+
const showCta = callToAction && !title;
|
|
76
|
+
const showClose = closable && !showCta;
|
|
70
77
|
const handleClose = () => {
|
|
71
|
-
|
|
72
|
-
onClose?.();
|
|
78
|
+
setClosing(true);
|
|
73
79
|
};
|
|
74
|
-
|
|
80
|
+
if (!visible)
|
|
81
|
+
return null;
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
83
|
+
display: 'grid',
|
|
84
|
+
gridTemplateRows: closing ? '0fr' : '1fr',
|
|
85
|
+
transition: 'grid-template-rows 0.2s ease-in-out',
|
|
86
|
+
}, onTransitionEnd: (e) => {
|
|
87
|
+
if (e.propertyName === 'grid-template-rows' && closing) {
|
|
88
|
+
setVisible(false);
|
|
89
|
+
onClose?.();
|
|
90
|
+
}
|
|
91
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: { overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { initial: false, children: !closing && ((0, jsx_runtime_1.jsxs)(react_1.motion.div, { role: "alert", exit: { y: -20 }, transition: { duration: 0.15, ease: 'easeIn' }, className: (0, utils_1.cn)('flex w-full gap-fds-sm rounded-fds-md border-l-4 bg-card pr-fds-sm shadow-[0_0_10px_0_rgba(35,37,55,0.12)]', title ? 'items-start pl-fds-md py-fds-md' : 'items-center pl-fds-lg py-[5px]', config.borderColor), children: [(0, jsx_runtime_1.jsx)(Icon, { size: title ? 20 : 18, className: (0, utils_1.cn)('shrink-0', title && 'mt-[3px]', config.iconColor) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex-1 min-w-0", children: [title && (0, jsx_runtime_1.jsx)("div", { className: "text-fds-h5 font-fds-bold leading-fds-title text-foreground", children: title }), message && ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)('text-fds-base text-fds-gray-80 dark:text-white', title && 'mt-fds-xs'), children: message }))] }), showCta && (0, jsx_runtime_1.jsx)("div", { className: "shrink-0", children: callToAction }), showClose && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleClose, className: "shrink-0 cursor-pointer text-fds-gray-90 hover:text-fds-gray-100 transition-colors", "aria-label": "Close alert", children: (0, jsx_runtime_1.jsx)(icons_1.IconClose, { size: 16 }) }))] })) }) }) }));
|
|
75
92
|
};
|
|
76
93
|
exports.Alert = Alert;
|
|
@@ -1,75 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
'use client';
|
|
35
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
4
|
+
exports.Avatar = Avatar;
|
|
37
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
-
const
|
|
39
|
-
const AvatarPrimitive = __importStar(require("@radix-ui/react-avatar"));
|
|
6
|
+
const icons_1 = require("@freightos/icons");
|
|
40
7
|
const class_variance_authority_1 = require("class-variance-authority");
|
|
41
|
-
const
|
|
42
|
-
const
|
|
8
|
+
const icon_utils_1 = require("../lib/icon-utils");
|
|
9
|
+
const FLAGS_BASE_URL = 'https://freightwind.freightos.com/flags/1x1';
|
|
10
|
+
// --- Component ---
|
|
11
|
+
const avatarVariants = (0, class_variance_authority_1.cva)('relative flex shrink-0 items-center justify-center overflow-hidden rounded-full', {
|
|
43
12
|
variants: {
|
|
13
|
+
variant: {
|
|
14
|
+
default: 'bg-fds-purple-2 text-fds-purple-1',
|
|
15
|
+
info: 'bg-fds-blue-20 text-fds-blue-40',
|
|
16
|
+
secondary: 'bg-fds-blue-10 text-fds-blue-40',
|
|
17
|
+
warning: 'bg-fds-yellow-20 text-fds-yellow-50',
|
|
18
|
+
neutral: 'bg-fds-gray-20 text-fds-gray-80',
|
|
19
|
+
positive: 'bg-fds-green-20 text-fds-green-40',
|
|
20
|
+
filled: 'bg-white dark:bg-fds-gray-90 text-fds-gray-80',
|
|
21
|
+
ghost: 'bg-transparent text-fds-gray-80',
|
|
22
|
+
},
|
|
44
23
|
size: {
|
|
45
|
-
xs: 'h-[16px] w-[16px]',
|
|
46
|
-
sm: 'h-[24px] w-[24px]',
|
|
47
|
-
md: 'h-[32px] w-[32px]',
|
|
48
|
-
lg: 'h-[40px] w-[40px]',
|
|
49
|
-
xl: 'h-[58px] w-[58px]',
|
|
24
|
+
xs: 'h-[16px] w-[16px] text-fds-xs',
|
|
25
|
+
sm: 'h-[24px] w-[24px] text-fds-sm',
|
|
26
|
+
md: 'h-[32px] w-[32px] text-fds-base',
|
|
27
|
+
lg: 'h-[40px] w-[40px] text-fds-h6',
|
|
28
|
+
xl: 'h-[58px] w-[58px] text-fds-h4',
|
|
50
29
|
},
|
|
51
30
|
bordered: {
|
|
52
|
-
true: 'border
|
|
31
|
+
true: 'border border-fds-gray-20',
|
|
53
32
|
false: '',
|
|
54
33
|
},
|
|
55
34
|
},
|
|
56
35
|
defaultVariants: {
|
|
36
|
+
variant: 'default',
|
|
57
37
|
size: 'md',
|
|
58
38
|
bordered: false,
|
|
59
39
|
},
|
|
60
40
|
});
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
const iconSizeMap = {
|
|
42
|
+
xs: 10,
|
|
43
|
+
sm: 14,
|
|
44
|
+
md: 18,
|
|
45
|
+
lg: 22,
|
|
46
|
+
xl: 28,
|
|
47
|
+
};
|
|
48
|
+
function Avatar({ variant = 'default', size = 'md', bordered = false, icon, title, flag, src, alt, }) {
|
|
49
|
+
const classes = avatarVariants({ variant, size, bordered });
|
|
50
|
+
const iconSize = iconSizeMap[size];
|
|
51
|
+
// Content priority: src > flag > title > icon > default placeholder
|
|
52
|
+
if (src) {
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: classes, children: (0, jsx_runtime_1.jsx)("img", { src: src, alt: alt ?? '', className: "h-full w-full object-cover" }) }));
|
|
65
54
|
}
|
|
66
|
-
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
if (flag) {
|
|
56
|
+
const flagUrl = `${FLAGS_BASE_URL}/${flag.trim().toLowerCase()}.svg`;
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: classes, children: (0, jsx_runtime_1.jsx)("img", { src: flagUrl, alt: alt ?? flag.toUpperCase(), className: "h-full w-full object-cover" }) }));
|
|
58
|
+
}
|
|
59
|
+
if (title) {
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: classes, role: "img", "aria-label": alt ?? title, children: (0, jsx_runtime_1.jsx)("span", { className: "font-fds-semibold leading-none", "aria-hidden": "true", children: title.charAt(0).toUpperCase() }) }));
|
|
61
|
+
}
|
|
62
|
+
if (icon) {
|
|
63
|
+
const IconComp = icon_utils_1.iconMap[icon];
|
|
64
|
+
if (IconComp) {
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: classes, role: "img", "aria-label": alt ?? icon, children: (0, jsx_runtime_1.jsx)(IconComp, { size: iconSize }) }));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Default: user icon placeholder
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: classes, role: "img", "aria-label": alt ?? 'User avatar', children: (0, jsx_runtime_1.jsx)(icons_1.IconUser, { size: iconSize }) }));
|
|
70
|
+
}
|
|
@@ -1,24 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.badgeVariants = void 0;
|
|
4
4
|
exports.Badge = Badge;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const class_variance_authority_1 = require("class-variance-authority");
|
|
7
6
|
const utils_1 = require("../lib/utils");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
const positionClasses = {
|
|
8
|
+
'top-end': '-top-1 -end-1',
|
|
9
|
+
'bottom-end': '-bottom-1 -end-1',
|
|
10
|
+
};
|
|
11
|
+
const statusDotColors = {
|
|
12
|
+
success: 'bg-fds-green-30',
|
|
13
|
+
error: 'bg-fds-red-30',
|
|
14
|
+
default: 'bg-fds-gray-40',
|
|
15
|
+
processing: 'bg-fds-blue-30',
|
|
16
|
+
warning: 'bg-fds-yellow-30',
|
|
17
|
+
};
|
|
18
|
+
const badgeSizeClasses = {
|
|
19
|
+
default: 'min-w-[16px] h-[16px] text-fds-sm px-[3px]',
|
|
20
|
+
large: 'min-w-[20px] h-[20px] text-fds-sm px-[4px]',
|
|
21
|
+
};
|
|
22
|
+
const variantClasses = {
|
|
23
|
+
default: 'bg-fds-red-30 text-white',
|
|
24
|
+
info: 'bg-fds-blue-30 text-white',
|
|
25
|
+
neutral: 'bg-white border border-fds-gray-20 text-fds-gray-80',
|
|
26
|
+
};
|
|
27
|
+
function Badge({ value, size = 'default', variant = 'default', position = 'top-end', status, text, children }) {
|
|
28
|
+
const badgeClasses = (0, utils_1.cn)('inline-flex items-center justify-center rounded-full font-fds-semibold leading-none', badgeSizeClasses[size], variantClasses[variant]);
|
|
29
|
+
const display = typeof value === 'number'
|
|
30
|
+
? (value > 99 ? '99+' : String(value))
|
|
31
|
+
: value;
|
|
32
|
+
const showValue = typeof value === 'string' ? value.length > 0 : (value != null && value > 0);
|
|
33
|
+
// Badge wrapping a child (e.g. icon or button)
|
|
34
|
+
if (children != null && value != null) {
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "relative inline-flex", children: [children, showValue && ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)(badgeClasses, 'absolute', positionClasses[position]), children: display }))] }));
|
|
36
|
+
}
|
|
37
|
+
// Standalone badge
|
|
38
|
+
if (value != null) {
|
|
39
|
+
if (!showValue)
|
|
40
|
+
return null;
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: badgeClasses, children: display }));
|
|
42
|
+
}
|
|
43
|
+
// Status badge
|
|
44
|
+
if (status) {
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: "inline-flex items-center gap-fds-sm", children: [(0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)('h-[6px] w-[6px] rounded-full', statusDotColors[status]) }), text && (0, jsx_runtime_1.jsx)("span", { className: "text-fds-base text-fds-gray-80", children: text })] }));
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
24
48
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -37,40 +38,50 @@ exports.buttonVariants = exports.Button = void 0;
|
|
|
37
38
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
39
|
const class_variance_authority_1 = require("class-variance-authority");
|
|
39
40
|
const React = __importStar(require("react"));
|
|
41
|
+
const icon_utils_1 = require("../lib/icon-utils");
|
|
40
42
|
const utils_1 = require("../lib/utils");
|
|
41
|
-
const
|
|
43
|
+
const tooltip_1 = require("./tooltip");
|
|
44
|
+
const buttonVariants = (0, class_variance_authority_1.cva)('inline-flex w-fit items-center justify-center gap-fds-sm whitespace-nowrap rounded-fds-md cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0', {
|
|
42
45
|
variants: {
|
|
43
|
-
|
|
44
|
-
default: 'bg-fds-blue
|
|
45
|
-
secondary: 'bg-fds-white
|
|
46
|
-
tertiary: 'bg-
|
|
47
|
-
|
|
48
|
-
danger: 'bg-fds-red hover:bg-fds-red
|
|
46
|
+
variant: {
|
|
47
|
+
default: 'bg-fds-blue-30 text-fds-white hover:bg-fds-blue-40',
|
|
48
|
+
secondary: 'bg-fds-white border border-fds-blue-30 text-fds-blue-30 hover:bg-fds-blue-10',
|
|
49
|
+
tertiary: 'bg-transparent text-fds-blue-30 hover:bg-fds-blue-10',
|
|
50
|
+
link: 'bg-transparent text-fds-blue-30 hover:text-fds-blue-50',
|
|
51
|
+
danger: 'bg-fds-red-30 text-fds-white hover:bg-fds-red-40',
|
|
52
|
+
'danger-ghost': 'bg-fds-white border border-fds-red-30 text-fds-red-30 hover:bg-fds-red-10',
|
|
53
|
+
toggle: 'bg-fds-white border border-fds-gray-30 text-fds-gray-80 hover:border-fds-blue-30 hover:text-fds-blue-30',
|
|
49
54
|
},
|
|
50
55
|
size: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
padding: {
|
|
56
|
-
default: 'px-fds-lg',
|
|
57
|
-
small: 'px-fds-md',
|
|
58
|
-
large: 'px-fds-xl',
|
|
56
|
+
sm: 'h-[var(--fds-size-lg)] px-fds-md text-fds-sm [&_svg]:size-3',
|
|
57
|
+
md: 'h-[var(--fds-size-xl)] px-fds-lg text-fds-base [&_svg]:size-4',
|
|
58
|
+
lg: 'h-[var(--fds-size-xxl)] px-fds-xl text-fds-base [&_svg]:size-4',
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
defaultVariants: {
|
|
62
|
-
|
|
63
|
-
size: '
|
|
64
|
-
padding: 'default',
|
|
62
|
+
variant: 'default',
|
|
63
|
+
size: 'md',
|
|
65
64
|
},
|
|
66
65
|
});
|
|
67
66
|
exports.buttonVariants = buttonVariants;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
67
|
+
function LoadingSpinner() {
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)("svg", { className: "animate-spin", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M12 22c5.421 0 10-4.579 10-10h-2c0 4.337-3.663 8-8 8s-8-3.663-8-8c0-4.336 3.663-8 8-8V2C6.579 2 2 6.58 2 12c0 5.421 4.579 10 10 10z", fill: "currentColor" }) }));
|
|
69
|
+
}
|
|
70
|
+
const Button = React.forwardRef(({ variant = 'default', size = 'md', icon, loading = false, active, disabled, tooltip, fullWidth, children, ...props }, ref) => {
|
|
71
|
+
const iconOnly = !!icon && !children && !loading;
|
|
72
|
+
if (process.env.NODE_ENV !== 'production' && iconOnly && !tooltip) {
|
|
73
|
+
console.warn('Button: tooltip is required for icon-only buttons.');
|
|
74
|
+
}
|
|
75
|
+
const IconComp = icon ? icon_utils_1.iconMap[icon] : null;
|
|
76
|
+
// Icon sizes: with text (sm=12, md=16, lg=16), icon-only (sm=16, md=16, lg=24)
|
|
77
|
+
const iconSize = iconOnly
|
|
78
|
+
? size === 'lg' ? 24 : 16
|
|
79
|
+
: size === 'sm' ? 12 : 16;
|
|
80
|
+
const button = ((0, jsx_runtime_1.jsxs)("button", { className: (0, utils_1.cn)(buttonVariants({ variant, size }), variant === 'toggle' && active && 'border-fds-blue-30 text-fds-blue-30 bg-fds-blue-10', iconOnly && '!px-0', iconOnly && size === 'sm' && 'w-[var(--fds-size-lg)]', iconOnly && size === 'md' && 'w-[var(--fds-size-xl)]', iconOnly && size === 'lg' && 'w-[var(--fds-size-xxl)]', fullWidth && 'w-full'), ref: ref, disabled: disabled || loading, "aria-busy": loading || undefined, "aria-label": iconOnly ? tooltip : undefined, "aria-pressed": variant === 'toggle' ? active : undefined, ...props, children: [loading ? (0, jsx_runtime_1.jsx)(LoadingSpinner, {}) : IconComp && (0, jsx_runtime_1.jsx)(IconComp, { size: iconSize }), children] }));
|
|
81
|
+
if (tooltip) {
|
|
82
|
+
return (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { message: tooltip, children: button });
|
|
83
|
+
}
|
|
84
|
+
return button;
|
|
74
85
|
});
|
|
75
86
|
exports.Button = Button;
|
|
76
87
|
Button.displayName = 'Button';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -37,8 +38,25 @@ exports.Checkbox = void 0;
|
|
|
37
38
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
39
|
const CheckboxPrimitive = __importStar(require("@radix-ui/react-checkbox"));
|
|
39
40
|
const React = __importStar(require("react"));
|
|
40
|
-
const icons_1 = require("@freightos/icons");
|
|
41
41
|
const utils_1 = require("../lib/utils");
|
|
42
|
-
const
|
|
42
|
+
const use_stable_id_1 = require("../lib/use-stable-id");
|
|
43
|
+
const Checkbox = React.forwardRef(({ checked, onCheckedChange, disabled, error, children, }, ref) => {
|
|
44
|
+
const checkboxId = (0, use_stable_id_1.useStableId)();
|
|
45
|
+
const [internalChecked, setInternalChecked] = React.useState(false);
|
|
46
|
+
const resolvedChecked = checked !== undefined ? checked : internalChecked;
|
|
47
|
+
const handleCheckedChange = (val) => {
|
|
48
|
+
if (checked === undefined)
|
|
49
|
+
setInternalChecked(val);
|
|
50
|
+
onCheckedChange?.(val);
|
|
51
|
+
};
|
|
52
|
+
const box = ((0, jsx_runtime_1.jsx)(CheckboxPrimitive.Root, { ref: ref, id: checkboxId, checked: resolvedChecked, onCheckedChange: handleCheckedChange, disabled: disabled, "aria-invalid": error || undefined, className: (0, utils_1.cn)('peer size-4 shrink-0 rounded-fds-sm border cursor-pointer transition-colors', 'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring', disabled
|
|
53
|
+
? 'cursor-not-allowed bg-fds-gray-10 border-fds-gray-20'
|
|
54
|
+
: error
|
|
55
|
+
? 'border-fds-red-30 bg-fds-red-10 data-[state=checked]:bg-fds-red-30'
|
|
56
|
+
: 'border-fds-gray-30 data-[state=checked]:bg-fds-blue-30 data-[state=checked]:border-fds-blue-30'), children: (0, jsx_runtime_1.jsx)(CheckboxPrimitive.Indicator, { className: (0, utils_1.cn)('flex items-center justify-center', disabled ? 'text-fds-gray-60' : error && resolvedChecked !== true ? 'text-fds-red-30' : 'text-fds-white'), children: resolvedChecked === 'indeterminate' ? ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)('block size-2 rounded-[1px]', disabled ? 'bg-fds-gray-60' : error ? 'bg-fds-red-30' : 'bg-fds-blue-30') })) : ((0, jsx_runtime_1.jsx)("svg", { width: "11", height: "9", viewBox: "0 0 11 9", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M3.96757 5.24179L1.53586 2.81007L0 4.3378L3.96742 8.30523L10.7609 1.51176L9.21392 0L3.96757 5.24179Z", fill: "currentColor" }) })) }) }));
|
|
57
|
+
if (!children)
|
|
58
|
+
return box;
|
|
59
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-fds-sm", children: [box, (0, jsx_runtime_1.jsx)("label", { htmlFor: checkboxId, className: (0, utils_1.cn)('text-fds-base cursor-pointer select-none', disabled && 'cursor-not-allowed text-fds-gray-60', !disabled && error && 'text-fds-red-30', !disabled && !error && 'text-fds-gray-80 dark:text-fds-gray-10'), children: children })] }));
|
|
60
|
+
});
|
|
43
61
|
exports.Checkbox = Checkbox;
|
|
44
|
-
Checkbox.displayName =
|
|
62
|
+
Checkbox.displayName = 'Checkbox';
|
|
@@ -1,26 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
2
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
37
|
exports.chipVariants = void 0;
|
|
4
38
|
exports.Chip = Chip;
|
|
5
39
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
40
|
const class_variance_authority_1 = require("class-variance-authority");
|
|
41
|
+
const React = __importStar(require("react"));
|
|
7
42
|
const icons_1 = require("@freightos/icons");
|
|
43
|
+
const icon_utils_1 = require("../lib/icon-utils");
|
|
8
44
|
const utils_1 = require("../lib/utils");
|
|
9
|
-
const chipVariants = (0, class_variance_authority_1.cva)('inline-flex items-center rounded-full h-5 px-
|
|
45
|
+
const chipVariants = (0, class_variance_authority_1.cva)('inline-flex items-center rounded-full h-5 px-fds-sm text-fds-sm font-fds-regular transition-colors', {
|
|
10
46
|
variants: {
|
|
11
|
-
|
|
12
|
-
default: 'bg-fds-purple-
|
|
47
|
+
variant: {
|
|
48
|
+
default: 'bg-fds-purple-2 text-fds-purple-1',
|
|
13
49
|
neutral: 'bg-fds-gray-20 text-fds-gray-80',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
50
|
+
info: 'bg-[rgba(225,245,249,1)] text-fds-blue-40',
|
|
51
|
+
highlight: 'bg-[rgba(172,232,240,1)] text-fds-blue-40',
|
|
52
|
+
warning: 'bg-fds-yellow-20 text-fds-yellow-50',
|
|
53
|
+
success: 'bg-fds-green-20 text-fds-green-40',
|
|
54
|
+
notice: 'bg-fds-red-10 text-fds-red-30',
|
|
55
|
+
error: 'bg-fds-red-20 text-fds-red-40',
|
|
17
56
|
},
|
|
18
57
|
},
|
|
19
58
|
defaultVariants: {
|
|
20
|
-
|
|
59
|
+
variant: 'default',
|
|
21
60
|
},
|
|
22
61
|
});
|
|
23
62
|
exports.chipVariants = chipVariants;
|
|
24
|
-
|
|
25
|
-
|
|
63
|
+
const badgeColors = {
|
|
64
|
+
default: 'bg-fds-purple-1 text-fds-white',
|
|
65
|
+
neutral: 'bg-fds-gray-80 text-fds-white',
|
|
66
|
+
info: 'bg-fds-blue-40 text-fds-white',
|
|
67
|
+
highlight: 'bg-fds-blue-40 text-fds-white',
|
|
68
|
+
warning: 'bg-fds-yellow-50 text-fds-white',
|
|
69
|
+
success: 'bg-fds-green-40 text-fds-white',
|
|
70
|
+
notice: 'bg-fds-red-30 text-fds-white',
|
|
71
|
+
error: 'bg-fds-red-40 text-fds-white',
|
|
72
|
+
};
|
|
73
|
+
function Chip({ variant = 'default', icon, closable, onClose, badge, children, }) {
|
|
74
|
+
const [visible, setVisible] = React.useState(true);
|
|
75
|
+
if (!visible)
|
|
76
|
+
return null;
|
|
77
|
+
const handleClose = () => {
|
|
78
|
+
setVisible(false);
|
|
79
|
+
onClose?.();
|
|
80
|
+
};
|
|
81
|
+
const IconComp = icon ? icon_utils_1.iconMap[icon] : null;
|
|
82
|
+
const iconOnly = !!icon && !children;
|
|
83
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)(chipVariants({ variant }), iconOnly && 'justify-center', badge !== undefined && (typeof badge === 'string' ? badge.length > 0 : badge > 0) && '!pl-0.5'), children: [badge !== undefined && (typeof badge === 'string' ? badge.length > 0 : badge > 0) && ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)('mr-1 inline-flex items-center justify-center rounded-full min-w-[16px] h-4 px-1 text-[10px] font-fds-semibold leading-none', badgeColors[variant]), children: typeof badge === 'number' && badge > 99 ? '99+' : badge })), IconComp && (0, jsx_runtime_1.jsx)(IconComp, { size: 12, className: children ? 'mr-fds-sm' : '' }), children, closable && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleClose, "aria-label": "Remove", className: "ml-fds-sm inline-flex cursor-pointer items-center hover:opacity-70", children: (0, jsx_runtime_1.jsx)(icons_1.IconClose, { size: 10 }) }))] }));
|
|
26
84
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.message = exports.MessageProvider = void 0;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const icons_1 = require("@freightos/icons");
|
|
7
|
+
const sonner_1 = require("sonner");
|
|
8
|
+
const messageConfig = {
|
|
9
|
+
success: { icon: icons_1.IconCheckCircled, bg: "bg-[rgba(71,169,110,1)]" },
|
|
10
|
+
info: { icon: icons_1.IconInfoCircled, bg: "bg-[rgba(32,117,189,1)]" },
|
|
11
|
+
warning: { icon: icons_1.IconRisk, bg: "bg-[rgba(237,175,7,1)]" },
|
|
12
|
+
error: { icon: icons_1.IconNegativeCircled, bg: "bg-[rgba(216,39,30,1)]" },
|
|
13
|
+
};
|
|
14
|
+
function MessageToast({ variant, title, onClick, toastId, }) {
|
|
15
|
+
const config = messageConfig[variant];
|
|
16
|
+
const Icon = config.icon;
|
|
17
|
+
const dir = document.documentElement.getAttribute("dir") || "ltr";
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)("div", { dir: dir, className: `mx-auto flex w-fit items-center gap-fds-sm rounded-fds-md p-fds-lg shadow-fds-md text-white font-[family-name:var(--font-open-sans)] ${config.bg} ${onClick ? "cursor-pointer" : ""}`, onClick: onClick ? () => {
|
|
19
|
+
onClick();
|
|
20
|
+
sonner_1.toast.dismiss(toastId);
|
|
21
|
+
} : undefined, children: [(0, jsx_runtime_1.jsx)(Icon, { size: 16, className: "shrink-0" }), (0, jsx_runtime_1.jsx)("span", { className: "text-fds-h6 font-fds-regular leading-fds-body", children: title })] }));
|
|
22
|
+
}
|
|
23
|
+
function showMessage(variant, title, options) {
|
|
24
|
+
return sonner_1.toast.custom((id) => ((0, jsx_runtime_1.jsx)(MessageToast, { variant: variant, title: title, onClick: options?.onClick, toastId: id })), {
|
|
25
|
+
...(options?.duration !== undefined && { duration: options.duration }),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const message = {
|
|
29
|
+
success: (title, options) => showMessage("success", title, options),
|
|
30
|
+
info: (title, options) => showMessage("info", title, options),
|
|
31
|
+
warning: (title, options) => showMessage("warning", title, options),
|
|
32
|
+
error: (title, options) => showMessage("error", title, options),
|
|
33
|
+
};
|
|
34
|
+
exports.message = message;
|
|
35
|
+
const MessageProvider = ({ duration = 3000, ...props }) => {
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(sonner_1.Toaster, { position: "top-center", duration: duration, gap: 8, toastOptions: { style: { left: 0, right: 0 } }, ...props }));
|
|
37
|
+
};
|
|
38
|
+
exports.MessageProvider = MessageProvider;
|