@freightos/freightwind 1.0.0 → 1.1.1

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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/dist/cjs/components/alert.js +33 -16
  4. package/dist/cjs/components/avatar.js +53 -58
  5. package/dist/cjs/components/badge.js +42 -18
  6. package/dist/cjs/components/button.js +35 -24
  7. package/dist/cjs/components/checkbox.js +21 -3
  8. package/dist/cjs/components/chip.js +67 -9
  9. package/dist/cjs/components/message.js +38 -0
  10. package/dist/cjs/components/pop-confirm.js +86 -0
  11. package/dist/cjs/components/radio-button-group.js +31 -35
  12. package/dist/cjs/components/radio-group.js +2 -1
  13. package/dist/cjs/components/slider.js +14 -6
  14. package/dist/cjs/components/switch.js +29 -10
  15. package/dist/cjs/components/tooltip.js +40 -11
  16. package/dist/cjs/index.js +38 -84
  17. package/dist/cjs/lib/icon-utils.js +5 -0
  18. package/dist/cjs/{components/aspect-ratio.js → lib/use-stable-id.js} +7 -4
  19. package/dist/cjs/lib/utils.js +18 -1
  20. package/dist/esm/components/alert.js +34 -17
  21. package/dist/esm/components/avatar.js +53 -22
  22. package/dist/esm/components/badge.js +45 -19
  23. package/dist/esm/components/button.js +36 -25
  24. package/dist/esm/components/checkbox.js +22 -4
  25. package/dist/esm/components/chip.js +34 -9
  26. package/dist/esm/components/message.js +34 -0
  27. package/dist/esm/components/pop-confirm.js +51 -0
  28. package/dist/esm/components/radio-button-group.js +31 -33
  29. package/dist/esm/components/radio-group.js +2 -1
  30. package/dist/esm/components/slider.js +14 -6
  31. package/dist/esm/components/switch.js +30 -11
  32. package/dist/esm/components/tooltip.js +40 -7
  33. package/dist/esm/index.js +18 -66
  34. package/dist/esm/lib/icon-utils.js +1 -0
  35. package/dist/esm/lib/use-stable-id.js +6 -0
  36. package/dist/esm/lib/utils.js +18 -1
  37. package/dist/types/components/alert.d.ts +5 -5
  38. package/dist/types/components/avatar.d.ts +14 -19
  39. package/dist/types/components/badge.d.ts +22 -8
  40. package/dist/types/components/button.d.ts +15 -9
  41. package/dist/types/components/checkbox.d.ts +8 -2
  42. package/dist/types/components/chip.d.ts +14 -8
  43. package/dist/types/components/message.d.ts +14 -0
  44. package/dist/types/components/pop-confirm.d.ts +28 -0
  45. package/dist/types/components/radio-button-group.d.ts +19 -14
  46. package/dist/types/components/slider.d.ts +10 -2
  47. package/dist/types/components/switch.d.ts +7 -6
  48. package/dist/types/components/tooltip.d.ts +9 -6
  49. package/dist/types/index.d.ts +25 -61
  50. package/dist/types/lib/icon-utils.d.ts +1 -0
  51. package/dist/types/lib/use-stable-id.d.ts +1 -0
  52. package/guidelines/Guidelines.md +54 -0
  53. package/guidelines/design-tokens/colors.md +81 -0
  54. package/guidelines/design-tokens/spacing.md +45 -0
  55. package/guidelines/design-tokens/typography.md +50 -0
  56. package/guidelines/overview-components.md +252 -0
  57. package/guidelines/overview-icons.md +52 -0
  58. package/package.json +63 -54
  59. package/tokens.css +409 -0
  60. package/dist/cjs/components/accordion.js +0 -57
  61. package/dist/cjs/components/breadcrumb.js +0 -65
  62. package/dist/cjs/components/calendar.js +0 -106
  63. package/dist/cjs/components/card.js +0 -59
  64. package/dist/cjs/components/chart.js +0 -176
  65. package/dist/cjs/components/collapsible.js +0 -43
  66. package/dist/cjs/components/command.js +0 -73
  67. package/dist/cjs/components/context-menu.js +0 -83
  68. package/dist/cjs/components/country-select.js +0 -155
  69. package/dist/cjs/components/date-picker.js +0 -59
  70. package/dist/cjs/components/date-range-picker.js +0 -59
  71. package/dist/cjs/components/date-time-picker.js +0 -106
  72. package/dist/cjs/components/dialog.js +0 -70
  73. package/dist/cjs/components/drawer.js +0 -68
  74. package/dist/cjs/components/dropdown-menu.js +0 -85
  75. package/dist/cjs/components/empty.js +0 -42
  76. package/dist/cjs/components/file-preview.js +0 -73
  77. package/dist/cjs/components/form.js +0 -106
  78. package/dist/cjs/components/inline-edit.js +0 -83
  79. package/dist/cjs/components/input-group.js +0 -70
  80. package/dist/cjs/components/input-otp.js +0 -58
  81. package/dist/cjs/components/input.js +0 -57
  82. package/dist/cjs/components/label.js +0 -45
  83. package/dist/cjs/components/menubar.js +0 -96
  84. package/dist/cjs/components/navigation-menu.js +0 -68
  85. package/dist/cjs/components/pagination.js +0 -65
  86. package/dist/cjs/components/phone-input.js +0 -218
  87. package/dist/cjs/components/popover.js +0 -49
  88. package/dist/cjs/components/progress.js +0 -43
  89. package/dist/cjs/components/resizable.js +0 -47
  90. package/dist/cjs/components/rich-text-editor.js +0 -152
  91. package/dist/cjs/components/route.js +0 -47
  92. package/dist/cjs/components/scroll-area.js +0 -48
  93. package/dist/cjs/components/select.js +0 -71
  94. package/dist/cjs/components/separator.js +0 -43
  95. package/dist/cjs/components/sheet.js +0 -245
  96. package/dist/cjs/components/skeleton.js +0 -8
  97. package/dist/cjs/components/sonner.js +0 -25
  98. package/dist/cjs/components/spinner.js +0 -25
  99. package/dist/cjs/components/stepper.js +0 -99
  100. package/dist/cjs/components/steps.js +0 -127
  101. package/dist/cjs/components/table.js +0 -66
  102. package/dist/cjs/components/tabs.js +0 -51
  103. package/dist/cjs/components/textarea.js +0 -44
  104. package/dist/cjs/components/time-picker.js +0 -110
  105. package/dist/cjs/components/toast.js +0 -75
  106. package/dist/cjs/components/toaster.js +0 -12
  107. package/dist/cjs/components/toggle-group.js +0 -58
  108. package/dist/cjs/components/toggle.js +0 -62
  109. package/dist/cjs/hooks/use-toast.js +0 -166
  110. package/dist/cjs/lib/countryUtils.js +0 -93
  111. package/dist/esm/components/accordion.js +0 -18
  112. package/dist/esm/components/aspect-ratio.js +0 -3
  113. package/dist/esm/components/breadcrumb.js +0 -23
  114. package/dist/esm/components/calendar.js +0 -70
  115. package/dist/esm/components/card.js +0 -18
  116. package/dist/esm/components/chart.js +0 -135
  117. package/dist/esm/components/collapsible.js +0 -5
  118. package/dist/esm/components/command.js +0 -29
  119. package/dist/esm/components/context-menu.js +0 -33
  120. package/dist/esm/components/country-select.js +0 -118
  121. package/dist/esm/components/date-picker.js +0 -23
  122. package/dist/esm/components/date-range-picker.js +0 -23
  123. package/dist/esm/components/date-time-picker.js +0 -70
  124. package/dist/esm/components/dialog.js +0 -24
  125. package/dist/esm/components/drawer.js +0 -23
  126. package/dist/esm/components/dropdown-menu.js +0 -35
  127. package/dist/esm/components/empty.js +0 -6
  128. package/dist/esm/components/file-preview.js +0 -69
  129. package/dist/esm/components/form.js +0 -63
  130. package/dist/esm/components/inline-edit.js +0 -47
  131. package/dist/esm/components/input-group.js +0 -63
  132. package/dist/esm/components/input-otp.js +0 -19
  133. package/dist/esm/components/input.js +0 -21
  134. package/dist/esm/components/label.js +0 -9
  135. package/dist/esm/components/menubar.js +0 -45
  136. package/dist/esm/components/navigation-menu.js +0 -24
  137. package/dist/esm/components/pagination.js +0 -23
  138. package/dist/esm/components/phone-input.js +0 -181
  139. package/dist/esm/components/popover.js +0 -10
  140. package/dist/esm/components/progress.js +0 -7
  141. package/dist/esm/components/resizable.js +0 -9
  142. package/dist/esm/components/rich-text-editor.js +0 -145
  143. package/dist/esm/components/route.js +0 -11
  144. package/dist/esm/components/scroll-area.js +0 -11
  145. package/dist/esm/components/select.js +0 -26
  146. package/dist/esm/components/separator.js +0 -7
  147. package/dist/esm/components/sheet.js +0 -197
  148. package/dist/esm/components/skeleton.js +0 -6
  149. package/dist/esm/components/sonner.js +0 -22
  150. package/dist/esm/components/spinner.js +0 -21
  151. package/dist/esm/components/stepper.js +0 -57
  152. package/dist/esm/components/steps.js +0 -80
  153. package/dist/esm/components/table.js +0 -22
  154. package/dist/esm/components/tabs.js +0 -12
  155. package/dist/esm/components/textarea.js +0 -8
  156. package/dist/esm/components/time-picker.js +0 -74
  157. package/dist/esm/components/toast.js +0 -33
  158. package/dist/esm/components/toaster.js +0 -9
  159. package/dist/esm/components/toggle-group.js +0 -21
  160. package/dist/esm/components/toggle.js +0 -25
  161. package/dist/esm/hooks/use-toast.js +0 -128
  162. package/dist/esm/lib/countryUtils.js +0 -87
  163. package/dist/styles.css +0 -152
  164. package/dist/types/components/accordion.d.ts +0 -11
  165. package/dist/types/components/aspect-ratio.d.ts +0 -3
  166. package/dist/types/components/breadcrumb.d.ts +0 -19
  167. package/dist/types/components/calendar.d.ts +0 -7
  168. package/dist/types/components/card.d.ts +0 -11
  169. package/dist/types/components/chart.d.ts +0 -66
  170. package/dist/types/components/collapsible.d.ts +0 -5
  171. package/dist/types/components/command.d.ts +0 -80
  172. package/dist/types/components/context-menu.d.ts +0 -27
  173. package/dist/types/components/country-select.d.ts +0 -17
  174. package/dist/types/components/date-picker.d.ts +0 -9
  175. package/dist/types/components/date-range-picker.d.ts +0 -10
  176. package/dist/types/components/date-time-picker.d.ts +0 -10
  177. package/dist/types/components/dialog.d.ts +0 -23
  178. package/dist/types/components/drawer.d.ts +0 -22
  179. package/dist/types/components/dropdown-menu.d.ts +0 -27
  180. package/dist/types/components/empty.d.ts +0 -6
  181. package/dist/types/components/file-preview.d.ts +0 -9
  182. package/dist/types/components/form.d.ts +0 -23
  183. package/dist/types/components/inline-edit.d.ts +0 -10
  184. package/dist/types/components/input-group.d.ts +0 -16
  185. package/dist/types/components/input-otp.d.ts +0 -34
  186. package/dist/types/components/input.d.ts +0 -9
  187. package/dist/types/components/label.d.ts +0 -5
  188. package/dist/types/components/menubar.d.ts +0 -28
  189. package/dist/types/components/navigation-menu.d.ts +0 -12
  190. package/dist/types/components/pagination.d.ts +0 -29
  191. package/dist/types/components/phone-input.d.ts +0 -20
  192. package/dist/types/components/popover.d.ts +0 -9
  193. package/dist/types/components/progress.d.ts +0 -4
  194. package/dist/types/components/resizable.d.ts +0 -23
  195. package/dist/types/components/rich-text-editor.d.ts +0 -8
  196. package/dist/types/components/route.d.ts +0 -10
  197. package/dist/types/components/scroll-area.d.ts +0 -5
  198. package/dist/types/components/select.d.ts +0 -13
  199. package/dist/types/components/separator.d.ts +0 -4
  200. package/dist/types/components/sheet.d.ts +0 -49
  201. package/dist/types/components/skeleton.d.ts +0 -2
  202. package/dist/types/components/sonner.d.ts +0 -4
  203. package/dist/types/components/spinner.d.ts +0 -8
  204. package/dist/types/components/stepper.d.ts +0 -17
  205. package/dist/types/components/steps.d.ts +0 -64
  206. package/dist/types/components/table.d.ts +0 -14
  207. package/dist/types/components/tabs.d.ts +0 -7
  208. package/dist/types/components/textarea.d.ts +0 -3
  209. package/dist/types/components/time-picker.d.ts +0 -10
  210. package/dist/types/components/toast.d.ts +0 -15
  211. package/dist/types/components/toaster.d.ts +0 -1
  212. package/dist/types/components/toggle-group.d.ts +0 -12
  213. package/dist/types/components/toggle.d.ts +0 -12
  214. package/dist/types/hooks/use-toast.d.ts +0 -44
  215. package/dist/types/lib/countryUtils.d.ts +0 -20
  216. package/tailwind-preset.js +0 -70
