oneslash-design-system 1.1.10 → 1.1.11
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 -23
- package/components/iconButton.tsx +2 -2
- package/components/menuItem.tsx +0 -1
- package/components/modal.tsx +14 -17
- package/components/popover.tsx +1 -5
- package/components/tab.tsx +2 -2
- package/dist/components/alert.d.ts +9 -0
- package/dist/components/alert.jsx +38 -0
- package/dist/components/button.d.ts +13 -0
- package/dist/components/button.jsx +141 -0
- package/dist/components/checkBox.d.ts +7 -0
- package/dist/components/checkBox.jsx +29 -0
- package/dist/components/emptyBox.d.ts +7 -0
- package/dist/components/emptyBox.jsx +17 -0
- package/dist/components/iconButton.d.ts +11 -0
- package/dist/components/iconButton.jsx +126 -0
- package/dist/components/loadingScreen.d.ts +3 -0
- package/dist/components/loadingScreen.jsx +14 -0
- package/dist/components/menuItem.d.ts +10 -0
- package/dist/components/menuItem.jsx +99 -0
- package/dist/components/modal.d.ts +11 -0
- package/dist/components/modal.jsx +47 -0
- package/dist/components/popover.d.ts +10 -0
- package/dist/components/popover.jsx +52 -0
- package/dist/components/radioGroup.d.ts +13 -0
- package/dist/components/radioGroup.jsx +17 -0
- package/dist/components/tab.d.ts +12 -0
- package/dist/components/tab.jsx +113 -0
- package/dist/components/tag.d.ts +15 -0
- package/dist/components/tag.jsx +123 -0
- package/dist/components/textField.d.ts +20 -0
- package/dist/components/textField.jsx +55 -0
- package/dist/components/timeStamp.d.ts +7 -0
- package/dist/components/timeStamp.jsx +58 -0
- package/dist/components/tooltip.d.ts +7 -0
- package/dist/components/tooltip.jsx +41 -0
- package/dist/components/userImage.d.ts +7 -0
- package/dist/components/userImage.jsx +13 -0
- package/dist/designTokens.d.ts +354 -0
- package/dist/designTokens.js +232 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/dist/output.css +1147 -0
- package/dist/tailwind.config.d.ts +3 -0
- package/dist/tailwind.config.js +202 -0
- package/package.json +1 -1
- package/{tailwind.config.js → tailwind.config.ts} +7 -99
|
@@ -0,0 +1,99 @@
|
|
|
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-background-accent200 dark:bg-dark-background-accent200 hover:bg-light-background-accent300 dark:hover:bg-dark-background-accent300'
|
|
89
|
+
: 'hover:bg-light-background-accent100 hover:dark:bg-dark-background-accent100', "\n ")} style={{ width: '100%' }} onClick={onClick}>
|
|
90
|
+
{/* render userImage. render dynamic icon if userImage is not available */}
|
|
91
|
+
{userImgUrl || userHandle ? (<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl || ''}/>) : (IconLeft && <IconLeft className="w-6 h-6"/>)}
|
|
92
|
+
|
|
93
|
+
{/* label */}
|
|
94
|
+
<span className="whitespace-nowrap text-body1 px-2 text-light-text-primary dark:text-dark-text-primary">
|
|
95
|
+
{label}
|
|
96
|
+
</span>
|
|
97
|
+
</div>
|
|
98
|
+
</NextLink>);
|
|
99
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,47 @@
|
|
|
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={"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 space-y-4">
|
|
40
|
+
{children}
|
|
41
|
+
</div>
|
|
42
|
+
{actions && (<div className="flex justify-between">
|
|
43
|
+
{actions}
|
|
44
|
+
</div>)}
|
|
45
|
+
</div>
|
|
46
|
+
</div>);
|
|
47
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,52 @@
|
|
|
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' })} {...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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface RadioOption {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
interface RadioGroupProps {
|
|
7
|
+
options: RadioOption[];
|
|
8
|
+
selectedValue: string;
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
direction?: 'horizontal' | 'vertical';
|
|
11
|
+
}
|
|
12
|
+
export default function RadioGroup({ options, selectedValue, onChange, direction, }: RadioGroupProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export default function RadioGroup(_a) {
|
|
4
|
+
var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b;
|
|
5
|
+
return (<div className={"flex ".concat(direction === 'horizontal' ? 'space-x-4' : 'flex-col space-y-2')}>
|
|
6
|
+
{options.map(function (option) { return (<label key={option.value} className="flex items-center cursor-pointer" onClick={function () { return onChange(option.value); }}>
|
|
7
|
+
{/* outer circle */}
|
|
8
|
+
<div className={"relative flex justify-center items-center w-4 h-4 rounded-full border-2\n ".concat(selectedValue === option.value
|
|
9
|
+
? 'border-light-text-primary dark:border-dark-text-primary'
|
|
10
|
+
: 'border-light-text-secondary dark:border-dark-text-secondary', "\n ")}>
|
|
11
|
+
{/* Inner circle */}
|
|
12
|
+
{selectedValue === option.value && (<div className='absolute w-2 h-2 rounded-full bg-light-text-primary dark:bg-dark-text-primary'/>)}
|
|
13
|
+
</div>
|
|
14
|
+
<span className="ml-2 text-body1 text-light-text-primary dark:text-dark-text-primary">{option.label}</span>
|
|
15
|
+
</label>); })}
|
|
16
|
+
</div>);
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,113 @@
|
|
|
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-1 p-1 rounded-[8px] cursor-pointer justify-start \n ".concat(isSelected
|
|
103
|
+
? 'bg-light-primary-dark dark:bg-dark-primary-dark text-light-text-contrast dark:text-dark-text-contrast'
|
|
104
|
+
: 'bg-transparent dark:bg-transparent hover:bg-light-background-accent200 dark:hover:bg-dark-background-accent200', "\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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TextFieldProps {
|
|
3
|
+
id: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
value: string;
|
|
6
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
7
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
8
|
+
onFocus?: (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
9
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
10
|
+
autoFocus?: boolean;
|
|
11
|
+
iconLeft?: React.ReactNode;
|
|
12
|
+
iconRight?: React.ReactNode | React.ComponentType<any>;
|
|
13
|
+
multiline?: boolean;
|
|
14
|
+
maxRows?: number;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
error?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export default function TextField({ id, label, value, onChange, onBlur, onFocus, onKeyDown, autoFocus, // Accept the autoFocus prop with default value
|
|
19
|
+
iconLeft, iconRight, multiline, maxRows, disabled, error, }: TextFieldProps): React.JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
export default function TextField(_a) {
|
|
4
|
+
var id = _a.id, label = _a.label, value = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, _b = _a.autoFocus, autoFocus = _b === void 0 ? false : _b, // Accept the autoFocus prop with default value
|
|
5
|
+
iconLeft = _a.iconLeft, iconRight = _a.iconRight, _c = _a.multiline, multiline = _c === void 0 ? false : _c, _d = _a.maxRows, maxRows = _d === void 0 ? 6 : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.error, error = _f === void 0 ? false : _f;
|
|
6
|
+
var _g = useState(false), isFocused = _g[0], setIsFocused = _g[1];
|
|
7
|
+
var baseClasses = 'w-full border rounded-[8px] p-2';
|
|
8
|
+
var bgColor = 'bg-light-background-default dark:bg-dark-background-default transition-colors duration-300 ease-in-out';
|
|
9
|
+
var borderColor = 'border-light-outlinedBorder-active dark:border-dark-outlinedBorder-active';
|
|
10
|
+
var containerClasses = "\n ".concat(bgColor, "\n ").concat(borderColor, "\n ").concat(baseClasses, "\n ").concat(disabled ? 'bg-gray-200 cursor-not-allowed' : '', "\n ").concat(error ? 'border-red-500 focus:ring-red-500' : '', "\n ").concat(isFocused ? 'focus:border-light-accent-main focus:dark:border-dark-accent-main outline-none' : '', "\n ").concat(!disabled && !error ? 'hover:border-light-outlinedBorder-hover' : '', "\n border-gray-300\n ");
|
|
11
|
+
var renderIconRight = function () {
|
|
12
|
+
if (React.isValidElement(iconRight)) {
|
|
13
|
+
return iconRight;
|
|
14
|
+
}
|
|
15
|
+
if (typeof iconRight === 'function') {
|
|
16
|
+
return React.createElement(iconRight);
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
return (<div className="flex flex-col w-full">
|
|
21
|
+
{label && (<label htmlFor={id} className="mb-1 text-body2 text-light-text-secondary dark:text-dark-text-secondary">
|
|
22
|
+
{label}
|
|
23
|
+
</label>)}
|
|
24
|
+
<div className="relative">
|
|
25
|
+
{iconLeft && (<span className="absolute inset-y-0 left-0 pl-3 flex items-center">
|
|
26
|
+
{iconLeft}
|
|
27
|
+
</span>)}
|
|
28
|
+
{iconRight && (<span className="absolute inset-y-0 right-0 pr-3 flex items-center">
|
|
29
|
+
{renderIconRight()}
|
|
30
|
+
</span>)}
|
|
31
|
+
{multiline ? (<textarea id={id} rows={maxRows} className={containerClasses} value={value} onChange={onChange} onFocus={function (e) {
|
|
32
|
+
setIsFocused(true);
|
|
33
|
+
if (onFocus)
|
|
34
|
+
onFocus(e);
|
|
35
|
+
}} onBlur={function (e) {
|
|
36
|
+
setIsFocused(false);
|
|
37
|
+
if (onBlur)
|
|
38
|
+
onBlur(e);
|
|
39
|
+
}} onKeyDown={onKeyDown} autoFocus={autoFocus} // Pass autoFocus to textarea
|
|
40
|
+
disabled={disabled}/>) : (<input id={id} type="text" className={containerClasses} value={value} onChange={onChange} onFocus={function (e) {
|
|
41
|
+
setIsFocused(true);
|
|
42
|
+
if (onFocus)
|
|
43
|
+
onFocus(e);
|
|
44
|
+
}} onBlur={function (e) {
|
|
45
|
+
setIsFocused(false);
|
|
46
|
+
if (onBlur)
|
|
47
|
+
onBlur(e);
|
|
48
|
+
}} onKeyDown={onKeyDown} autoFocus={autoFocus} // Pass autoFocus to input
|
|
49
|
+
disabled={disabled}/>)}
|
|
50
|
+
</div>
|
|
51
|
+
{error && (<p className="mt-1 text-light-error-main text-body2">
|
|
52
|
+
This field is required
|
|
53
|
+
</p>)}
|
|
54
|
+
</div>);
|
|
55
|
+
}
|