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
package/components/button.tsx
CHANGED
|
@@ -113,7 +113,8 @@ export default function Button({
|
|
|
113
113
|
onMouseLeave={() => { if (state !== 'disabled') setIsHovered(false); }}
|
|
114
114
|
onClick={onClickButton} // Button click action
|
|
115
115
|
>
|
|
116
|
-
{/*
|
|
116
|
+
{/* conditionally render left section */}
|
|
117
|
+
{(IconLeft || userImgUrl || userHandle) && (
|
|
117
118
|
<div className="flex items-center space-x-2">
|
|
118
119
|
{/* Render dynamic icon if available */}
|
|
119
120
|
{IconLeft && (
|
|
@@ -125,6 +126,7 @@ export default function Button({
|
|
|
125
126
|
<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl} />
|
|
126
127
|
)}
|
|
127
128
|
</div>
|
|
129
|
+
)}
|
|
128
130
|
|
|
129
131
|
{/* label */}
|
|
130
132
|
<div className="flex-1 whitespace-nowrap overflow-hidden truncate px-2 text-left">
|
|
@@ -49,8 +49,8 @@ export default function IconButton({
|
|
|
49
49
|
|
|
50
50
|
// padding, corner
|
|
51
51
|
const baseClasses = variant === 'contained'
|
|
52
|
-
? 'p-
|
|
53
|
-
: 'p-
|
|
52
|
+
? 'p-1 rounded-[8px] leading-none '
|
|
53
|
+
: 'p-1 rounded-[8px] leading-none ';
|
|
54
54
|
|
|
55
55
|
// bg color
|
|
56
56
|
const bgColor = variant === 'contained'
|
package/components/menuItem.tsx
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { useState, useEffect, useCallback, SVGProps } from 'react';
|
|
3
3
|
import NextLink from 'next/link';
|
|
4
|
+
import UserImage from './userImage';
|
|
4
5
|
|
|
5
6
|
type IconType = (props: SVGProps<SVGSVGElement>) => JSX.Element;
|
|
6
7
|
|
|
7
8
|
interface MenuItemProps {
|
|
8
9
|
href?: string;
|
|
9
10
|
iconName?: string;
|
|
11
|
+
userHandle?: string;
|
|
12
|
+
userImgUrl?: string;
|
|
10
13
|
label: string;
|
|
11
14
|
isSelected?: boolean;
|
|
12
15
|
onClick: any;
|
|
@@ -14,13 +17,15 @@ interface MenuItemProps {
|
|
|
14
17
|
|
|
15
18
|
export default function MenuItem({
|
|
16
19
|
href = '#',
|
|
17
|
-
iconName,
|
|
20
|
+
iconName,
|
|
21
|
+
userHandle,
|
|
22
|
+
userImgUrl,
|
|
18
23
|
label,
|
|
19
24
|
isSelected,
|
|
20
25
|
onClick, }
|
|
21
26
|
: MenuItemProps) {
|
|
22
27
|
|
|
23
|
-
const [
|
|
28
|
+
const [IconLeft, setIconLeft] = useState<IconType | null>(null);
|
|
24
29
|
|
|
25
30
|
// Import icon dynamically
|
|
26
31
|
const loadIcon = useCallback(async (iconName?: string) => {
|
|
@@ -38,7 +43,7 @@ export default function MenuItem({
|
|
|
38
43
|
useEffect(() => {
|
|
39
44
|
const fetchIcon = async () => {
|
|
40
45
|
if (iconName) {
|
|
41
|
-
|
|
46
|
+
setIconLeft(await loadIcon(iconName));
|
|
42
47
|
}
|
|
43
48
|
};
|
|
44
49
|
fetchIcon();
|
|
@@ -57,10 +62,18 @@ export default function MenuItem({
|
|
|
57
62
|
style={{ width: '100%' }}
|
|
58
63
|
onClick={onClick}
|
|
59
64
|
>
|
|
60
|
-
{
|
|
65
|
+
{/* render userImage. render dynamic icon if userImage is not available */}
|
|
66
|
+
{userImgUrl || userHandle ? (
|
|
67
|
+
<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl || ''} />
|
|
68
|
+
) : (
|
|
69
|
+
IconLeft && <IconLeft className="w-6 h-6" />
|
|
70
|
+
)}
|
|
71
|
+
|
|
72
|
+
{/* label */}
|
|
61
73
|
<span className="whitespace-nowrap text-body1 px-2">
|
|
62
74
|
{label}
|
|
63
75
|
</span>
|
|
76
|
+
|
|
64
77
|
</div>
|
|
65
78
|
</NextLink>
|
|
66
79
|
);
|
package/components/modal.tsx
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
interface RadioOption {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface RadioGroupProps {
|
|
10
|
+
options: RadioOption[];
|
|
11
|
+
selectedValue: string;
|
|
12
|
+
onChange: (value: string) => void;
|
|
13
|
+
direction?: 'horizontal' | 'vertical';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default function RadioGroup({
|
|
17
|
+
options,
|
|
18
|
+
selectedValue,
|
|
19
|
+
onChange,
|
|
20
|
+
direction = 'vertical',
|
|
21
|
+
}: RadioGroupProps) {
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
className={`flex ${ direction === 'horizontal' ? 'space-x-4' : 'flex-col space-y-2' }`}
|
|
25
|
+
>
|
|
26
|
+
{options.map((option) => (
|
|
27
|
+
<label
|
|
28
|
+
key={option.value}
|
|
29
|
+
className="flex items-center cursor-pointer"
|
|
30
|
+
onClick={() => onChange(option.value)}
|
|
31
|
+
>
|
|
32
|
+
{/* outer circle */}
|
|
33
|
+
<div
|
|
34
|
+
className={`relative flex justify-center items-center w-4 h-4 rounded-full border-2
|
|
35
|
+
${selectedValue === option.value
|
|
36
|
+
? 'border-2 border-light-text-primary dark:border-dark-text-primary'
|
|
37
|
+
: 'border-2 border-light-text-secondary dark:border-dark-text-secondary'}
|
|
38
|
+
`}
|
|
39
|
+
>
|
|
40
|
+
{/* Inner circle */}
|
|
41
|
+
<div
|
|
42
|
+
className={`absolute w-2 h-2 rounded-full
|
|
43
|
+
${selectedValue === option.value
|
|
44
|
+
? 'bg-light-text-primary dark:bg-dark-text-primary'
|
|
45
|
+
: 'bg-transparent'}
|
|
46
|
+
`}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
</div>
|
|
50
|
+
<span className="ml-2 text-body1">{option.label}</span>
|
|
51
|
+
</label>
|
|
52
|
+
))}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
package/components/tab.tsx
CHANGED
|
@@ -64,10 +64,10 @@ export default function Tab({
|
|
|
64
64
|
return (
|
|
65
65
|
<div
|
|
66
66
|
className={`
|
|
67
|
-
flex items-center space-x-2 p-
|
|
67
|
+
flex items-center space-x-2 p-1 rounded-[8px] cursor-pointer justify-start
|
|
68
68
|
${isSelected
|
|
69
|
-
? 'bg-light-primary-
|
|
70
|
-
: 'bg-
|
|
69
|
+
? 'bg-light-primary-dark dark:bg-dark-primary-dark text-light-text-contrast dark:text-dark-text-contrast'
|
|
70
|
+
: 'bg-transparent dark:bg-transparent hover:bg-light-background-accent200 dark:hover:bg-dark-background-accent200'}
|
|
71
71
|
`}
|
|
72
72
|
onClick={handleClick}
|
|
73
73
|
>
|
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type { Config } from "tailwindcss";
|
|
2
|
-
|
|
3
1
|
const designTokens = require('./designTokens');
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
module.exports = {
|
|
4
|
+
darkMode: 'class',
|
|
6
5
|
content: [
|
|
7
|
-
"./app/**/*.{js,ts,jsx,tsx}",
|
|
8
6
|
"./components/**/*.{js,ts,jsx,tsx}",
|
|
9
|
-
"./pages/**/*.{js,ts,jsx,tsx}",
|
|
10
7
|
],
|
|
11
8
|
theme: {
|
|
12
9
|
extend: {
|
|
@@ -156,12 +153,11 @@ const config: Config = {
|
|
|
156
153
|
'dark-misc-scrollbar-bg': designTokens.colors.dark.background.default,
|
|
157
154
|
'dark-misc-scrollbar-thumb': designTokens.colors.dark.background.accent200,
|
|
158
155
|
},
|
|
159
|
-
spacing:
|
|
160
|
-
...theme('spacing'), // Retain default spacing
|
|
156
|
+
spacing: {
|
|
161
157
|
small: designTokens.spacing.small,
|
|
162
158
|
medium: designTokens.spacing.medium,
|
|
163
159
|
large: designTokens.spacing.large,
|
|
164
|
-
}
|
|
160
|
+
},
|
|
165
161
|
fontSize: {
|
|
166
162
|
h1: designTokens.typography.h1.size,
|
|
167
163
|
h2: designTokens.typography.h2.size,
|
|
@@ -229,7 +225,100 @@ const config: Config = {
|
|
|
229
225
|
require('tailwindcss'),
|
|
230
226
|
require('autoprefixer'),
|
|
231
227
|
require('tailwind-scrollbar'),
|
|
232
|
-
|
|
228
|
+
function({ addUtilities, theme }) {
|
|
229
|
+
const newUtilities = {
|
|
230
|
+
'.text-h1': {
|
|
231
|
+
fontSize: theme('fontSize.h1'),
|
|
232
|
+
fontWeight: theme('fontWeight.h1'),
|
|
233
|
+
letterSpacing: theme('letterSpacing.h1'),
|
|
234
|
+
lineHeight: theme('lineHeight.h1'),
|
|
235
|
+
fontFamily: theme('fontFamily.inter'),
|
|
236
|
+
},
|
|
237
|
+
'.text-h2': {
|
|
238
|
+
fontSize: theme('fontSize.h2'),
|
|
239
|
+
fontWeight: theme('fontWeight.h2'),
|
|
240
|
+
letterSpacing: theme('letterSpacing.h2'),
|
|
241
|
+
lineHeight: theme('lineHeight.h2'),
|
|
242
|
+
fontFamily: theme('fontFamily.inter'),
|
|
243
|
+
},
|
|
244
|
+
'.text-h3': {
|
|
245
|
+
fontSize: theme('fontSize.h3'),
|
|
246
|
+
fontWeight: theme('fontWeight.h3'),
|
|
247
|
+
letterSpacing: theme('letterSpacing.h3'),
|
|
248
|
+
lineHeight: theme('lineHeight.h3'),
|
|
249
|
+
fontFamily: theme('fontFamily.inter'),
|
|
250
|
+
},
|
|
251
|
+
'.text-h4': {
|
|
252
|
+
fontSize: theme('fontSize.h4'),
|
|
253
|
+
fontWeight: theme('fontWeight.h4'),
|
|
254
|
+
letterSpacing: theme('letterSpacing.h4'),
|
|
255
|
+
lineHeight: theme('lineHeight.h4'),
|
|
256
|
+
fontFamily: theme('fontFamily.inter'),
|
|
257
|
+
},
|
|
258
|
+
'.text-h5': {
|
|
259
|
+
fontSize: theme('fontSize.h5'),
|
|
260
|
+
fontWeight: theme('fontWeight.h5'),
|
|
261
|
+
letterSpacing: theme('letterSpacing.h5'),
|
|
262
|
+
lineHeight: theme('lineHeight.h5'),
|
|
263
|
+
fontFamily: theme('fontFamily.inter'),
|
|
264
|
+
},
|
|
265
|
+
'.text-h6': {
|
|
266
|
+
fontSize: theme('fontSize.h6'),
|
|
267
|
+
fontWeight: theme('fontWeight.h6'),
|
|
268
|
+
letterSpacing: theme('letterSpacing.h6'),
|
|
269
|
+
lineHeight: theme('lineHeight.h6'),
|
|
270
|
+
fontFamily: theme('fontFamily.inter'),
|
|
271
|
+
},
|
|
272
|
+
'.text-subtitle1': {
|
|
273
|
+
fontSize: theme('fontSize.subtitle1'),
|
|
274
|
+
fontWeight: theme('fontWeight.subtitle1'),
|
|
275
|
+
letterSpacing: theme('letterSpacing.subtitle1'),
|
|
276
|
+
lineHeight: theme('lineHeight.subtitle1'),
|
|
277
|
+
fontFamily: theme('fontFamily.inter'),
|
|
278
|
+
},
|
|
279
|
+
'.text-subtitle2': {
|
|
280
|
+
fontSize: theme('fontSize.subtitle2'),
|
|
281
|
+
fontWeight: theme('fontWeight.subtitle2'),
|
|
282
|
+
letterSpacing: theme('letterSpacing.subtitle2'),
|
|
283
|
+
lineHeight: theme('lineHeight.subtitle2'),
|
|
284
|
+
fontFamily: theme('fontFamily.inter'),
|
|
285
|
+
},
|
|
286
|
+
'.text-body1': {
|
|
287
|
+
fontSize: theme('fontSize.body1'),
|
|
288
|
+
fontWeight: theme('fontWeight.body1'),
|
|
289
|
+
letterSpacing: theme('letterSpacing.body1'),
|
|
290
|
+
lineHeight: theme('lineHeight.body1'),
|
|
291
|
+
fontFamily: theme('fontFamily.inter'),
|
|
292
|
+
},
|
|
293
|
+
'.text-body2': {
|
|
294
|
+
fontSize: theme('fontSize.body2'),
|
|
295
|
+
fontWeight: theme('fontWeight.body2'),
|
|
296
|
+
letterSpacing: theme('letterSpacing.body2'),
|
|
297
|
+
lineHeight: theme('lineHeight.body2'),
|
|
298
|
+
fontFamily: theme('fontFamily.inter'),
|
|
299
|
+
},
|
|
300
|
+
'.text-caption': {
|
|
301
|
+
fontSize: theme('fontSize.caption'),
|
|
302
|
+
fontWeight: theme('fontWeight.caption'),
|
|
303
|
+
letterSpacing: theme('letterSpacing.caption'),
|
|
304
|
+
lineHeight: theme('lineHeight.caption'),
|
|
305
|
+
fontFamily: theme('fontFamily.inter'),
|
|
306
|
+
},
|
|
307
|
+
'.text-left': {
|
|
308
|
+
textAlign: theme('textAlign.left'),
|
|
309
|
+
},
|
|
310
|
+
'.text-center': {
|
|
311
|
+
textAlign: theme('textAlign.center'),
|
|
312
|
+
},
|
|
313
|
+
'.text-right': {
|
|
314
|
+
textAlign: theme('textAlign.right'),
|
|
315
|
+
},
|
|
316
|
+
'.text-justify': {
|
|
317
|
+
textAlign: theme('textAlign.justify'),
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
addUtilities(newUtilities);
|
|
322
|
+
},
|
|
233
323
|
],
|
|
234
|
-
}
|
|
235
|
-
export default config;
|
|
324
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface AlertProps {
|
|
3
|
-
open?: boolean;
|
|
4
|
-
type: 'success' | 'warning' | 'error' | 'info';
|
|
5
|
-
message: string;
|
|
6
|
-
onClose: () => void;
|
|
7
|
-
}
|
|
8
|
-
export default function Alert({ open, type, message, onClose }: AlertProps): React.JSX.Element | null;
|
|
9
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
3
|
-
export default function Alert(_a) {
|
|
4
|
-
var open = _a.open, type = _a.type, message = _a.message, onClose = _a.onClose;
|
|
5
|
-
useEffect(function () {
|
|
6
|
-
if (open) {
|
|
7
|
-
var timer_1 = setTimeout(function () {
|
|
8
|
-
onClose();
|
|
9
|
-
}, 3000);
|
|
10
|
-
return function () { return clearTimeout(timer_1); };
|
|
11
|
-
}
|
|
12
|
-
}, [open, onClose]);
|
|
13
|
-
if (!open)
|
|
14
|
-
return null;
|
|
15
|
-
var bgColor;
|
|
16
|
-
switch (type) {
|
|
17
|
-
case 'error':
|
|
18
|
-
bgColor = 'bg-light-error-main dark:bg-dark-error-main';
|
|
19
|
-
break;
|
|
20
|
-
case 'warning':
|
|
21
|
-
bgColor = 'bg-light-warning-main dark:bg-dark-warning-main';
|
|
22
|
-
break;
|
|
23
|
-
case 'info':
|
|
24
|
-
bgColor = 'bg-light-info-main dark:bg-dark-info-main';
|
|
25
|
-
break;
|
|
26
|
-
case 'success':
|
|
27
|
-
bgColor = 'bg-light-success-main dark:bg-dark-success-main';
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
return (<div className="fixed top-4 inset-x-0 z-50 flex justify-center">
|
|
31
|
-
<div className={"flex items-center justify-between w-full max-w-md p-4 rounded-[8px] shadow-lg text-light-text-contrast dark:text-dark-text-contrast ".concat(bgColor)}>
|
|
32
|
-
<span>{message}</span>
|
|
33
|
-
<button onClick={onClose} className="ml-4 text-xl font-bold">
|
|
34
|
-
×
|
|
35
|
-
</button>
|
|
36
|
-
</div>
|
|
37
|
-
</div>);
|
|
38
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface ButtonProps {
|
|
3
|
-
size: 'small' | 'medium' | 'large';
|
|
4
|
-
type: 'primary' | 'secondary' | 'tertiary' | 'textOnly';
|
|
5
|
-
state: 'enabled' | 'hovered' | 'focused' | 'disabled';
|
|
6
|
-
label: string;
|
|
7
|
-
decoIcon?: string;
|
|
8
|
-
actionIcon?: string;
|
|
9
|
-
onClickButton?: any;
|
|
10
|
-
onClickActionIcon?: () => void;
|
|
11
|
-
}
|
|
12
|
-
export default function Button({ size, type, state, label, decoIcon, actionIcon, onClickButton, onClickActionIcon, }: ButtonProps): React.JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1,141 +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 Button(_a) {
|
|
40
|
-
var _this = this;
|
|
41
|
-
var size = _a.size, type = _a.type, state = _a.state, label = _a.label, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, onClickButton = _a.onClickButton, onClickActionIcon = _a.onClickActionIcon;
|
|
42
|
-
var _b = useState(false), isHovered = _b[0], setIsHovered = _b[1];
|
|
43
|
-
var _c = useState(null), IconLeft = _c[0], setIconLeft = _c[1];
|
|
44
|
-
var _d = useState(null), IconRight = _d[0], setIconRight = _d[1];
|
|
45
|
-
// Import icon dynamically
|
|
46
|
-
var loadIcon = useCallback(function (iconName) { return __awaiter(_this, void 0, void 0, function () {
|
|
47
|
-
var module_1, Icon, error_1;
|
|
48
|
-
return __generator(this, function (_a) {
|
|
49
|
-
switch (_a.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
if (!iconName)
|
|
52
|
-
return [2 /*return*/, null];
|
|
53
|
-
_a.label = 1;
|
|
54
|
-
case 1:
|
|
55
|
-
_a.trys.push([1, 3, , 4]);
|
|
56
|
-
return [4 /*yield*/, import('@heroicons/react/24/outline')];
|
|
57
|
-
case 2:
|
|
58
|
-
module_1 = _a.sent();
|
|
59
|
-
Icon = module_1[iconName];
|
|
60
|
-
return [2 /*return*/, Icon || null];
|
|
61
|
-
case 3:
|
|
62
|
-
error_1 = _a.sent();
|
|
63
|
-
console.error("Failed to load icon ".concat(iconName, ":"), error_1);
|
|
64
|
-
return [2 /*return*/, null];
|
|
65
|
-
case 4: return [2 /*return*/];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}); }, []);
|
|
69
|
-
useEffect(function () {
|
|
70
|
-
var fetchIcons = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
71
|
-
var _a, _b;
|
|
72
|
-
return __generator(this, function (_c) {
|
|
73
|
-
switch (_c.label) {
|
|
74
|
-
case 0:
|
|
75
|
-
if (!decoIcon) return [3 /*break*/, 2];
|
|
76
|
-
_a = setIconLeft;
|
|
77
|
-
return [4 /*yield*/, loadIcon(decoIcon)];
|
|
78
|
-
case 1:
|
|
79
|
-
_a.apply(void 0, [_c.sent()]);
|
|
80
|
-
_c.label = 2;
|
|
81
|
-
case 2:
|
|
82
|
-
if (!actionIcon) return [3 /*break*/, 4];
|
|
83
|
-
_b = setIconRight;
|
|
84
|
-
return [4 /*yield*/, loadIcon(actionIcon)];
|
|
85
|
-
case 3:
|
|
86
|
-
_b.apply(void 0, [_c.sent()]);
|
|
87
|
-
_c.label = 4;
|
|
88
|
-
case 4: return [2 /*return*/];
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}); };
|
|
92
|
-
fetchIcons();
|
|
93
|
-
}, [decoIcon, actionIcon, loadIcon]);
|
|
94
|
-
// Define classes for size
|
|
95
|
-
var sizeClasses = {
|
|
96
|
-
large: 'text-body1 p-2',
|
|
97
|
-
medium: 'text-body1 p-1',
|
|
98
|
-
small: 'text-body2 p-1',
|
|
99
|
-
}[size];
|
|
100
|
-
// Define icon size classes
|
|
101
|
-
var sizeIcon = {
|
|
102
|
-
large: 'w-6 h-6',
|
|
103
|
-
medium: 'w-5 h-5',
|
|
104
|
-
small: 'w-4 h-4',
|
|
105
|
-
}[size];
|
|
106
|
-
// Define classes for button types
|
|
107
|
-
var baseTypeClasses = {
|
|
108
|
-
primary: 'bg-light-accent-main dark:bg-dark-accent-main text-light-text-primary dark:text-dark-text-contrast',
|
|
109
|
-
secondary: 'bg-light-primary-main dark:bg-dark-primary-main text-light-text-contrast dark:text-dark-text-contrast',
|
|
110
|
-
tertiary: 'bg-light-background-accent200 dark:bg-dark-background-accent200 text-light-text-primary dark:text-dark-text-primary',
|
|
111
|
-
textOnly: 'text-light-text-primary dark:text-dark-text-primary',
|
|
112
|
-
}[type];
|
|
113
|
-
var hoverTypeClasses = {
|
|
114
|
-
primary: 'hover:bg-light-accent-dark hover:dark:bg-dark-accent-dark',
|
|
115
|
-
secondary: 'hover:bg-light-primary-dark dark:hover:bg-dark-primary-dark',
|
|
116
|
-
tertiary: 'hover:bg-light-background-accent300 hover:dark:bg-dark-background-accent300',
|
|
117
|
-
textOnly: 'hover:bg-light-background-accent100 hover:dark:bg-dark-background-accent100',
|
|
118
|
-
}[type];
|
|
119
|
-
// State classes
|
|
120
|
-
var stateClasses = {
|
|
121
|
-
enabled: 'cursor-pointer',
|
|
122
|
-
focused: 'ring-2 ring-offset-4 ring-offset-light-background-default dark:ring-offset-dark-background-default ring-light-accent-main dark:ring-dark-accent-main',
|
|
123
|
-
disabled: type === 'textOnly'
|
|
124
|
-
? 'cursor-not-allowed text-light-text-disabled dark:text-dark-text-disabled bg-transparent'
|
|
125
|
-
: 'cursor-not-allowed text-light-text-disabled dark:text-dark-text-disabled bg-light-actionBackground-disabled dark:bg-dark-actionBackground-disabled',
|
|
126
|
-
};
|
|
127
|
-
// Build the button classes dynamically
|
|
128
|
-
var buttonClasses = "\n flex flex-row space-x-2 items-center rounded-[8px]\n ".concat(sizeClasses, "\n ").concat(state === 'enabled' ? baseTypeClasses : '', "\n ").concat(state === 'focused' ? stateClasses.focused : '', "\n ").concat(state === 'disabled' ? stateClasses.disabled : baseTypeClasses, "\n ").concat(state !== 'disabled' && isHovered ? hoverTypeClasses : '', "\n ");
|
|
129
|
-
return (<button className={buttonClasses} onMouseEnter={function () { if (state !== 'disabled')
|
|
130
|
-
setIsHovered(true); }} onMouseLeave={function () { if (state !== 'disabled')
|
|
131
|
-
setIsHovered(false); }} onClick={onClickButton} // Button click action
|
|
132
|
-
>
|
|
133
|
-
{IconLeft && (<IconLeft className={sizeIcon}/>)}
|
|
134
|
-
<div className="flex-1 whitespace-nowrap overflow-hidden truncate px-2">
|
|
135
|
-
{label}
|
|
136
|
-
</div>
|
|
137
|
-
{IconRight && (<div onClick={onClickActionIcon} className="cursor-pointer">
|
|
138
|
-
<IconRight className={sizeIcon}/>
|
|
139
|
-
</div>)}
|
|
140
|
-
</button>);
|
|
141
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
export default function Checkbox(_a) {
|
|
4
|
-
var label = _a.label, _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange;
|
|
5
|
-
var _c = useState(checked), isChecked = _c[0], setIsChecked = _c[1];
|
|
6
|
-
var handleToggle = function () {
|
|
7
|
-
var newChecked = !isChecked;
|
|
8
|
-
setIsChecked(newChecked);
|
|
9
|
-
if (onChange) {
|
|
10
|
-
onChange(newChecked);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
return (<label className="flex items-center cursor-pointer">
|
|
14
|
-
<div onClick={handleToggle} className="relative flex items-center justify-center w-6 h-6 group">
|
|
15
|
-
{/* Circle behind the checkbox */}
|
|
16
|
-
<div className="absolute w-6 h-6 rounded-full group-hover:bg-light-action-selected dark:group-hover:bg-dark-action-selected transition-all"></div>
|
|
17
|
-
|
|
18
|
-
{/* Checkbox */}
|
|
19
|
-
<div className={"relative z-10 w-4 h-4 border-2 rounded ".concat(isChecked
|
|
20
|
-
? 'bg-light-accent-main dark:bg-dark-accent-main border-none'
|
|
21
|
-
: 'border-light-text-secondary dark:border-dark-text-secondary', " flex items-center justify-center transition-colors")}>
|
|
22
|
-
{isChecked && (<svg className="w-3 h-3 text-light-text-contrast dark:text-dark-text-contrast" fill="none" stroke="currentColor" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
|
23
|
-
<path strokeWidth="2" d="M1 6l4 3 6-7"/>
|
|
24
|
-
</svg>)}
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
{label && <span className="ml-2">{label}</span>}
|
|
28
|
-
</label>);
|
|
29
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ExclamationCircleIcon } from '@heroicons/react/24/outline';
|
|
4
|
-
export default function EmptyBox(_a) {
|
|
5
|
-
var text = _a.text, size = _a.size;
|
|
6
|
-
var color = 'text-light-text-disabled dark:text-dark-text-disabled';
|
|
7
|
-
var height = size === 'small'
|
|
8
|
-
? 'py-6'
|
|
9
|
-
: 'h-full';
|
|
10
|
-
var iconSize = 'size-6';
|
|
11
|
-
return (<div className={"flex flex-col space-y-2 justify-center items-center w-full ".concat(height)}>
|
|
12
|
-
<ExclamationCircleIcon className={"".concat(iconSize, " ").concat(color)}/>
|
|
13
|
-
<p className={"text-body1 ".concat(color)} text-center>
|
|
14
|
-
{text}
|
|
15
|
-
</p>
|
|
16
|
-
</div>);
|
|
17
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import * as HeroIcons from '@heroicons/react/24/outline';
|
|
3
|
-
interface IconButtonProps {
|
|
4
|
-
variant: "contained" | "iconOnly";
|
|
5
|
-
color: "primary" | "secondary";
|
|
6
|
-
state: "enabled" | "selected" | "disabled";
|
|
7
|
-
iconName: keyof typeof HeroIcons;
|
|
8
|
-
onClick?: any;
|
|
9
|
-
}
|
|
10
|
-
export default function IconButton({ variant, color, state, iconName, onClick, }: IconButtonProps): React.JSX.Element;
|
|
11
|
-
export {};
|