@@ -1,118 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { cn } from '../lib/utils';
4
- import { getCountryFlag } from '../lib/countryUtils';
5
- import { IconCaretDown, IconCheck } from '@freightos/icons';
6
- import * as React from 'react';
7
- // Common countries list - can be extended or replaced via props
8
- export const COUNTRIES = [
9
- { code: 'US', name: 'United States' },
10
- { code: 'CN', name: 'China' },
11
- { code: 'GB', name: 'United Kingdom' },
12
- { code: 'CA', name: 'Canada' },
13
- { code: 'DE', name: 'Germany' },
14
- { code: 'FR', name: 'France' },
15
- { code: 'IT', name: 'Italy' },
16
- { code: 'ES', name: 'Spain' },
17
- { code: 'NL', name: 'Netherlands' },
18
- { code: 'BE', name: 'Belgium' },
19
- { code: 'CH', name: 'Switzerland' },
20
- { code: 'AT', name: 'Austria' },
21
- { code: 'SE', name: 'Sweden' },
22
- { code: 'NO', name: 'Norway' },
23
- { code: 'DK', name: 'Denmark' },
24
- { code: 'FI', name: 'Finland' },
25
- { code: 'PL', name: 'Poland' },
26
- { code: 'CZ', name: 'Czech Republic' },
27
- { code: 'IE', name: 'Ireland' },
28
- { code: 'PT', name: 'Portugal' },
29
- { code: 'GR', name: 'Greece' },
30
- { code: 'JP', name: 'Japan' },
31
- { code: 'KR', name: 'South Korea' },
32
- { code: 'IN', name: 'India' },
33
- { code: 'AU', name: 'Australia' },
34
- { code: 'NZ', name: 'New Zealand' },
35
- { code: 'SG', name: 'Singapore' },
36
- { code: 'HK', name: 'Hong Kong' },
37
- { code: 'TW', name: 'Taiwan' },
38
- { code: 'TH', name: 'Thailand' },
39
- { code: 'MY', name: 'Malaysia' },
40
- { code: 'ID', name: 'Indonesia' },
41
- { code: 'PH', name: 'Philippines' },
42
- { code: 'VN', name: 'Vietnam' },
43
- { code: 'BR', name: 'Brazil' },
44
- { code: 'MX', name: 'Mexico' },
45
- { code: 'AR', name: 'Argentina' },
46
- { code: 'CL', name: 'Chile' },
47
- { code: 'CO', name: 'Colombia' },
48
- { code: 'PE', name: 'Peru' },
49
- { code: 'ZA', name: 'South Africa' },
50
- { code: 'EG', name: 'Egypt' },
51
- { code: 'IL', name: 'Israel' },
52
- { code: 'AE', name: 'United Arab Emirates' },
53
- { code: 'SA', name: 'Saudi Arabia' },
54
- { code: 'TR', name: 'Turkey' },
55
- { code: 'RU', name: 'Russia' },
56
- { code: 'UA', name: 'Ukraine' },
57
- ];
58
- export const CountrySelect = ({ value, onChange, placeholder = 'Select country', mostUsedCountries = ['US', 'CN'], countries = COUNTRIES, className, disabled = false, }) => {
59
- const [open, setOpen] = React.useState(false);
60
- const [search, setSearch] = React.useState('');
61
- const containerRef = React.useRef(null);
62
- const inputRef = React.useRef(null);
63
- // Get selected country
64
- const selectedCountry = countries.find((c) => c.code === value);
65
- // Filter countries based on search
66
- const filteredCountries = React.useMemo(() => {
67
- const searchLower = search.toLowerCase();
68
- const filtered = countries.filter((country) => country.name.toLowerCase().includes(searchLower) ||
69
- country.code.toLowerCase().includes(searchLower));
70
- // Sort: most used first, then alphabetically
71
- return filtered.sort((a, b) => {
72
- const aIsMostUsed = mostUsedCountries.includes(a.code);
73
- const bIsMostUsed = mostUsedCountries.includes(b.code);
74
- if (aIsMostUsed && !bIsMostUsed)
75
- return -1;
76
- if (!aIsMostUsed && bIsMostUsed)
77
- return 1;
78
- return a.name.localeCompare(b.name);
79
- });
80
- }, [countries, search, mostUsedCountries]);
81
- // Close on click outside
82
- React.useEffect(() => {
83
- const handleClickOutside = (e) => {
84
- if (containerRef.current &&
85
- !containerRef.current.contains(e.target)) {
86
- setOpen(false);
87
- setSearch('');
88
- }
89
- };
90
- if (open) {
91
- document.addEventListener('mousedown', handleClickOutside);
92
- }
93
- return () => document.removeEventListener('mousedown', handleClickOutside);
94
- }, [open]);
95
- const handleSelect = (country) => {
96
- onChange?.(country.code);
97
- setOpen(false);
98
- setSearch('');
99
- };
100
- const handleTriggerClick = () => {
101
- if (!disabled) {
102
- setOpen(!open);
103
- if (!open) {
104
- setTimeout(() => inputRef.current?.focus(), 0);
105
- }
106
- }
107
- };
108
- return (_jsxs("div", { ref: containerRef, className: cn('relative', className), children: [_jsxs("button", { type: "button", onClick: handleTriggerClick, disabled: disabled, className: cn('flex h-[32px] w-full items-center gap-fds-sm rounded-fds-md border border-input-border bg-input px-fds-sm text-fds-base outline-none transition-[color,box-shadow]', open &&
109
- 'border-[#2075bd] shadow-[0_0_0_2px_var(--fds-color-primary-blue-20)]', disabled && 'cursor-not-allowed opacity-50'), children: [selectedCountry ? (_jsxs(_Fragment, { children: [_jsx("img", { src: getCountryFlag(selectedCountry.code), alt: selectedCountry.code, className: "h-4 w-4 shrink-0 rounded-full object-cover" }), _jsx("span", { className: "flex-1 truncate text-left", children: selectedCountry.name })] })) : (_jsx("span", { className: "flex-1 text-left text-muted-foreground", children: placeholder })), _jsx(IconCaretDown, { size: 16, className: cn('shrink-0 text-fds-gray-60 transition-transform', open && 'rotate-180') })] }), open && (_jsxs("div", { className: "absolute top-full z-50 mt-fds-xs w-full rounded-fds-md border border-border bg-popover shadow-lg", children: [_jsx("div", { className: "border-b border-border p-fds-xs", children: _jsx("input", { ref: inputRef, type: "text", value: search, onChange: (e) => setSearch(e.target.value), placeholder: "Search country...", className: "h-[28px] w-full rounded-fds-sm border border-input-border bg-input px-fds-sm text-fds-sm outline-none focus:border-[#2075bd] focus:shadow-[0_0_0_2px_var(--fds-color-primary-blue-20)]" }) }), _jsx("div", { className: "max-h-[210px] overflow-y-auto p-fds-xs", children: filteredCountries.length === 0 ? (_jsx("div", { className: "px-fds-sm py-fds-md text-center text-fds-sm text-muted-foreground", children: "No countries found" })) : (filteredCountries.map((country, index) => {
110
- const isSelected = country.code === value;
111
- const isMostUsed = mostUsedCountries.includes(country.code);
112
- const isLastMostUsed = isMostUsed &&
113
- !search &&
114
- index === mostUsedCountries.length - 1 &&
115
- filteredCountries.length > mostUsedCountries.length;
116
- return (_jsxs(React.Fragment, { children: [_jsxs("div", { onClick: () => handleSelect(country), className: cn('flex cursor-pointer items-center gap-fds-sm rounded-fds-sm px-fds-sm py-fds-xs hover:bg-accent', isSelected && 'bg-accent'), children: [_jsx("img", { src: getCountryFlag(country.code), alt: country.code, className: "h-6 w-6 shrink-0 rounded-full object-cover" }), _jsx("span", { className: "flex-1 truncate text-fds-base", children: country.name }), isSelected && (_jsx(IconCheck, { size: 16, className: "shrink-0 text-fds-blue" }))] }), isLastMostUsed && (_jsx("div", { className: "my-fds-xs h-px bg-border" }))] }, country.code));
117
- })) })] }))] }));
118
- };
@@ -1,23 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as React from 'react';
4
- import { CalendarIcon } from 'lucide-react';
5
- import { IconClearCircledSolid } from '@freightos/icons';
6
- import { format } from 'date-fns';
7
- import { cn } from '../lib/utils';
8
- import { Calendar } from './calendar';
9
- import { Popover, PopoverContent, PopoverTrigger, } from './popover';
10
- export function DatePicker({ value, onChange, placeholder = 'Pick a date', disabled = false, className, }) {
11
- const [open, setOpen] = React.useState(false);
12
- const [isHovered, setIsHovered] = React.useState(false);
13
- const handleSelect = (date) => {
14
- onChange?.(date);
15
- setOpen(false);
16
- };
17
- const handleClear = (e) => {
18
- e.stopPropagation();
19
- onChange?.(undefined);
20
- };
21
- const showClearIcon = isHovered && value;
22
- return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", disabled: disabled, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), className: cn('flex h-[var(--fds-size-xl)] w-full items-center justify-between gap-3 rounded-[var(--fds-border-radius-md)] border border-input-border bg-input py-1 pl-3 pr-2 text-sm', 'focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', 'disabled:cursor-not-allowed disabled:opacity-50', !value && 'text-muted-foreground', className), children: [_jsx("span", { className: "truncate", children: value ? format(value, 'dd/MM/yyyy') : placeholder }), showClearIcon ? (_jsx(IconClearCircledSolid, { size: 16, className: "shrink-0 cursor-pointer text-muted-foreground hover:text-foreground", onClick: handleClear })) : (_jsx(CalendarIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }))] }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: _jsx(Calendar, { mode: "single", selected: value, onSelect: handleSelect }) })] }));
23
- }
@@ -1,23 +0,0 @@
1
- 'use client';
2
- import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import * as React from 'react';
4
- import { CalendarIcon } from 'lucide-react';
5
- import { IconClearCircledSolid } from '@freightos/icons';
6
- import { format } from 'date-fns';
7
- import { cn } from '../lib/utils';
8
- import { Calendar } from './calendar';
9
- import { Popover, PopoverContent, PopoverTrigger, } from './popover';
10
- export function DateRangePicker({ value, onChange, placeholder = 'Start date - End date', disabled = false, className, }) {
11
- const [open, setOpen] = React.useState(false);
12
- const [isHovered, setIsHovered] = React.useState(false);
13
- const handleSelect = (range) => {
14
- onChange?.(range);
15
- };
16
- const handleClear = (e) => {
17
- e.stopPropagation();
18
- onChange?.(undefined);
19
- };
20
- const hasValue = value?.from;
21
- const showClearIcon = isHovered && hasValue;
22
- return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", disabled: disabled, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), className: cn('flex h-[var(--fds-size-xl)] w-full items-center justify-between gap-3 rounded-[var(--fds-border-radius-md)] border border-input-border bg-input py-1 pl-3 pr-2 text-sm', 'focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', 'disabled:cursor-not-allowed disabled:opacity-50', !hasValue && 'text-muted-foreground', className), children: [_jsx("span", { className: "truncate", children: value?.from ? (value.to ? (_jsxs(_Fragment, { children: [format(value.from, 'dd/MM/yyyy'), " - ", format(value.to, 'dd/MM/yyyy')] })) : (format(value.from, 'dd/MM/yyyy'))) : (placeholder) }), showClearIcon ? (_jsx(IconClearCircledSolid, { size: 16, className: "shrink-0 cursor-pointer text-muted-foreground hover:text-foreground", onClick: handleClear })) : (_jsx(CalendarIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }))] }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "end", children: _jsx(Calendar, { mode: "range", defaultMonth: value?.from, selected: value, onSelect: handleSelect, numberOfMonths: 2, showOutsideDays: false }) })] }));
23
- }
@@ -1,70 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as React from 'react';
4
- import { CalendarIcon } from 'lucide-react';
5
- import { IconClearCircledSolid } from '@freightos/icons';
6
- import { format } from 'date-fns';
7
- import { cn } from '../lib/utils';
8
- import { Button } from './button';
9
- import { Calendar } from './calendar';
10
- import { Popover, PopoverContent, PopoverTrigger, } from './popover';
11
- import { ScrollArea, ScrollBar, } from './scroll-area';
12
- export function DateTimePicker({ value, onChange, placeholder = 'Pick date and time', disabled = false, className, use24Hour = false, }) {
13
- const [open, setOpen] = React.useState(false);
14
- const [isHovered, setIsHovered] = React.useState(false);
15
- const hours = use24Hour
16
- ? Array.from({ length: 24 }, (_, i) => i)
17
- : Array.from({ length: 12 }, (_, i) => i + 1);
18
- const handleDateSelect = (selectedDate) => {
19
- if (selectedDate) {
20
- const newDate = new Date(selectedDate);
21
- if (value) {
22
- newDate.setHours(value.getHours());
23
- newDate.setMinutes(value.getMinutes());
24
- }
25
- onChange?.(newDate);
26
- }
27
- };
28
- const handleTimeChange = (type, val) => {
29
- const newDate = value ? new Date(value) : new Date();
30
- if (type === 'hour') {
31
- if (use24Hour) {
32
- newDate.setHours(parseInt(val));
33
- }
34
- else {
35
- newDate.setHours((parseInt(val) % 12) + (newDate.getHours() >= 12 ? 12 : 0));
36
- }
37
- }
38
- else if (type === 'minute') {
39
- newDate.setMinutes(parseInt(val));
40
- }
41
- else if (type === 'ampm') {
42
- const currentHours = newDate.getHours();
43
- if (val === 'PM' && currentHours < 12) {
44
- newDate.setHours(currentHours + 12);
45
- }
46
- else if (val === 'AM' && currentHours >= 12) {
47
- newDate.setHours(currentHours - 12);
48
- }
49
- }
50
- onChange?.(newDate);
51
- };
52
- const handleClear = (e) => {
53
- e.stopPropagation();
54
- onChange?.(undefined);
55
- };
56
- const formatString = use24Hour ? 'dd/MM/yyyy HH:mm' : 'dd/MM/yyyy hh:mm aa';
57
- const showClearIcon = isHovered && value;
58
- return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", disabled: disabled, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), className: cn('flex h-[var(--fds-size-xl)] w-full items-center justify-between gap-3 rounded-[var(--fds-border-radius-md)] border border-input-border bg-input py-1 pl-3 pr-2 text-sm', 'focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', 'disabled:cursor-not-allowed disabled:opacity-50', !value && 'text-muted-foreground', className), children: [_jsx("span", { className: "truncate", children: value ? format(value, formatString) : placeholder }), showClearIcon ? (_jsx(IconClearCircledSolid, { size: 16, className: "shrink-0 cursor-pointer text-muted-foreground hover:text-foreground", onClick: handleClear })) : (_jsx(CalendarIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }))] }) }), _jsx(PopoverContent, { className: "w-auto p-0", children: _jsxs("div", { className: "sm:flex", children: [_jsx(Calendar, { mode: "single", selected: value, onSelect: handleDateSelect }), _jsxs("div", { className: "flex flex-col divide-y sm:h-[300px] sm:flex-row sm:divide-x sm:divide-y-0", children: [_jsxs(ScrollArea, { className: "w-64 sm:w-auto", children: [_jsx("div", { className: "flex p-2 sm:flex-col", children: hours.map((hour) => (_jsx(Button, { size: "small", htmlType: "button", type: value &&
59
- (use24Hour
60
- ? value.getHours() === hour
61
- : value.getHours() % 12 === hour % 12)
62
- ? 'default'
63
- : 'text', className: "aspect-square shrink-0 sm:w-full", onClick: () => handleTimeChange('hour', hour.toString()), children: use24Hour ? hour.toString().padStart(2, '0') : hour }, hour))) }), _jsx(ScrollBar, { orientation: "horizontal", className: "sm:hidden" })] }), _jsxs(ScrollArea, { className: "w-64 sm:w-auto", children: [_jsx("div", { className: "flex p-2 sm:flex-col", children: Array.from({ length: 12 }, (_, i) => i * 5).map((minute) => (_jsx(Button, { size: "small", htmlType: "button", type: value && value.getMinutes() === minute
64
- ? 'default'
65
- : 'text', className: "aspect-square shrink-0 sm:w-full", onClick: () => handleTimeChange('minute', minute.toString()), children: minute.toString().padStart(2, '0') }, minute))) }), _jsx(ScrollBar, { orientation: "horizontal", className: "sm:hidden" })] }), !use24Hour && (_jsx(ScrollArea, { className: "", children: _jsx("div", { className: "flex p-2 sm:flex-col", children: ['AM', 'PM'].map((ampm) => (_jsx(Button, { size: "small", htmlType: "button", type: value &&
66
- ((ampm === 'AM' && value.getHours() < 12) ||
67
- (ampm === 'PM' && value.getHours() >= 12))
68
- ? 'default'
69
- : 'text', className: "aspect-square shrink-0 sm:w-full", onClick: () => handleTimeChange('ampm', ampm), children: ampm }, ampm))) }) }))] })] }) })] }));
70
- }
@@ -1,24 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as DialogPrimitive from '@radix-ui/react-dialog';
3
- import * as React from 'react';
4
- import { cn } from '../lib/utils';
5
- import { IconClose } from '@freightos/icons';
6
- const Dialog = DialogPrimitive.Root;
7
- const DialogTrigger = DialogPrimitive.Trigger;
8
- const DialogPortal = DialogPrimitive.Portal;
9
- const DialogClose = DialogPrimitive.Close;
10
- const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Overlay, { ref: ref, className: cn('fixed inset-0 z-[9999] bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0', className), ...props })));
11
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
12
- const DialogContent = React.forwardRef(({ className, children, closable = true, ...props }, ref) => (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { ref: ref, className: cn('fixed left-[50%] top-[50%] z-[9999] flex w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col bg-card shadow-lg duration-150 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg', className), ...props, children: [children, closable && (_jsx(DialogPrimitive.Close, { asChild: true, children: _jsxs("button", { className: "hover:text-fds-gray-90 absolute end-fds-xl top-fds-lg text-fds-gray-60 dark:text-fds-gray-40 dark:hover:text-fds-gray-10", children: [_jsx(IconClose, { size: 24 }), _jsx("span", { className: "sr-only", children: "Close" })] }) }))] })] })));
13
- DialogContent.displayName = DialogPrimitive.Content.displayName;
14
- const DialogHeader = ({ className, ...props }) => (_jsx("div", { className: cn('flex flex-col space-y-1.5 border-b px-fds-xl py-fds-lg text-center sm:text-left', className), ...props }));
15
- DialogHeader.displayName = 'DialogHeader';
16
- const DialogBody = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn('flex-1 overflow-y-auto p-6', className), ...props })));
17
- DialogBody.displayName = 'DialogBody';
18
- const DialogFooter = ({ className, ...props }) => (_jsx("div", { className: cn('flex flex-col-reverse border-t p-6 sm:flex-row sm:justify-end sm:space-x-2', className), ...props }));
19
- DialogFooter.displayName = 'DialogFooter';
20
- const DialogTitle = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Title, { ref: ref, className: cn('text-lg font-semibold leading-none tracking-tight', className), ...props })));
21
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
22
- const DialogDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Description, { ref: ref, className: cn('text-sm text-muted-foreground', className), ...props })));
23
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
24
- export { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };
@@ -1,23 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as React from 'react';
4
- import { Drawer as DrawerPrimitive } from 'vaul';
5
- import { cn } from '../lib/utils';
6
- const Drawer = ({ shouldScaleBackground = true, ...props }) => (_jsx(DrawerPrimitive.Root, { shouldScaleBackground: shouldScaleBackground, ...props }));
7
- Drawer.displayName = 'Drawer';
8
- const DrawerTrigger = DrawerPrimitive.Trigger;
9
- const DrawerPortal = DrawerPrimitive.Portal;
10
- const DrawerClose = DrawerPrimitive.Close;
11
- const DrawerOverlay = React.forwardRef(({ className, ...props }, ref) => (_jsx(DrawerPrimitive.Overlay, { ref: ref, className: cn('fixed inset-0 z-50 bg-black/80', className), ...props })));
12
- DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
13
- const DrawerContent = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(DrawerPortal, { children: [_jsx(DrawerOverlay, {}), _jsxs(DrawerPrimitive.Content, { ref: ref, className: cn('fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background', className), ...props, children: [_jsx("div", { className: "mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" }), children] })] })));
14
- DrawerContent.displayName = 'DrawerContent';
15
- const DrawerHeader = ({ className, ...props }) => (_jsx("div", { className: cn('grid gap-1.5 p-4 text-center sm:text-left', className), ...props }));
16
- DrawerHeader.displayName = 'DrawerHeader';
17
- const DrawerFooter = ({ className, ...props }) => (_jsx("div", { className: cn('mt-auto flex flex-col gap-2 p-4', className), ...props }));
18
- DrawerFooter.displayName = 'DrawerFooter';
19
- const DrawerTitle = React.forwardRef(({ className, ...props }, ref) => (_jsx(DrawerPrimitive.Title, { ref: ref, className: cn('text-lg font-semibold leading-none tracking-tight', className), ...props })));
20
- DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
21
- const DrawerDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx(DrawerPrimitive.Description, { ref: ref, className: cn('text-sm text-muted-foreground', className), ...props })));
22
- DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
23
- export { Drawer, DrawerPortal, DrawerOverlay, DrawerTrigger, DrawerClose, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription, };
@@ -1,35 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
3
- import { Check, ChevronRight, Circle } from 'lucide-react';
4
- import * as React from 'react';
5
- import { cn } from '../lib/utils';
6
- const DropdownMenu = DropdownMenuPrimitive.Root;
7
- const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
8
- const DropdownMenuGroup = DropdownMenuPrimitive.Group;
9
- const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
10
- const DropdownMenuSub = DropdownMenuPrimitive.Sub;
11
- const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
12
- const DropdownMenuSubTrigger = React.forwardRef(({ className, inset, children, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.SubTrigger, { ref: ref, className: cn('flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0', inset && 'pl-8', className), ...props, children: [children, _jsx(ChevronRight, { className: "ml-auto" })] })));
13
- DropdownMenuSubTrigger.displayName =
14
- DropdownMenuPrimitive.SubTrigger.displayName;
15
- const DropdownMenuSubContent = React.forwardRef(({ className, ...props }, ref) => (_jsx(DropdownMenuPrimitive.SubContent, { ref: ref, className: cn('z-50 min-w-[8rem] origin-[--radix-dropdown-menu-content-transform-origin] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', className), ...props })));
16
- DropdownMenuSubContent.displayName =
17
- DropdownMenuPrimitive.SubContent.displayName;
18
- const DropdownMenuContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { ref: ref, sideOffset: sideOffset, className: cn('z-[1010] max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] origin-[--radix-dropdown-menu-content-transform-origin] overflow-y-auto overflow-x-hidden rounded-md bg-popover py-1 text-popover-foreground shadow-fds-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', className), ...props }) })));
19
- DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
20
- const DropdownMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Item, { ref: ref, className: cn('relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-fds-xs text-sm outline-none transition-colors hover:bg-fds-blue-10 focus:bg-fds-blue-10 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0', inset && 'pl-8', className), ...props })));
21
- DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
22
- const DropdownMenuCheckboxItem = React.forwardRef(({ className, children, checked, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.CheckboxItem, { ref: ref, className: cn('relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className), checked: checked, ...props, children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4" }) }) }), children] })));
23
- DropdownMenuCheckboxItem.displayName =
24
- DropdownMenuPrimitive.CheckboxItem.displayName;
25
- const DropdownMenuRadioItem = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.RadioItem, { ref: ref, className: cn('relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className), ...props, children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }), children] })));
26
- DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
27
- const DropdownMenuLabel = React.forwardRef(({ className, inset, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Label, { ref: ref, className: cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className), ...props })));
28
- DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
29
- const DropdownMenuSeparator = React.forwardRef(({ className, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Separator, { ref: ref, className: cn('-mx-1 my-1 h-px bg-muted', className), ...props })));
30
- DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
31
- const DropdownMenuShortcut = ({ className, ...props }) => {
32
- return (_jsx("span", { className: cn('ml-auto text-xs tracking-widest opacity-60', className), ...props }));
33
- };
34
- DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
35
- export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, };
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { cn } from '../lib/utils';
4
- const Empty = React.forwardRef(({ className, message = 'No data', ...props }, ref) => (_jsxs("div", { ref: ref, className: cn('flex flex-col items-center justify-center py-fds-xl', className), ...props, children: [_jsx("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: _jsxs("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [_jsx("ellipse", { className: "fill-fds-gray-10 dark:fill-fds-gray-80", cx: "32", cy: "33", rx: "32", ry: "7" }), _jsxs("g", { fillRule: "nonzero", className: "stroke-fds-gray-30 dark:stroke-fds-gray-60", children: [_jsx("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }), _jsx("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", className: "fill-fds-gray-5 dark:fill-fds-gray-90" })] })] }) }), _jsx("span", { className: "mt-fds-sm text-fds-sm text-fds-gray-50", children: message })] })));
5
- Empty.displayName = 'Empty';
6
- export { Empty };
@@ -1,69 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Button } from './button';
4
- import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from './dialog';
5
- import { IconDownload, IconPrint } from '@freightos/icons';
6
- const IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg', '.bmp'];
7
- function isImageFile(fileName) {
8
- const lowerName = fileName.toLowerCase();
9
- return IMAGE_EXTENSIONS.some(ext => lowerName.endsWith(ext));
10
- }
11
- export const FilePreview = ({ fileName, fileUrl, open, onOpenChange, }) => {
12
- const isImage = isImageFile(fileName);
13
- const handlePrint = () => {
14
- if (isImage) {
15
- // For images, create a printable HTML page
16
- const printWindow = window.open('', '_blank');
17
- if (printWindow) {
18
- printWindow.document.write(`
19
- <!DOCTYPE html>
20
- <html>
21
- <head>
22
- <title>${fileName}</title>
23
- <style>
24
- body { margin: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; }
25
- img { max-width: 100%; max-height: 100vh; object-fit: contain; }
26
- @media print { body { margin: 0; } img { max-width: 100%; max-height: 100%; } }
27
- </style>
28
- </head>
29
- <body>
30
- <img src="${fileUrl}" alt="${fileName}" onload="window.print(); window.close();" />
31
- </body>
32
- </html>
33
- `);
34
- printWindow.document.close();
35
- }
36
- }
37
- else {
38
- // For PDFs and other documents
39
- const printWindow = window.open(fileUrl, '_blank');
40
- if (printWindow) {
41
- printWindow.onload = () => {
42
- printWindow.print();
43
- };
44
- }
45
- }
46
- };
47
- const handleDownload = async () => {
48
- try {
49
- const response = await fetch(fileUrl);
50
- const blob = await response.blob();
51
- const url = window.URL.createObjectURL(blob);
52
- const link = document.createElement('a');
53
- link.href = url;
54
- link.download = fileName;
55
- document.body.appendChild(link);
56
- link.click();
57
- document.body.removeChild(link);
58
- window.URL.revokeObjectURL(url);
59
- onOpenChange(false);
60
- }
61
- catch (error) {
62
- console.error('Download failed:', error);
63
- // Fallback: open in new tab
64
- window.open(fileUrl, '_blank');
65
- onOpenChange(false);
66
- }
67
- };
68
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "h-[90vh] max-w-4xl", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: fileName }) }), _jsx("div", { className: "flex flex-1 items-center justify-center overflow-auto p-fds-xl", children: isImage ? (_jsx("img", { src: fileUrl, alt: fileName, className: "max-h-full max-w-full object-contain" })) : (_jsx("iframe", { src: fileUrl, title: fileName, className: "h-full w-full border-0" })) }), _jsxs(DialogFooter, { className: "flex justify-end gap-2 py-fds-lg", children: [_jsxs(Button, { type: "secondary", size: "medium", onClick: handlePrint, children: [_jsx(IconPrint, {}), "Print"] }), _jsxs(Button, { type: "default", size: "medium", onClick: handleDownload, children: [_jsx(IconDownload, {}), "Download"] })] })] }) }));
69
- };
@@ -1,63 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import * as React from 'react';
4
- import { Slot } from '@radix-ui/react-slot';
5
- import { Controller, FormProvider, useFormContext, } from 'react-hook-form';
6
- import { cn } from '../lib/utils';
7
- import { Label } from './label';
8
- const Form = FormProvider;
9
- const FormFieldContext = React.createContext({});
10
- const FormField = ({ ...props }) => {
11
- return (_jsx(FormFieldContext.Provider, { value: { name: props.name }, children: _jsx(Controller, { ...props }) }));
12
- };
13
- const useFormField = () => {
14
- const fieldContext = React.useContext(FormFieldContext);
15
- const itemContext = React.useContext(FormItemContext);
16
- const { getFieldState, formState } = useFormContext();
17
- const fieldState = getFieldState(fieldContext.name, formState);
18
- if (!fieldContext) {
19
- throw new Error('useFormField should be used within <FormField>');
20
- }
21
- const { id } = itemContext;
22
- return {
23
- id,
24
- name: fieldContext.name,
25
- formItemId: `${id}-form-item`,
26
- formDescriptionId: `${id}-form-item-description`,
27
- formMessageId: `${id}-form-item-message`,
28
- ...fieldState,
29
- };
30
- };
31
- const FormItemContext = React.createContext({});
32
- const FormItem = React.forwardRef(({ className, ...props }, ref) => {
33
- const id = React.useId();
34
- return (_jsx(FormItemContext.Provider, { value: { id }, children: _jsx("div", { ref: ref, className: cn('space-y-fds-xs', className), ...props }) }));
35
- });
36
- FormItem.displayName = 'FormItem';
37
- const FormLabel = React.forwardRef(({ className, ...props }, ref) => {
38
- const { error, formItemId } = useFormField();
39
- return (_jsx(Label, { ref: ref, className: cn(error && 'text-destructive', className), htmlFor: formItemId, ...props }));
40
- });
41
- FormLabel.displayName = 'FormLabel';
42
- const FormControl = React.forwardRef(({ ...props }, ref) => {
43
- const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
44
- return (_jsx(Slot, { ref: ref, id: formItemId, "aria-describedby": !error
45
- ? `${formDescriptionId}`
46
- : `${formDescriptionId} ${formMessageId}`, "aria-invalid": !!error, ...props }));
47
- });
48
- FormControl.displayName = 'FormControl';
49
- const FormDescription = React.forwardRef(({ className, ...props }, ref) => {
50
- const { formDescriptionId } = useFormField();
51
- return (_jsx("p", { ref: ref, id: formDescriptionId, className: cn('text-sm text-muted-foreground', className), ...props }));
52
- });
53
- FormDescription.displayName = 'FormDescription';
54
- const FormMessage = React.forwardRef(({ className, children, ...props }, ref) => {
55
- const { error, formMessageId } = useFormField();
56
- const body = error ? String(error?.message ?? '') : children;
57
- if (!body) {
58
- return null;
59
- }
60
- return (_jsx("p", { ref: ref, id: formMessageId, className: cn('text-sm font-medium text-destructive', className), ...props, children: body }));
61
- });
62
- FormMessage.displayName = 'FormMessage';
63
- export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, };
@@ -1,47 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as React from 'react';
4
- import { cn } from '../lib/utils';
5
- import { IconEdit } from '@freightos/icons';
6
- import { Input } from './input';
7
- const InlineEdit = React.forwardRef(({ value, onChange, placeholder = 'Click to edit', className, hideIcon = false }, ref) => {
8
- const [isEditing, setIsEditing] = React.useState(false);
9
- const [editValue, setEditValue] = React.useState(value);
10
- const inputRef = React.useRef(null);
11
- React.useEffect(() => {
12
- setEditValue(value);
13
- }, [value]);
14
- React.useEffect(() => {
15
- if (isEditing && inputRef.current) {
16
- inputRef.current.focus();
17
- inputRef.current.select();
18
- }
19
- }, [isEditing]);
20
- const handleSave = () => {
21
- setIsEditing(false);
22
- if (editValue.trim() !== value) {
23
- onChange(editValue.trim());
24
- }
25
- else {
26
- setEditValue(value);
27
- }
28
- };
29
- const handleCancel = () => {
30
- setIsEditing(false);
31
- setEditValue(value);
32
- };
33
- const handleKeyDown = (e) => {
34
- if (e.key === 'Enter') {
35
- handleSave();
36
- }
37
- else if (e.key === 'Escape') {
38
- handleCancel();
39
- }
40
- };
41
- if (isEditing) {
42
- return (_jsx(Input, { ref: inputRef, type: "text", value: editValue, onChange: (e) => setEditValue(e.target.value), onBlur: handleSave, onKeyDown: handleKeyDown, className: cn('w-auto', className), placeholder: placeholder, inputSize: "small" }));
43
- }
44
- return (_jsxs("div", { ref: ref, onClick: () => setIsEditing(true), className: cn('group inline-flex h-[24px] cursor-pointer items-center gap-fds-xs rounded px-fds-xs font-fds-semibold hover:bg-fds-blue-10 dark:hover:bg-fds-gray-80', className), children: [_jsx("span", { className: cn(!value && 'text-fds-gray-60'), children: value || placeholder }), !hideIcon && _jsx(IconEdit, { size: 14, className: "text-fds-gray-60" })] }));
45
- });
46
- InlineEdit.displayName = 'InlineEdit';
47
- export { InlineEdit };
@@ -1,63 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { cva } from 'class-variance-authority';
4
- import { cn } from '../lib/utils';
5
- import { Button } from './button';
6
- import { Input } from './input';
7
- import { Textarea } from './textarea';
8
- function InputGroup({ className, ...props }) {
9
- return (_jsx("div", { "data-slot": "input-group", role: "group", className: cn('group/input-group relative flex w-full items-center rounded-fds-md border border-input-border bg-input outline-none transition-[color,box-shadow]', 'h-[32px] has-[>textarea]:h-auto',
10
- // Variants based on alignment.
11
- 'has-[>[data-align=inline-start]]:[&>input]:pl-2', 'has-[>[data-align=inline-end]]:[&>input]:pr-2', 'has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3', 'has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3',
12
- // Focus state.
13
- 'focus-within:border-[#2075bd] focus-within:shadow-[0_0_0_2px_var(--fds-color-primary-blue-20)]',
14
- // Error state.
15
- 'has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40', className), ...props }));
16
- }
17
- const inputGroupAddonVariants = cva("text-muted-foreground flex h-full cursor-text select-none items-center justify-center gap-2 bg-fds-gray-10 px-3 text-xs font-medium group-data-[disabled=true]/input-group:opacity-50 dark:bg-background [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
18
- variants: {
19
- align: {
20
- 'inline-start': 'order-first rounded-l-[3px] border-r border-input-border',
21
- 'inline-end': 'order-last rounded-r-[3px] border-l border-input-border',
22
- 'block-start': '[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5',
23
- 'block-end': '[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5',
24
- },
25
- },
26
- defaultVariants: {
27
- align: 'inline-start',
28
- },
29
- });
30
- function InputGroupAddon({ className, align = 'inline-start', ...props }) {
31
- return (_jsx("div", { role: "group", "data-slot": "input-group-addon", "data-align": align, className: cn(inputGroupAddonVariants({ align }), className), onClick: (e) => {
32
- if (e.target.closest('button')) {
33
- return;
34
- }
35
- e.currentTarget.parentElement?.querySelector('input')?.focus();
36
- }, ...props }));
37
- }
38
- const inputGroupButtonVariants = cva('flex items-center gap-2 text-sm shadow-none', {
39
- variants: {
40
- size: {
41
- xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
42
- sm: 'h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5',
43
- 'icon-xs': 'size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0',
44
- 'icon-sm': 'size-8 p-0 has-[>svg]:p-0',
45
- },
46
- },
47
- defaultVariants: {
48
- size: 'xs',
49
- },
50
- });
51
- function InputGroupButton({ className, htmlType = 'button', type = 'text', size = 'xs', ...props }) {
52
- return (_jsx(Button, { htmlType: htmlType, type: type, "data-size": size, className: cn(inputGroupButtonVariants({ size }), className), ...props }));
53
- }
54
- function InputGroupText({ className, ...props }) {
55
- return (_jsx("span", { className: cn("flex items-center gap-2 text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none", className), ...props }));
56
- }
57
- function InputGroupInput({ className, ...props }) {
58
- return (_jsx(Input, { "data-slot": "input-group-control", className: cn('flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent', className), ...props }));
59
- }
60
- function InputGroupTextarea({ className, ...props }) {
61
- return (_jsx(Textarea, { "data-slot": "input-group-control", className: cn('flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent', className), ...props }));
62
- }
63
- export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, };
@@ -1,19 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as React from "react";
4
- import { OTPInput, OTPInputContext } from "input-otp";
5
- import { Dot } from "lucide-react";
6
- import { cn } from "../lib/utils";
7
- const InputOTP = React.forwardRef(({ className, containerClassName, ...props }, ref) => (_jsx(OTPInput, { ref: ref, containerClassName: cn("flex items-center gap-2 has-[:disabled]:opacity-50", containerClassName), className: cn("disabled:cursor-not-allowed", className), ...props })));
8
- InputOTP.displayName = "InputOTP";
9
- const InputOTPGroup = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("flex items-center", className), ...props })));
10
- InputOTPGroup.displayName = "InputOTPGroup";
11
- const InputOTPSlot = React.forwardRef(({ index, className, ...props }, ref) => {
12
- const inputOTPContext = React.useContext(OTPInputContext);
13
- const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
14
- return (_jsxs("div", { ref: ref, className: cn("relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md", isActive && "z-10 ring-2 ring-ring ring-offset-background", className), ...props, children: [char, hasFakeCaret && (_jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: _jsx("div", { className: "h-4 w-px animate-caret-blink bg-foreground duration-1000" }) }))] }));
15
- });
16
- InputOTPSlot.displayName = "InputOTPSlot";
17
- const InputOTPSeparator = React.forwardRef(({ ...props }, ref) => (_jsx("div", { ref: ref, role: "separator", ...props, children: _jsx(Dot, {}) })));
18
- InputOTPSeparator.displayName = "InputOTPSeparator";
19
- export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };