oneslash-design-system 1.1.6 → 1.1.8
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/components/button.tsx +3 -1
- package/components/iconButton.tsx +2 -2
- package/components/menuItem.tsx +17 -4
- package/components/modal.tsx +1 -1
- package/components/radioGroup.tsx +55 -0
- package/components/tab.tsx +3 -3
- package/package.json +1 -1
- package/{tailwind.config.ts → tailwind.config.js} +100 -11
- package/dist/components/alert.d.ts +0 -9
- package/dist/components/alert.jsx +0 -38
- package/dist/components/button.d.ts +0 -13
- package/dist/components/button.jsx +0 -141
- package/dist/components/checkBox.d.ts +0 -7
- package/dist/components/checkBox.jsx +0 -29
- package/dist/components/emptyBox.d.ts +0 -7
- package/dist/components/emptyBox.jsx +0 -17
- package/dist/components/iconButton.d.ts +0 -11
- package/dist/components/iconButton.jsx +0 -126
- package/dist/components/loadingScreen.d.ts +0 -3
- package/dist/components/loadingScreen.jsx +0 -14
- package/dist/components/menuItem.d.ts +0 -10
- package/dist/components/menuItem.jsx +0 -96
- package/dist/components/modal.d.ts +0 -11
- package/dist/components/modal.jsx +0 -49
- package/dist/components/popover.d.ts +0 -10
- package/dist/components/popover.jsx +0 -52
- package/dist/components/tab.d.ts +0 -12
- package/dist/components/tab.jsx +0 -113
- package/dist/components/tag.d.ts +0 -15
- package/dist/components/tag.jsx +0 -123
- package/dist/components/textField.d.ts +0 -20
- package/dist/components/textField.jsx +0 -55
- package/dist/components/timeStamp.d.ts +0 -7
- package/dist/components/timeStamp.jsx +0 -58
- package/dist/components/tooltip.d.ts +0 -7
- package/dist/components/tooltip.jsx +0 -41
- package/dist/components/userImage.d.ts +0 -7
- package/dist/components/userImage.jsx +0 -13
- package/dist/designTokens.d.ts +0 -354
- package/dist/designTokens.js +0 -232
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -17
- package/dist/output.css +0 -1166
- package/dist/tailwind.config.d.ts +0 -3
- package/dist/tailwind.config.js +0 -214
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
import React, { useState, useEffect, useCallback } from 'react';
|
|
39
|
-
export default function IconButton(_a) {
|
|
40
|
-
var _this = this;
|
|
41
|
-
var variant = _a.variant, color = _a.color, state = _a.state, iconName = _a.iconName, onClick = _a.onClick;
|
|
42
|
-
var _b = useState(false), isHovered = _b[0], setIsHovered = _b[1];
|
|
43
|
-
var _c = useState(null), Icon = _c[0], setIcon = _c[1];
|
|
44
|
-
// import icon
|
|
45
|
-
var loadIcon = useCallback(function (iconName) { return __awaiter(_this, void 0, void 0, function () {
|
|
46
|
-
var module_1, Icon_1, error_1;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
if (!iconName)
|
|
51
|
-
return [2 /*return*/, null];
|
|
52
|
-
_a.label = 1;
|
|
53
|
-
case 1:
|
|
54
|
-
_a.trys.push([1, 3, , 4]);
|
|
55
|
-
return [4 /*yield*/, import('@heroicons/react/24/outline')];
|
|
56
|
-
case 2:
|
|
57
|
-
module_1 = _a.sent();
|
|
58
|
-
Icon_1 = module_1[iconName];
|
|
59
|
-
return [2 /*return*/, Icon_1 || null];
|
|
60
|
-
case 3:
|
|
61
|
-
error_1 = _a.sent();
|
|
62
|
-
console.error("Failed to load icon ".concat(iconName, ":"), error_1);
|
|
63
|
-
return [2 /*return*/, null];
|
|
64
|
-
case 4: return [2 /*return*/];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}); }, []);
|
|
68
|
-
// Load icons on mount and when props change
|
|
69
|
-
useEffect(function () {
|
|
70
|
-
var fetchIcons = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
71
|
-
var _a;
|
|
72
|
-
return __generator(this, function (_b) {
|
|
73
|
-
switch (_b.label) {
|
|
74
|
-
case 0:
|
|
75
|
-
if (!(typeof iconName === 'string')) return [3 /*break*/, 2];
|
|
76
|
-
_a = setIcon;
|
|
77
|
-
return [4 /*yield*/, loadIcon(iconName)];
|
|
78
|
-
case 1:
|
|
79
|
-
_a.apply(void 0, [_b.sent()]);
|
|
80
|
-
_b.label = 2;
|
|
81
|
-
case 2: return [2 /*return*/];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}); };
|
|
85
|
-
fetchIcons();
|
|
86
|
-
}, [iconName, loadIcon]);
|
|
87
|
-
// padding, corner
|
|
88
|
-
var baseClasses = variant === 'contained'
|
|
89
|
-
? 'p-2 rounded-[8px] leading-none '
|
|
90
|
-
: 'p-2 rounded-[8px] leading-none ';
|
|
91
|
-
// bg color
|
|
92
|
-
var bgColor = variant === 'contained'
|
|
93
|
-
? color === 'primary'
|
|
94
|
-
? 'bg-light-primary-main dark:bg-dark-primary-main' // contained && primary
|
|
95
|
-
: 'bg-light-background-accent200 dark:bg-dark-background-accent200' // contained && secondary
|
|
96
|
-
: color === 'primary'
|
|
97
|
-
? ' ' // textOnly && primary
|
|
98
|
-
: ' '; // textOnly && secondary
|
|
99
|
-
// bg color hover
|
|
100
|
-
var bgColorHover = variant === 'contained'
|
|
101
|
-
? color === 'primary'
|
|
102
|
-
? 'hover:bg-light-primary-dark hover:dark:bg-dark-primary-dark' // contained && primary
|
|
103
|
-
: 'hover:bg-light-background-accent300 hover:dark:bg-dark-background-accent300' // contained && secondary
|
|
104
|
-
: color === 'primary'
|
|
105
|
-
? 'hover:bg-light-action-hover hover:dark:bg-dark-action-hover' // textOnly && primary
|
|
106
|
-
: 'hover:bg-light-action-hover hover:dark:bg-dark-action-hover'; // textOnly && secondary
|
|
107
|
-
// icon color
|
|
108
|
-
var iconColor = variant === 'contained'
|
|
109
|
-
? color === 'primary'
|
|
110
|
-
? 'text-light-primary-contrast dark:text-dark-primary-contrast' // contained && primary
|
|
111
|
-
: 'text-light-text-primary dark:text-dark-text-primary' // contained && secondary
|
|
112
|
-
: color === 'primary'
|
|
113
|
-
? ' text-light-text-primary dark:text-dark-text-primary' // textOnly && primary
|
|
114
|
-
: ' text-light-text-primary dark:text-dark-text-primary'; // textOnly && secondary
|
|
115
|
-
// state
|
|
116
|
-
var stateClasses = state === 'disabled'
|
|
117
|
-
? 'cursor-not-allowed opacity-50'
|
|
118
|
-
: state === 'selected'
|
|
119
|
-
? 'cursor-pointer ring-2 ring-offset-2 ring-blue-500'
|
|
120
|
-
: isHovered
|
|
121
|
-
? 'cursor-pointer hover:bg-opacity-75'
|
|
122
|
-
: 'cursor-pointer';
|
|
123
|
-
return (<button className={"".concat(baseClasses, " ").concat(bgColor, " ").concat(iconColor, " ").concat(bgColorHover, " ").concat(stateClasses, " transition-colors duration-300 ease-in-out")} disabled={state === 'disabled'} onMouseEnter={function () { return setIsHovered(true); }} onMouseLeave={function () { return setIsHovered(false); }} onClick={onClick}>
|
|
124
|
-
{Icon && <Icon className="size-6"/>}
|
|
125
|
-
</button>);
|
|
126
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export default function LoadingScreen() {
|
|
4
|
-
return (<div className="flex justify-center items-center h-full w-full min-h-[200px]">
|
|
5
|
-
<div className="w-12 h-12 border-4 border-t-transparent border-light-accent-main rounded-full animate-spin"></div>
|
|
6
|
-
</div>);
|
|
7
|
-
}
|
|
8
|
-
;
|
|
9
|
-
export function LoadingSmall() {
|
|
10
|
-
return (<div className="flex justify-center items-center h-[40px] w-[40px]">
|
|
11
|
-
<div className="w-[40px] h-[40px] border-4 border-t-transparent border-light-accent-main rounded-full animate-spin"></div>
|
|
12
|
-
</div>);
|
|
13
|
-
}
|
|
14
|
-
;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface MenuItemProps {
|
|
3
|
-
href?: string;
|
|
4
|
-
iconName?: string;
|
|
5
|
-
label: string;
|
|
6
|
-
isSelected?: boolean;
|
|
7
|
-
onClick: any;
|
|
8
|
-
}
|
|
9
|
-
export default function MenuItem({ href, iconName, label, isSelected, onClick, }: MenuItemProps): React.JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
import React, { useState, useEffect, useCallback } from 'react';
|
|
39
|
-
import NextLink from 'next/link';
|
|
40
|
-
export default function MenuItem(_a) {
|
|
41
|
-
var _this = this;
|
|
42
|
-
var _b = _a.href, href = _b === void 0 ? '#' : _b, iconName = _a.iconName, label = _a.label, isSelected = _a.isSelected, onClick = _a.onClick;
|
|
43
|
-
var _c = useState(null), Icon = _c[0], setIcon = _c[1];
|
|
44
|
-
// Import icon dynamically
|
|
45
|
-
var loadIcon = useCallback(function (iconName) { return __awaiter(_this, void 0, void 0, function () {
|
|
46
|
-
var module_1, IconComponent, error_1;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
if (!iconName)
|
|
51
|
-
return [2 /*return*/, null];
|
|
52
|
-
_a.label = 1;
|
|
53
|
-
case 1:
|
|
54
|
-
_a.trys.push([1, 3, , 4]);
|
|
55
|
-
return [4 /*yield*/, import('@heroicons/react/24/outline')];
|
|
56
|
-
case 2:
|
|
57
|
-
module_1 = _a.sent();
|
|
58
|
-
IconComponent = module_1[iconName];
|
|
59
|
-
return [2 /*return*/, IconComponent || null];
|
|
60
|
-
case 3:
|
|
61
|
-
error_1 = _a.sent();
|
|
62
|
-
console.error("Failed to load icon ".concat(iconName, ":"), error_1);
|
|
63
|
-
return [2 /*return*/, null];
|
|
64
|
-
case 4: return [2 /*return*/];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}); }, []);
|
|
68
|
-
useEffect(function () {
|
|
69
|
-
var fetchIcon = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
70
|
-
var _a;
|
|
71
|
-
return __generator(this, function (_b) {
|
|
72
|
-
switch (_b.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
if (!iconName) return [3 /*break*/, 2];
|
|
75
|
-
_a = setIcon;
|
|
76
|
-
return [4 /*yield*/, loadIcon(iconName)];
|
|
77
|
-
case 1:
|
|
78
|
-
_a.apply(void 0, [_b.sent()]);
|
|
79
|
-
_b.label = 2;
|
|
80
|
-
case 2: return [2 /*return*/];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}); };
|
|
84
|
-
fetchIcon();
|
|
85
|
-
}, [iconName, loadIcon]);
|
|
86
|
-
return (<NextLink href={href}>
|
|
87
|
-
<div className={"\n flex items-center space-x-2 p-2 rounded-[8px] cursor-pointer justify-start\n ".concat(isSelected
|
|
88
|
-
? 'bg-light-action-selected dark:bg-dark-action-selected'
|
|
89
|
-
: 'hover:bg-light-background-accent100 hover:dark:bg-dark-background-accent100', "\n ")} style={{ width: '100%' }} onClick={onClick}>
|
|
90
|
-
{Icon && <Icon className="w-6 h-6"/>}
|
|
91
|
-
<span className="whitespace-nowrap text-body1 px-2">
|
|
92
|
-
{label}
|
|
93
|
-
</span>
|
|
94
|
-
</div>
|
|
95
|
-
</NextLink>);
|
|
96
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface ModalProps {
|
|
3
|
-
isOpen: boolean;
|
|
4
|
-
title?: string;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
onClose: () => void;
|
|
7
|
-
actions?: React.ReactNode;
|
|
8
|
-
size?: 'medium' | 'large';
|
|
9
|
-
}
|
|
10
|
-
export default function Modal({ isOpen, title, children, onClose, actions, size, }: ModalProps): React.JSX.Element | null;
|
|
11
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
3
|
-
export default function Modal(_a) {
|
|
4
|
-
var isOpen = _a.isOpen, title = _a.title, children = _a.children, onClose = _a.onClose, actions = _a.actions, _b = _a.size, size = _b === void 0 ? 'medium' : _b;
|
|
5
|
-
if (!isOpen)
|
|
6
|
-
return null;
|
|
7
|
-
// close modal by clicking elsewhere
|
|
8
|
-
var handleOverlayClick = function (e) {
|
|
9
|
-
if (e.target === e.currentTarget) {
|
|
10
|
-
onClose();
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
// close modal by esc keypress
|
|
14
|
-
useEffect(function () {
|
|
15
|
-
var handleKeyDown = function (e) {
|
|
16
|
-
if (e.key === 'Escape') {
|
|
17
|
-
onClose();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
window.addEventListener('keydown', handleKeyDown);
|
|
21
|
-
return function () {
|
|
22
|
-
window.removeEventListener('keydown', handleKeyDown);
|
|
23
|
-
};
|
|
24
|
-
}, [onClose]);
|
|
25
|
-
// Determine width based on size prop
|
|
26
|
-
var modalWidth = size === 'large' ? 'w-[1200px]' : 'w-[600px]';
|
|
27
|
-
var maxWidth = size === 'large' ? '1200px' : '600px';
|
|
28
|
-
return (<div className="fixed inset-[-32px] bg-black bg-opacity-50 flex items-center justify-center z-50" onClick={handleOverlayClick} role="dialog" aria-labelledby="modal-title" aria-modal="true" tabIndex={-1}>
|
|
29
|
-
<div className={"flex flex-col bg-light-background-default dark:bg-dark-background-default p-6 rounded-[8px] space-y-4 ".concat(modalWidth)} style={{
|
|
30
|
-
maxWidth: maxWidth,
|
|
31
|
-
width: 'calc(100vw - 64px)',
|
|
32
|
-
maxHeight: '800px',
|
|
33
|
-
height: 'auto',
|
|
34
|
-
overflowY: 'auto',
|
|
35
|
-
}}>
|
|
36
|
-
{title && (<h2 id="modal-title" className="text-h6">
|
|
37
|
-
{title}
|
|
38
|
-
</h2>)}
|
|
39
|
-
<div className="text-body1">
|
|
40
|
-
{children}
|
|
41
|
-
</div>
|
|
42
|
-
{actions && (<div className='pt-6 border-t border-light-misc-divider dark:border-dark-misc-divider'>
|
|
43
|
-
<div className="flex justify-between">
|
|
44
|
-
{actions}
|
|
45
|
-
</div>
|
|
46
|
-
</div>)}
|
|
47
|
-
</div>
|
|
48
|
-
</div>);
|
|
49
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface PopoverProps {
|
|
3
|
-
id?: string;
|
|
4
|
-
anchorEl?: HTMLElement | null;
|
|
5
|
-
open: boolean;
|
|
6
|
-
onClose: () => void;
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
}
|
|
9
|
-
export default function Popover({ id, anchorEl, open, onClose, children, }: PopoverProps): React.ReactPortal | null;
|
|
10
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
import React, { useState, useEffect } from 'react';
|
|
14
|
-
import { createPortal } from 'react-dom';
|
|
15
|
-
import { usePopper } from 'react-popper';
|
|
16
|
-
export default function Popover(_a) {
|
|
17
|
-
var id = _a.id, anchorEl = _a.anchorEl, open = _a.open, onClose = _a.onClose, children = _a.children;
|
|
18
|
-
var _b = useState(null), popoverElement = _b[0], setPopoverElement = _b[1];
|
|
19
|
-
var _c = useState(false), hasMounted = _c[0], setHasMounted = _c[1];
|
|
20
|
-
// Initialize Popper.js
|
|
21
|
-
var _d = usePopper(anchorEl, popoverElement, {
|
|
22
|
-
placement: 'bottom-start', // Default placement, can be customized
|
|
23
|
-
modifiers: [
|
|
24
|
-
{ name: 'offset', options: { offset: [0, 8] } }, // Offset for spacing between anchor and popover
|
|
25
|
-
],
|
|
26
|
-
}), styles = _d.styles, attributes = _d.attributes;
|
|
27
|
-
// Handle outside clicks to close the popover
|
|
28
|
-
useEffect(function () {
|
|
29
|
-
var handleClickOutside = function (event) {
|
|
30
|
-
if (popoverElement && !popoverElement.contains(event.target) && anchorEl) {
|
|
31
|
-
onClose();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
if (open) {
|
|
35
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
36
|
-
}
|
|
37
|
-
return function () {
|
|
38
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
39
|
-
};
|
|
40
|
-
}, [open, anchorEl, popoverElement, onClose]);
|
|
41
|
-
// Ensure popover is only rendered after the component mounts
|
|
42
|
-
useEffect(function () {
|
|
43
|
-
setHasMounted(true);
|
|
44
|
-
}, []);
|
|
45
|
-
if (!open || !hasMounted || !anchorEl)
|
|
46
|
-
return null;
|
|
47
|
-
// Render popover in a portal to prevent layout shifts and positioning issues
|
|
48
|
-
return createPortal(<div id={id} ref={setPopoverElement} style={__assign(__assign({}, styles.popper), { display: open ? 'block' : 'none', zIndex: 10000 })} {...attributes.popper} className="bg-light-background-accent100 dark:bg-dark-background-accent100 rounded-[8px] shadow-lg p-2" role="dialog">
|
|
49
|
-
{children}
|
|
50
|
-
</div>, document.body // Mounting the popover in the document body for isolation
|
|
51
|
-
);
|
|
52
|
-
}
|
package/dist/components/tab.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
type TabProps = {
|
|
3
|
-
label: string;
|
|
4
|
-
href?: string;
|
|
5
|
-
isSelected: boolean;
|
|
6
|
-
onClickTab: () => void;
|
|
7
|
-
onClickActionIcon?: any;
|
|
8
|
-
decoIcon?: string;
|
|
9
|
-
actionIcon?: string;
|
|
10
|
-
};
|
|
11
|
-
export default function Tab({ label, href, isSelected, onClickTab, onClickActionIcon, decoIcon, actionIcon }: TabProps): React.JSX.Element;
|
|
12
|
-
export {};
|
package/dist/components/tab.jsx
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
import React, { useState, useEffect, useCallback } from 'react';
|
|
39
|
-
import { useRouter, usePathname } from 'next/navigation';
|
|
40
|
-
export default function Tab(_a) {
|
|
41
|
-
var _this = this;
|
|
42
|
-
var label = _a.label, href = _a.href, isSelected = _a.isSelected, onClickTab = _a.onClickTab, onClickActionIcon = _a.onClickActionIcon, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon;
|
|
43
|
-
var router = useRouter();
|
|
44
|
-
var pathname = usePathname();
|
|
45
|
-
var _b = useState(null), IconLeft = _b[0], setIconLeft = _b[1];
|
|
46
|
-
var _c = useState(null), IconRight = _c[0], setIconRight = _c[1];
|
|
47
|
-
// Load icon dynamically
|
|
48
|
-
var loadIcon = useCallback(function (iconName) { return __awaiter(_this, void 0, void 0, function () {
|
|
49
|
-
var module_1, Icon, error_1;
|
|
50
|
-
return __generator(this, function (_a) {
|
|
51
|
-
switch (_a.label) {
|
|
52
|
-
case 0:
|
|
53
|
-
if (!iconName)
|
|
54
|
-
return [2 /*return*/, null];
|
|
55
|
-
_a.label = 1;
|
|
56
|
-
case 1:
|
|
57
|
-
_a.trys.push([1, 3, , 4]);
|
|
58
|
-
return [4 /*yield*/, import('@heroicons/react/24/outline')];
|
|
59
|
-
case 2:
|
|
60
|
-
module_1 = _a.sent();
|
|
61
|
-
Icon = module_1[iconName];
|
|
62
|
-
return [2 /*return*/, Icon || null];
|
|
63
|
-
case 3:
|
|
64
|
-
error_1 = _a.sent();
|
|
65
|
-
console.error("Failed to load icon ".concat(iconName, ":"), error_1);
|
|
66
|
-
return [2 /*return*/, null];
|
|
67
|
-
case 4: return [2 /*return*/];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}); }, []);
|
|
71
|
-
useEffect(function () {
|
|
72
|
-
var fetchIcons = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
73
|
-
var _a, _b;
|
|
74
|
-
return __generator(this, function (_c) {
|
|
75
|
-
switch (_c.label) {
|
|
76
|
-
case 0:
|
|
77
|
-
if (!decoIcon) return [3 /*break*/, 2];
|
|
78
|
-
_a = setIconLeft;
|
|
79
|
-
return [4 /*yield*/, loadIcon(decoIcon)];
|
|
80
|
-
case 1:
|
|
81
|
-
_a.apply(void 0, [_c.sent()]);
|
|
82
|
-
_c.label = 2;
|
|
83
|
-
case 2:
|
|
84
|
-
if (!actionIcon) return [3 /*break*/, 4];
|
|
85
|
-
_b = setIconRight;
|
|
86
|
-
return [4 /*yield*/, loadIcon(actionIcon)];
|
|
87
|
-
case 3:
|
|
88
|
-
_b.apply(void 0, [_c.sent()]);
|
|
89
|
-
_c.label = 4;
|
|
90
|
-
case 4: return [2 /*return*/];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}); };
|
|
94
|
-
fetchIcons();
|
|
95
|
-
}, [decoIcon, actionIcon, loadIcon]);
|
|
96
|
-
var handleClick = function () {
|
|
97
|
-
onClickTab();
|
|
98
|
-
if (href) {
|
|
99
|
-
router.push(href);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
return (<div className={"\n flex items-center space-x-2 p-2 rounded-[8px] cursor-pointer justify-start\n ".concat(isSelected
|
|
103
|
-
? 'bg-light-primary-main dark:bg-dark-primary-main text-light-text-contrast dark:text-dark-text-contrast'
|
|
104
|
-
: 'bg-light-action-selected dark:bg-dark-action-selected hover:bg-light-background-default dark:hover:bg-dark-action-hover', "\n ")} onClick={handleClick}>
|
|
105
|
-
{IconLeft && <IconLeft className="w-5 h-5"/>}
|
|
106
|
-
<span className="whitespace-nowrap text-body1 px-2">
|
|
107
|
-
{label}
|
|
108
|
-
</span>
|
|
109
|
-
{IconRight && (<div onClick={onClickActionIcon} className="cursor-pointer">
|
|
110
|
-
<IconRight className="w-5 h-5"/>
|
|
111
|
-
</div>)}
|
|
112
|
-
</div>);
|
|
113
|
-
}
|
package/dist/components/tag.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import * as HeroIcons from '@heroicons/react/24/outline';
|
|
3
|
-
interface TagProps {
|
|
4
|
-
key?: any;
|
|
5
|
-
variant: "contained" | "textOnly";
|
|
6
|
-
size: "medium" | "small";
|
|
7
|
-
state?: "enabled" | "selected";
|
|
8
|
-
label: any;
|
|
9
|
-
iconName?: keyof typeof HeroIcons;
|
|
10
|
-
isDeletable?: keyof typeof HeroIcons;
|
|
11
|
-
onClick?: any;
|
|
12
|
-
color?: 'default' | 'info';
|
|
13
|
-
}
|
|
14
|
-
export default function Tag({ key, variant, size, state, label, iconName, isDeletable, onClick, color, }: TagProps): React.JSX.Element;
|
|
15
|
-
export {};
|
package/dist/components/tag.jsx
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
import React, { useState, useEffect, useCallback } from 'react';
|
|
39
|
-
export default function Tag(_a) {
|
|
40
|
-
var _this = this;
|
|
41
|
-
var key = _a.key, variant = _a.variant, size = _a.size, state = _a.state, label = _a.label, iconName = _a.iconName, isDeletable = _a.isDeletable, onClick = _a.onClick, _b = _a.color, color = _b === void 0 ? 'default' : _b;
|
|
42
|
-
var _c = useState(false), isHovered = _c[0], setIsHovered = _c[1];
|
|
43
|
-
var _d = useState(null), Icon = _d[0], setIcon = _d[1];
|
|
44
|
-
var _e = useState(null), DeleteIcon = _e[0], setDeleteIcon = _e[1];
|
|
45
|
-
var loadIcon = useCallback(function (iconName) { return __awaiter(_this, void 0, void 0, function () {
|
|
46
|
-
var module_1, Icon_1, error_1;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
if (!iconName)
|
|
51
|
-
return [2 /*return*/, null];
|
|
52
|
-
_a.label = 1;
|
|
53
|
-
case 1:
|
|
54
|
-
_a.trys.push([1, 3, , 4]);
|
|
55
|
-
return [4 /*yield*/, import('@heroicons/react/24/outline')];
|
|
56
|
-
case 2:
|
|
57
|
-
module_1 = _a.sent();
|
|
58
|
-
Icon_1 = module_1[iconName];
|
|
59
|
-
return [2 /*return*/, Icon_1 || null];
|
|
60
|
-
case 3:
|
|
61
|
-
error_1 = _a.sent();
|
|
62
|
-
console.error("Failed to load icon ".concat(iconName, ":"), error_1);
|
|
63
|
-
return [2 /*return*/, null];
|
|
64
|
-
case 4: return [2 /*return*/];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}); }, []);
|
|
68
|
-
useEffect(function () {
|
|
69
|
-
var fetchIcons = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
70
|
-
var _a, _b;
|
|
71
|
-
return __generator(this, function (_c) {
|
|
72
|
-
switch (_c.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
if (!(typeof iconName === 'string')) return [3 /*break*/, 2];
|
|
75
|
-
_a = setIcon;
|
|
76
|
-
return [4 /*yield*/, loadIcon(iconName)];
|
|
77
|
-
case 1:
|
|
78
|
-
_a.apply(void 0, [_c.sent()]);
|
|
79
|
-
_c.label = 2;
|
|
80
|
-
case 2:
|
|
81
|
-
if (!(typeof isDeletable === 'string')) return [3 /*break*/, 4];
|
|
82
|
-
_b = setDeleteIcon;
|
|
83
|
-
return [4 /*yield*/, loadIcon(isDeletable)];
|
|
84
|
-
case 3:
|
|
85
|
-
_b.apply(void 0, [_c.sent()]);
|
|
86
|
-
_c.label = 4;
|
|
87
|
-
case 4: return [2 /*return*/];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}); };
|
|
91
|
-
fetchIcons();
|
|
92
|
-
}, [iconName, isDeletable, loadIcon]);
|
|
93
|
-
// size and padding
|
|
94
|
-
var sizeClasses = size === 'medium' ? 'text-body2 px-2 py-1' : 'text-caption px-2 py-[3px]';
|
|
95
|
-
// bg color
|
|
96
|
-
var bgClasses = variant === 'contained'
|
|
97
|
-
? (color === 'info'
|
|
98
|
-
? 'bg-light-info-main dark:bg-dark-info-main' // info
|
|
99
|
-
: 'bg-light-background-accent200 dark:bg-dark-background-accent200') // default
|
|
100
|
-
: ''; // textOnly
|
|
101
|
-
// font color
|
|
102
|
-
var fontClasses = variant === 'textOnly'
|
|
103
|
-
? (color === 'info'
|
|
104
|
-
? 'text-light-info-main dark:text-dark-info-main' // info
|
|
105
|
-
: 'text-light-text-primary dark:text-dark-text-primary') // default
|
|
106
|
-
: 'text-light-text-primary dark:text-dark-text-primary'; // contained
|
|
107
|
-
// state
|
|
108
|
-
var stateClasses = state === 'selected'
|
|
109
|
-
? 'bg-light-accent-main dark:bg-dark-accent-main text-white'
|
|
110
|
-
: 'cursor-pointer';
|
|
111
|
-
// hover
|
|
112
|
-
var hoverClasses = isHovered ? (variant === 'contained' ? 'hover:bg-dark-background-accent300' : '') : '';
|
|
113
|
-
return (<div className={"flex items-center space-x-1 rounded-full \n ".concat(sizeClasses, " ").concat(bgClasses, " ").concat(fontClasses, " ").concat(stateClasses, " ").concat(hoverClasses, " \n transition-colors duration-300 ease-in-out")} onMouseEnter={function () { return setIsHovered(true); }} onMouseLeave={function () { return setIsHovered(false); }} onClick={onClick}>
|
|
114
|
-
{Icon && <Icon className="w-4 h-4"/>}
|
|
115
|
-
<span>{label}</span>
|
|
116
|
-
{isDeletable && (<button className="ml-2 text-red-500" onClick={function (e) {
|
|
117
|
-
e.stopPropagation();
|
|
118
|
-
// Handle delete action
|
|
119
|
-
}}>
|
|
120
|
-
{DeleteIcon && <DeleteIcon className="w-4 h-4"/>}
|
|
121
|
-
</button>)}
|
|
122
|
-
</div>);
|
|
123
|
-
}
|