@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.
- 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/guidelines/Guidelines.md +54 -0
- package/guidelines/design-tokens/colors.md +81 -0
- package/guidelines/design-tokens/spacing.md +45 -0
- package/guidelines/design-tokens/typography.md +50 -0
- package/guidelines/overview-components.md +252 -0
- package/guidelines/overview-icons.md +52 -0
- package/package.json +63 -54
- package/tokens.css +409 -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
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
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
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.PaginationPrevious = exports.PaginationNext = exports.PaginationLink = exports.PaginationItem = exports.PaginationEllipsis = exports.PaginationContent = exports.Pagination = void 0;
|
|
37
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
-
const React = __importStar(require("react"));
|
|
39
|
-
const lucide_react_1 = require("lucide-react");
|
|
40
|
-
const utils_1 = require("../lib/utils");
|
|
41
|
-
const button_1 = require("./button");
|
|
42
|
-
const Pagination = ({ className, ...props }) => ((0, jsx_runtime_1.jsx)("nav", { role: "navigation", "aria-label": "pagination", className: (0, utils_1.cn)('mx-auto flex w-full justify-center', className), ...props }));
|
|
43
|
-
exports.Pagination = Pagination;
|
|
44
|
-
Pagination.displayName = 'Pagination';
|
|
45
|
-
const PaginationContent = React.forwardRef(({ className, ...props }, ref) => ((0, jsx_runtime_1.jsx)("ul", { ref: ref, className: (0, utils_1.cn)('flex flex-row items-center gap-1', className), ...props })));
|
|
46
|
-
exports.PaginationContent = PaginationContent;
|
|
47
|
-
PaginationContent.displayName = 'PaginationContent';
|
|
48
|
-
const PaginationItem = React.forwardRef(({ className, ...props }, ref) => ((0, jsx_runtime_1.jsx)("li", { ref: ref, className: (0, utils_1.cn)('', className), ...props })));
|
|
49
|
-
exports.PaginationItem = PaginationItem;
|
|
50
|
-
PaginationItem.displayName = 'PaginationItem';
|
|
51
|
-
const PaginationLink = ({ className, isActive, icon = true, size, ...props }) => ((0, jsx_runtime_1.jsx)("a", { "aria-current": isActive ? 'page' : undefined, className: (0, utils_1.cn)((0, button_1.buttonVariants)({
|
|
52
|
-
type: isActive ? 'secondary' : 'text',
|
|
53
|
-
size,
|
|
54
|
-
}), icon && 'aspect-square p-0', className), ...props }));
|
|
55
|
-
exports.PaginationLink = PaginationLink;
|
|
56
|
-
PaginationLink.displayName = 'PaginationLink';
|
|
57
|
-
const PaginationPrevious = ({ className, ...props }) => ((0, jsx_runtime_1.jsxs)(PaginationLink, { "aria-label": "Go to previous page", icon: false, size: "medium", className: (0, utils_1.cn)('gap-1 pl-2.5', className), ...props, children: [(0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "h-4 w-4" }), (0, jsx_runtime_1.jsx)("span", { children: "Previous" })] }));
|
|
58
|
-
exports.PaginationPrevious = PaginationPrevious;
|
|
59
|
-
PaginationPrevious.displayName = 'PaginationPrevious';
|
|
60
|
-
const PaginationNext = ({ className, ...props }) => ((0, jsx_runtime_1.jsxs)(PaginationLink, { "aria-label": "Go to next page", icon: false, size: "medium", className: (0, utils_1.cn)('gap-1 pr-2.5', className), ...props, children: [(0, jsx_runtime_1.jsx)("span", { children: "Next" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }));
|
|
61
|
-
exports.PaginationNext = PaginationNext;
|
|
62
|
-
PaginationNext.displayName = 'PaginationNext';
|
|
63
|
-
const PaginationEllipsis = ({ className, ...props }) => ((0, jsx_runtime_1.jsxs)("span", { "aria-hidden": true, className: (0, utils_1.cn)('flex h-9 w-9 items-center justify-center', className), ...props, children: [(0, jsx_runtime_1.jsx)(lucide_react_1.MoreHorizontal, { className: "h-4 w-4" }), (0, jsx_runtime_1.jsx)("span", { className: "sr-only", children: "More pages" })] }));
|
|
64
|
-
exports.PaginationEllipsis = PaginationEllipsis;
|
|
65
|
-
PaginationEllipsis.displayName = 'PaginationEllipsis';
|
|
@@ -1,218 +0,0 @@
|
|
|
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
|
-
})();
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.PhoneInput = exports.PHONE_COUNTRIES = void 0;
|
|
38
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
|
-
const utils_1 = require("../lib/utils");
|
|
40
|
-
const countryUtils_1 = require("../lib/countryUtils");
|
|
41
|
-
const icons_1 = require("@freightos/icons");
|
|
42
|
-
const React = __importStar(require("react"));
|
|
43
|
-
const libphonenumber_js_1 = require("libphonenumber-js");
|
|
44
|
-
// Countries with dial codes
|
|
45
|
-
exports.PHONE_COUNTRIES = [
|
|
46
|
-
{ code: 'US', name: 'United States', dialCode: '+1' },
|
|
47
|
-
{ code: 'CN', name: 'China', dialCode: '+86' },
|
|
48
|
-
{ code: 'GB', name: 'United Kingdom', dialCode: '+44' },
|
|
49
|
-
{ code: 'CA', name: 'Canada', dialCode: '+1' },
|
|
50
|
-
{ code: 'DE', name: 'Germany', dialCode: '+49' },
|
|
51
|
-
{ code: 'FR', name: 'France', dialCode: '+33' },
|
|
52
|
-
{ code: 'IT', name: 'Italy', dialCode: '+39' },
|
|
53
|
-
{ code: 'ES', name: 'Spain', dialCode: '+34' },
|
|
54
|
-
{ code: 'NL', name: 'Netherlands', dialCode: '+31' },
|
|
55
|
-
{ code: 'BE', name: 'Belgium', dialCode: '+32' },
|
|
56
|
-
{ code: 'CH', name: 'Switzerland', dialCode: '+41' },
|
|
57
|
-
{ code: 'AT', name: 'Austria', dialCode: '+43' },
|
|
58
|
-
{ code: 'SE', name: 'Sweden', dialCode: '+46' },
|
|
59
|
-
{ code: 'NO', name: 'Norway', dialCode: '+47' },
|
|
60
|
-
{ code: 'DK', name: 'Denmark', dialCode: '+45' },
|
|
61
|
-
{ code: 'FI', name: 'Finland', dialCode: '+358' },
|
|
62
|
-
{ code: 'PL', name: 'Poland', dialCode: '+48' },
|
|
63
|
-
{ code: 'CZ', name: 'Czech Republic', dialCode: '+420' },
|
|
64
|
-
{ code: 'IE', name: 'Ireland', dialCode: '+353' },
|
|
65
|
-
{ code: 'PT', name: 'Portugal', dialCode: '+351' },
|
|
66
|
-
{ code: 'GR', name: 'Greece', dialCode: '+30' },
|
|
67
|
-
{ code: 'JP', name: 'Japan', dialCode: '+81' },
|
|
68
|
-
{ code: 'KR', name: 'South Korea', dialCode: '+82' },
|
|
69
|
-
{ code: 'IN', name: 'India', dialCode: '+91' },
|
|
70
|
-
{ code: 'AU', name: 'Australia', dialCode: '+61' },
|
|
71
|
-
{ code: 'NZ', name: 'New Zealand', dialCode: '+64' },
|
|
72
|
-
{ code: 'SG', name: 'Singapore', dialCode: '+65' },
|
|
73
|
-
{ code: 'HK', name: 'Hong Kong', dialCode: '+852' },
|
|
74
|
-
{ code: 'TW', name: 'Taiwan', dialCode: '+886' },
|
|
75
|
-
{ code: 'TH', name: 'Thailand', dialCode: '+66' },
|
|
76
|
-
{ code: 'MY', name: 'Malaysia', dialCode: '+60' },
|
|
77
|
-
{ code: 'ID', name: 'Indonesia', dialCode: '+62' },
|
|
78
|
-
{ code: 'PH', name: 'Philippines', dialCode: '+63' },
|
|
79
|
-
{ code: 'VN', name: 'Vietnam', dialCode: '+84' },
|
|
80
|
-
{ code: 'BR', name: 'Brazil', dialCode: '+55' },
|
|
81
|
-
{ code: 'MX', name: 'Mexico', dialCode: '+52' },
|
|
82
|
-
{ code: 'AR', name: 'Argentina', dialCode: '+54' },
|
|
83
|
-
{ code: 'CL', name: 'Chile', dialCode: '+56' },
|
|
84
|
-
{ code: 'CO', name: 'Colombia', dialCode: '+57' },
|
|
85
|
-
{ code: 'PE', name: 'Peru', dialCode: '+51' },
|
|
86
|
-
{ code: 'ZA', name: 'South Africa', dialCode: '+27' },
|
|
87
|
-
{ code: 'EG', name: 'Egypt', dialCode: '+20' },
|
|
88
|
-
{ code: 'IL', name: 'Israel', dialCode: '+972' },
|
|
89
|
-
{ code: 'AE', name: 'United Arab Emirates', dialCode: '+971' },
|
|
90
|
-
{ code: 'SA', name: 'Saudi Arabia', dialCode: '+966' },
|
|
91
|
-
{ code: 'TR', name: 'Turkey', dialCode: '+90' },
|
|
92
|
-
{ code: 'RU', name: 'Russia', dialCode: '+7' },
|
|
93
|
-
{ code: 'UA', name: 'Ukraine', dialCode: '+380' },
|
|
94
|
-
];
|
|
95
|
-
const PhoneInput = ({ value = '', onChange, onError, placeholder = 'Enter phone number', defaultCountry = 'US', mostUsedCountries = ['US', 'CN'], countries = exports.PHONE_COUNTRIES, className, disabled = false, }) => {
|
|
96
|
-
const [open, setOpen] = React.useState(false);
|
|
97
|
-
const [search, setSearch] = React.useState('');
|
|
98
|
-
const [selectedCountry, setSelectedCountry] = React.useState(() => countries.find((c) => c.code === defaultCountry) || countries[0]);
|
|
99
|
-
const [phoneNumber, setPhoneNumber] = React.useState('');
|
|
100
|
-
const containerRef = React.useRef(null);
|
|
101
|
-
const searchInputRef = React.useRef(null);
|
|
102
|
-
// Parse initial value to extract country and number
|
|
103
|
-
React.useEffect(() => {
|
|
104
|
-
if (value) {
|
|
105
|
-
try {
|
|
106
|
-
const parsed = (0, libphonenumber_js_1.parsePhoneNumberFromString)(value);
|
|
107
|
-
if (parsed) {
|
|
108
|
-
const countryCode = parsed.country;
|
|
109
|
-
if (countryCode) {
|
|
110
|
-
const country = countries.find((c) => c.code === countryCode);
|
|
111
|
-
if (country) {
|
|
112
|
-
setSelectedCountry(country);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
setPhoneNumber(parsed.nationalNumber);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// Try to extract dial code from value
|
|
119
|
-
const matchingCountry = countries.find((c) => value.startsWith(c.dialCode));
|
|
120
|
-
if (matchingCountry) {
|
|
121
|
-
setSelectedCountry(matchingCountry);
|
|
122
|
-
setPhoneNumber(value.slice(matchingCountry.dialCode.length).trim());
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
setPhoneNumber(value.replace(/^\+\d+\s*/, ''));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
catch {
|
|
130
|
-
setPhoneNumber(value);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
134
|
-
}, []);
|
|
135
|
-
// Filter countries based on search
|
|
136
|
-
const filteredCountries = React.useMemo(() => {
|
|
137
|
-
const searchLower = search.toLowerCase();
|
|
138
|
-
const filtered = countries.filter((country) => country.name.toLowerCase().includes(searchLower) ||
|
|
139
|
-
country.code.toLowerCase().includes(searchLower) ||
|
|
140
|
-
country.dialCode.includes(search));
|
|
141
|
-
return filtered.sort((a, b) => {
|
|
142
|
-
const aIsMostUsed = mostUsedCountries.includes(a.code);
|
|
143
|
-
const bIsMostUsed = mostUsedCountries.includes(b.code);
|
|
144
|
-
if (aIsMostUsed && !bIsMostUsed)
|
|
145
|
-
return -1;
|
|
146
|
-
if (!aIsMostUsed && bIsMostUsed)
|
|
147
|
-
return 1;
|
|
148
|
-
return a.name.localeCompare(b.name);
|
|
149
|
-
});
|
|
150
|
-
}, [countries, search, mostUsedCountries]);
|
|
151
|
-
// Close on click outside
|
|
152
|
-
React.useEffect(() => {
|
|
153
|
-
const handleClickOutside = (e) => {
|
|
154
|
-
if (containerRef.current &&
|
|
155
|
-
!containerRef.current.contains(e.target)) {
|
|
156
|
-
setOpen(false);
|
|
157
|
-
setSearch('');
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
if (open) {
|
|
161
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
162
|
-
}
|
|
163
|
-
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
164
|
-
}, [open]);
|
|
165
|
-
const handleCountrySelect = (country) => {
|
|
166
|
-
setSelectedCountry(country);
|
|
167
|
-
setOpen(false);
|
|
168
|
-
setSearch('');
|
|
169
|
-
// Update full value with new country code
|
|
170
|
-
const fullNumber = `${country.dialCode} ${phoneNumber}`.trim();
|
|
171
|
-
onChange?.(fullNumber);
|
|
172
|
-
validateNumber(phoneNumber, country.code);
|
|
173
|
-
};
|
|
174
|
-
const handlePhoneChange = (e) => {
|
|
175
|
-
const input = e.target.value;
|
|
176
|
-
// Format as user types
|
|
177
|
-
const formatter = new libphonenumber_js_1.AsYouType(selectedCountry.code);
|
|
178
|
-
const formatted = formatter.input(input);
|
|
179
|
-
// Extract just the national number part
|
|
180
|
-
const nationalNumber = formatted.replace(/^\+\d+\s*/, '');
|
|
181
|
-
setPhoneNumber(nationalNumber);
|
|
182
|
-
// Build full international number
|
|
183
|
-
const fullNumber = `${selectedCountry.dialCode} ${nationalNumber}`.trim();
|
|
184
|
-
onChange?.(fullNumber);
|
|
185
|
-
validateNumber(nationalNumber, selectedCountry.code);
|
|
186
|
-
};
|
|
187
|
-
const validateNumber = (number, countryCode) => {
|
|
188
|
-
if (!number || !onError)
|
|
189
|
-
return;
|
|
190
|
-
try {
|
|
191
|
-
const fullNumber = `${(0, libphonenumber_js_1.getCountryCallingCode)(countryCode)}${number.replace(/\D/g, '')}`;
|
|
192
|
-
const parsed = (0, libphonenumber_js_1.parsePhoneNumberFromString)(`+${fullNumber}`, countryCode);
|
|
193
|
-
onError?.(!parsed?.isValid());
|
|
194
|
-
}
|
|
195
|
-
catch {
|
|
196
|
-
onError?.(true);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
const handleTriggerClick = () => {
|
|
200
|
-
if (!disabled) {
|
|
201
|
-
setOpen(!open);
|
|
202
|
-
if (!open) {
|
|
203
|
-
setTimeout(() => searchInputRef.current?.focus(), 0);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: (0, utils_1.cn)('relative flex min-w-0', className), children: [(0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: handleTriggerClick, disabled: disabled, className: (0, utils_1.cn)('flex h-[32px] shrink-0 items-center gap-fds-xs rounded-l-fds-md border border-r-0 border-input-border bg-input px-fds-sm text-fds-base outline-none transition-[color,box-shadow]', open &&
|
|
208
|
-
'border-[#2075bd] shadow-[0_0_0_2px_var(--fds-color-primary-blue-20)]', disabled && 'cursor-not-allowed opacity-50'), children: [(0, jsx_runtime_1.jsx)("img", { src: (0, countryUtils_1.getCountryFlag)(selectedCountry.code), alt: selectedCountry.code, className: "h-4 w-4 shrink-0 rounded-full object-cover" }), (0, jsx_runtime_1.jsx)("span", { className: "text-fds-sm text-fds-gray-60", children: selectedCountry.dialCode }), (0, jsx_runtime_1.jsx)(icons_1.IconCaretDown, { size: 14, className: (0, utils_1.cn)('shrink-0 text-fds-gray-60 transition-transform', open && 'rotate-180') })] }), (0, jsx_runtime_1.jsx)("input", { type: "tel", value: phoneNumber, onChange: handlePhoneChange, placeholder: placeholder, disabled: disabled, className: (0, utils_1.cn)('h-[32px] flex-1 rounded-r-fds-md border border-input-border bg-input px-fds-sm text-fds-base outline-none transition-[color,box-shadow] placeholder:text-muted-foreground', 'focus:border-[#2075bd] focus:shadow-[0_0_0_2px_var(--fds-color-primary-blue-20)]', disabled && 'cursor-not-allowed opacity-50') }), open && ((0, jsx_runtime_1.jsxs)("div", { className: "absolute left-0 top-full z-50 mt-fds-xs w-[280px] rounded-fds-md border border-border bg-popover shadow-lg", children: [(0, jsx_runtime_1.jsx)("div", { className: "border-b border-border p-fds-xs", children: (0, jsx_runtime_1.jsx)("input", { ref: searchInputRef, 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)]" }) }), (0, jsx_runtime_1.jsx)("div", { className: "max-h-[210px] overflow-y-auto p-fds-xs", children: filteredCountries.length === 0 ? ((0, jsx_runtime_1.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) => {
|
|
209
|
-
const isSelected = country.code === selectedCountry.code;
|
|
210
|
-
const isMostUsed = mostUsedCountries.includes(country.code);
|
|
211
|
-
const isLastMostUsed = isMostUsed &&
|
|
212
|
-
!search &&
|
|
213
|
-
index === mostUsedCountries.length - 1 &&
|
|
214
|
-
filteredCountries.length > mostUsedCountries.length;
|
|
215
|
-
return ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { onClick: () => handleCountrySelect(country), className: (0, utils_1.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: [(0, jsx_runtime_1.jsx)("img", { src: (0, countryUtils_1.getCountryFlag)(country.code), alt: country.code, className: "h-6 w-6 shrink-0 rounded-full object-cover" }), (0, jsx_runtime_1.jsx)("span", { className: "flex-1 truncate text-fds-base", children: country.name }), (0, jsx_runtime_1.jsx)("span", { className: "text-fds-sm text-fds-gray-60", children: country.dialCode })] }), isLastMostUsed && ((0, jsx_runtime_1.jsx)("div", { className: "my-fds-xs h-px bg-border" }))] }, country.code));
|
|
216
|
-
})) })] }))] }));
|
|
217
|
-
};
|
|
218
|
-
exports.PhoneInput = PhoneInput;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
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
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.PopoverArrow = exports.PopoverContent = exports.PopoverTrigger = exports.Popover = void 0;
|
|
37
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
-
const React = __importStar(require("react"));
|
|
39
|
-
const PopoverPrimitive = __importStar(require("@radix-ui/react-popover"));
|
|
40
|
-
const utils_1 = require("../lib/utils");
|
|
41
|
-
const Popover = PopoverPrimitive.Root;
|
|
42
|
-
exports.Popover = Popover;
|
|
43
|
-
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
44
|
-
exports.PopoverTrigger = PopoverTrigger;
|
|
45
|
-
const PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, showArrow = false, ...props }, ref) => ((0, jsx_runtime_1.jsx)(PopoverPrimitive.Portal, { children: (0, jsx_runtime_1.jsxs)(PopoverPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, className: (0, utils_1.cn)("z-[1300] w-72 rounded-md bg-popover p-4 text-popover-foreground shadow-fds-md outline-none 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 origin-[--radix-popover-content-transform-origin]", className), ...props, children: [props.children, showArrow && ((0, jsx_runtime_1.jsx)(PopoverPrimitive.Arrow, { className: "fill-popover", width: 16, height: 8 }))] }) })));
|
|
46
|
-
exports.PopoverContent = PopoverContent;
|
|
47
|
-
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
48
|
-
const PopoverArrow = PopoverPrimitive.Arrow;
|
|
49
|
-
exports.PopoverArrow = PopoverArrow;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
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
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Progress = void 0;
|
|
37
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
-
const React = __importStar(require("react"));
|
|
39
|
-
const ProgressPrimitive = __importStar(require("@radix-ui/react-progress"));
|
|
40
|
-
const utils_1 = require("../lib/utils");
|
|
41
|
-
const Progress = React.forwardRef(({ className, value, ...props }, ref) => ((0, jsx_runtime_1.jsx)(ProgressPrimitive.Root, { ref: ref, className: (0, utils_1.cn)("relative h-4 w-full overflow-hidden rounded-full bg-secondary", className), ...props, children: (0, jsx_runtime_1.jsx)(ProgressPrimitive.Indicator, { className: "h-full w-full flex-1 bg-primary transition-all", style: { transform: `translateX(-${100 - (value || 0)}%)` } }) })));
|
|
42
|
-
exports.Progress = Progress;
|
|
43
|
-
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
})();
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.ResizablePanelGroup = exports.ResizablePanel = exports.ResizableHandle = void 0;
|
|
38
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
|
-
const lucide_react_1 = require("lucide-react");
|
|
40
|
-
const ResizablePrimitive = __importStar(require("react-resizable-panels"));
|
|
41
|
-
const utils_1 = require("../lib/utils");
|
|
42
|
-
const ResizablePanelGroup = ({ className, ...props }) => ((0, jsx_runtime_1.jsx)(ResizablePrimitive.PanelGroup, { className: (0, utils_1.cn)('flex h-full w-full data-[panel-group-direction=vertical]:flex-col', className), ...props }));
|
|
43
|
-
exports.ResizablePanelGroup = ResizablePanelGroup;
|
|
44
|
-
const ResizablePanel = ResizablePrimitive.Panel;
|
|
45
|
-
exports.ResizablePanel = ResizablePanel;
|
|
46
|
-
const ResizableHandle = ({ withHandle, className, ...props }) => ((0, jsx_runtime_1.jsx)(ResizablePrimitive.PanelResizeHandle, { className: (0, utils_1.cn)('relative flex w-px items-center justify-center bg-fds-gray-20 dark:bg-fds-gray-70 after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-fds-blue-50 focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90', className), ...props, children: withHandle && ((0, jsx_runtime_1.jsx)("div", { className: "z-10 flex h-4 w-3 items-center justify-center rounded-sm border border-fds-gray-20 bg-fds-gray-10 dark:border-fds-gray-70 dark:bg-fds-gray-80", children: (0, jsx_runtime_1.jsx)(lucide_react_1.GripVertical, { className: "h-2.5 w-2.5" }) })) }));
|
|
47
|
-
exports.ResizableHandle = ResizableHandle;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.RichTextEditor = void 0;
|
|
8
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
-
const utils_1 = require("../lib/utils");
|
|
10
|
-
const extension_bullet_list_1 = __importDefault(require("@tiptap/extension-bullet-list"));
|
|
11
|
-
const extension_list_item_1 = __importDefault(require("@tiptap/extension-list-item"));
|
|
12
|
-
const extension_ordered_list_1 = __importDefault(require("@tiptap/extension-ordered-list"));
|
|
13
|
-
const extension_link_1 = __importDefault(require("@tiptap/extension-link"));
|
|
14
|
-
const extension_underline_1 = __importDefault(require("@tiptap/extension-underline"));
|
|
15
|
-
const extension_placeholder_1 = __importDefault(require("@tiptap/extension-placeholder"));
|
|
16
|
-
const react_1 = require("@tiptap/react");
|
|
17
|
-
const starter_kit_1 = __importDefault(require("@tiptap/starter-kit"));
|
|
18
|
-
const state_1 = require("@tiptap/pm/state");
|
|
19
|
-
const lucide_react_1 = require("lucide-react");
|
|
20
|
-
const react_2 = require("react");
|
|
21
|
-
const input_1 = require("./input");
|
|
22
|
-
const button_1 = require("./button");
|
|
23
|
-
const popover_1 = require("./popover");
|
|
24
|
-
// Custom Link extension to prevent clicks
|
|
25
|
-
const createCustomLink = (onLinkClick) => {
|
|
26
|
-
return extension_link_1.default.extend({
|
|
27
|
-
addProseMirrorPlugins() {
|
|
28
|
-
return [
|
|
29
|
-
new state_1.Plugin({
|
|
30
|
-
key: new state_1.PluginKey('handleLinkClick'),
|
|
31
|
-
props: {
|
|
32
|
-
handleClick(_view, _pos, event) {
|
|
33
|
-
const link = event.target?.closest('a');
|
|
34
|
-
if (link) {
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
event.stopPropagation();
|
|
37
|
-
const href = link.getAttribute('href');
|
|
38
|
-
if (href) {
|
|
39
|
-
onLinkClick(href);
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
}),
|
|
47
|
-
];
|
|
48
|
-
},
|
|
49
|
-
}).configure({
|
|
50
|
-
openOnClick: false,
|
|
51
|
-
HTMLAttributes: {
|
|
52
|
-
class: 'text-primary underline cursor-pointer',
|
|
53
|
-
rel: 'noopener noreferrer nofollow',
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const MenuBar = ({ editor, linkUrl, setLinkUrl, linkPopoverOpen, setLinkPopoverOpen, isEditingExistingLink, setIsEditingExistingLink, handleSetLink, handleRemoveLink, }) => {
|
|
58
|
-
if (!editor)
|
|
59
|
-
return null;
|
|
60
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-fds-xs border-b border-border bg-fds-gray-10 px-fds-md py-fds-md dark:bg-card", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => editor.chain().focus().toggleBold().run(), type: "button", className: "cursor-pointer rounded p-1 hover:bg-fds-gray-20 dark:hover:bg-fds-gray-80", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Bold, { className: (0, utils_1.cn)('h-4 w-4 text-foreground', editor.isActive('bold') && 'text-primary') }) }), (0, jsx_runtime_1.jsx)("button", { onClick: () => editor.chain().focus().toggleItalic().run(), type: "button", className: "cursor-pointer rounded p-1 hover:bg-fds-gray-20 dark:hover:bg-fds-gray-80", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Italic, { className: (0, utils_1.cn)('h-4 w-4 text-foreground', editor.isActive('italic') && 'text-primary') }) }), (0, jsx_runtime_1.jsx)("button", { onClick: () => editor.chain().focus().toggleUnderline().run(), type: "button", className: "cursor-pointer rounded p-1 hover:bg-fds-gray-20 dark:hover:bg-fds-gray-80", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Underline, { className: (0, utils_1.cn)('h-4 w-4 text-foreground', editor.isActive('underline') && 'text-primary') }) }), (0, jsx_runtime_1.jsx)("div", { className: "mx-fds-xs h-4 w-px bg-fds-gray-20 dark:bg-fds-gray-80" }), (0, jsx_runtime_1.jsx)("button", { onClick: (e) => {
|
|
61
|
-
e.preventDefault();
|
|
62
|
-
editor.chain().focus().toggleBulletList().run();
|
|
63
|
-
}, type: "button", className: "cursor-pointer rounded p-1 hover:bg-fds-gray-20 dark:hover:bg-fds-gray-80", children: (0, jsx_runtime_1.jsx)(lucide_react_1.List, { className: (0, utils_1.cn)('h-4 w-4 text-foreground', editor.isActive('bulletList') && 'text-primary') }) }), (0, jsx_runtime_1.jsx)("button", { onClick: (e) => {
|
|
64
|
-
e.preventDefault();
|
|
65
|
-
editor.chain().focus().toggleOrderedList().run();
|
|
66
|
-
}, type: "button", className: "cursor-pointer rounded p-1 hover:bg-fds-gray-20 dark:hover:bg-fds-gray-80", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ListOrdered, { className: (0, utils_1.cn)('h-4 w-4 text-foreground', editor.isActive('orderedList') && 'text-primary') }) }), (0, jsx_runtime_1.jsxs)(popover_1.Popover, { open: linkPopoverOpen, onOpenChange: setLinkPopoverOpen, children: [(0, jsx_runtime_1.jsx)(popover_1.PopoverTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "cursor-pointer rounded p-1 hover:bg-fds-gray-20 dark:hover:bg-fds-gray-80", onClick: () => {
|
|
67
|
-
if (editor.isActive('link')) {
|
|
68
|
-
setLinkUrl(editor.getAttributes('link').href);
|
|
69
|
-
}
|
|
70
|
-
}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.Link, { className: (0, utils_1.cn)('h-4 w-4 text-foreground', editor.isActive('link') && 'text-primary') }) }) }), (0, jsx_runtime_1.jsx)(popover_1.PopoverContent, { className: "w-[300px]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-fds-sm", children: isEditingExistingLink ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "text-fds-sm font-fds-semibold", children: "Visit URL:" }), (0, jsx_runtime_1.jsx)("a", { href: linkUrl, target: "_blank", rel: "noopener noreferrer", className: "truncate text-fds-sm text-primary hover:underline", children: linkUrl }), (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-fds-xs", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { size: "small", onClick: () => {
|
|
71
|
-
setIsEditingExistingLink(false);
|
|
72
|
-
}, className: "flex-1", children: "Edit" }), (0, jsx_runtime_1.jsx)(button_1.Button, { size: "small", type: "text", onClick: handleRemoveLink, className: "flex-1", children: "Remove" })] })] })) : editor.isActive('link') ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "text-fds-sm font-fds-semibold", children: "Edit Link" }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: linkUrl, onChange: (e) => setLinkUrl(e.target.value), placeholder: "Enter URL", onKeyDown: (e) => {
|
|
73
|
-
if (e.key === 'Enter') {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
handleSetLink();
|
|
76
|
-
}
|
|
77
|
-
}, autoFocus: true }), (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-fds-xs", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { size: "small", onClick: handleSetLink, className: "flex-1", children: "Update" }), (0, jsx_runtime_1.jsx)(button_1.Button, { size: "small", type: "text", onClick: handleRemoveLink, className: "flex-1", children: "Remove" })] })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "text-fds-sm font-fds-semibold", children: "Add Link" }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: linkUrl, onChange: (e) => setLinkUrl(e.target.value), placeholder: "Enter URL", onKeyDown: (e) => {
|
|
78
|
-
if (e.key === 'Enter') {
|
|
79
|
-
e.preventDefault();
|
|
80
|
-
handleSetLink();
|
|
81
|
-
}
|
|
82
|
-
}, autoFocus: true }), (0, jsx_runtime_1.jsx)(button_1.Button, { size: "small", onClick: handleSetLink, children: "Add Link" })] })) }) })] })] }));
|
|
83
|
-
};
|
|
84
|
-
const RichTextEditor = ({ value = '', onChange, placeholder = 'Type your message...', className, }) => {
|
|
85
|
-
const [linkPopoverOpen, setLinkPopoverOpen] = (0, react_2.useState)(false);
|
|
86
|
-
const [linkUrl, setLinkUrl] = (0, react_2.useState)('');
|
|
87
|
-
const [isEditingExistingLink, setIsEditingExistingLink] = (0, react_2.useState)(false);
|
|
88
|
-
const handleLinkClick = (href) => {
|
|
89
|
-
setLinkUrl(href);
|
|
90
|
-
setIsEditingExistingLink(true);
|
|
91
|
-
setLinkPopoverOpen(true);
|
|
92
|
-
};
|
|
93
|
-
const CustomLink = createCustomLink(handleLinkClick);
|
|
94
|
-
const editor = (0, react_1.useEditor)({
|
|
95
|
-
immediatelyRender: false,
|
|
96
|
-
extensions: [
|
|
97
|
-
starter_kit_1.default.configure({
|
|
98
|
-
bulletList: false,
|
|
99
|
-
orderedList: false,
|
|
100
|
-
listItem: false,
|
|
101
|
-
}),
|
|
102
|
-
extension_list_item_1.default,
|
|
103
|
-
extension_bullet_list_1.default.configure({
|
|
104
|
-
HTMLAttributes: {
|
|
105
|
-
class: 'list-disc list-outside ml-4',
|
|
106
|
-
},
|
|
107
|
-
}),
|
|
108
|
-
extension_ordered_list_1.default.configure({
|
|
109
|
-
HTMLAttributes: {
|
|
110
|
-
class: 'list-decimal list-outside ml-4',
|
|
111
|
-
},
|
|
112
|
-
}),
|
|
113
|
-
extension_underline_1.default,
|
|
114
|
-
CustomLink,
|
|
115
|
-
extension_placeholder_1.default.configure({
|
|
116
|
-
placeholder,
|
|
117
|
-
}),
|
|
118
|
-
],
|
|
119
|
-
content: value,
|
|
120
|
-
onUpdate: ({ editor }) => {
|
|
121
|
-
onChange?.(editor.getHTML());
|
|
122
|
-
},
|
|
123
|
-
editorProps: {
|
|
124
|
-
attributes: {
|
|
125
|
-
class: (0, utils_1.cn)('prose prose-sm focus:outline-none min-h-[80px] px-fds-lg py-fds-sm prose-p:my-1 prose-ul:my-1 prose-ol:my-1 text-fds-sm bg-white dark:bg-black dark:text-white', className),
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
const handleSetLink = () => {
|
|
130
|
-
if (linkUrl && editor) {
|
|
131
|
-
// Ensure URL has protocol
|
|
132
|
-
let formattedUrl = linkUrl;
|
|
133
|
-
if (!/^https?:\/\//i.test(linkUrl)) {
|
|
134
|
-
formattedUrl = `https://${linkUrl}`;
|
|
135
|
-
}
|
|
136
|
-
editor.chain().focus().setLink({ href: formattedUrl }).run();
|
|
137
|
-
setLinkUrl('');
|
|
138
|
-
setIsEditingExistingLink(false);
|
|
139
|
-
setLinkPopoverOpen(false);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
const handleRemoveLink = () => {
|
|
143
|
-
if (editor) {
|
|
144
|
-
editor.chain().focus().unsetLink().run();
|
|
145
|
-
setLinkUrl('');
|
|
146
|
-
setIsEditingExistingLink(false);
|
|
147
|
-
setLinkPopoverOpen(false);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [(0, jsx_runtime_1.jsx)(MenuBar, { editor: editor, linkUrl: linkUrl, setLinkUrl: setLinkUrl, linkPopoverOpen: linkPopoverOpen, setLinkPopoverOpen: setLinkPopoverOpen, isEditingExistingLink: isEditingExistingLink, setIsEditingExistingLink: setIsEditingExistingLink, handleSetLink: handleSetLink, handleRemoveLink: handleRemoveLink }), (0, jsx_runtime_1.jsx)(react_1.EditorContent, { editor: editor, placeholder: placeholder })] }));
|
|
151
|
-
};
|
|
152
|
-
exports.RichTextEditor = RichTextEditor;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
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
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Route = void 0;
|
|
37
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
-
const React = __importStar(require("react"));
|
|
39
|
-
const utils_1 = require("../lib/utils");
|
|
40
|
-
const Route = React.forwardRef(({ className, type = 'point-to-point', start, end, ...props }, ref) => {
|
|
41
|
-
if (type === 'point-to-point') {
|
|
42
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, utils_1.cn)('flex items-center gap-fds-sm', className), ...props, children: [start, (0, jsx_runtime_1.jsxs)("div", { className: "relative flex items-center", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[5px] w-[5px] rounded-full bg-foreground" }), (0, jsx_runtime_1.jsx)("div", { className: "h-px w-[22px] bg-foreground" }), (0, jsx_runtime_1.jsx)("div", { className: "h-[5px] w-[5px] rounded-full bg-foreground" })] }), end] }));
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
});
|
|
46
|
-
exports.Route = Route;
|
|
47
|
-
Route.displayName = 'Route';
|