@youngonesworks/ui 0.1.95 → 0.1.99
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/dist/components/alert/index.d.ts +10 -9
- package/dist/components/badge/index.d.ts +2 -17
- package/dist/index.cjs +87 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +88 -80
- package/dist/index.js.map +1 -1
- package/dist/utils/enums.d.ts +1 -0
- package/package.json +3 -1
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
type AlertType = 'success' | 'warning' | 'error';
|
|
3
|
+
interface AlertProps extends HTMLAttributes<HTMLDivElement> {
|
|
2
4
|
show: boolean;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
type?: AlertType;
|
|
8
|
+
button?: React.ReactNode;
|
|
6
9
|
plain?: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated Can be removed entirely.
|
|
9
|
-
*/
|
|
10
10
|
closable?: boolean;
|
|
11
|
-
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
onClose?: () => void;
|
|
12
13
|
}
|
|
13
14
|
export declare const Alert: {
|
|
14
|
-
({ show,
|
|
15
|
+
({ show, title, description, type, button, plain, closable, className, icon, onClose, ...props }: AlertProps): import("react/jsx-runtime").JSX.Element | null;
|
|
15
16
|
displayName: string;
|
|
16
17
|
};
|
|
17
18
|
export {};
|
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
interface IBadgeProps {
|
|
2
|
-
styleVariant?: 'green-light' | 'red' | 'accent-blue' | 'warning' | 'gray' | 'black' | 'purple' | 'pink' | 'pink-light' | 'gray' | 'white';
|
|
2
|
+
styleVariant?: 'green-light' | 'red' | 'accent-blue' | 'warning' | 'gray' | 'black' | 'dark-gray' | 'purple' | 'pink' | 'pink-light' | 'gray' | 'white';
|
|
3
3
|
color?: 'dark' | 'gray' | 'red' | 'pink' | 'grape' | 'violet' | 'indigo' | 'blue' | 'cyan' | 'green' | 'lime' | 'yellow' | 'orange' | 'teal';
|
|
4
|
-
/** Controls appearance */
|
|
5
|
-
variant?: 'light' | 'filled' | 'outline' | 'dot' | 'gradient';
|
|
6
|
-
/** Badge height and font size */
|
|
7
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
-
/** Key of theme.radius or any valid CSS value to set border-radius, "xl" by default */
|
|
9
|
-
radius?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
10
|
-
/** Sets badge width to 100% of parent element, hides overflow text with text-overflow: ellipsis */
|
|
11
|
-
fullWidth?: boolean;
|
|
12
|
-
/** Section rendered on the left side of label */
|
|
13
|
-
leftSection?: React.ReactNode;
|
|
14
|
-
/** Section rendered on the right side of label */
|
|
15
|
-
rightSection?: React.ReactNode;
|
|
16
4
|
favorite?: boolean;
|
|
17
|
-
/** Badge label */
|
|
18
5
|
children?: React.ReactNode;
|
|
19
|
-
mobile?: boolean;
|
|
20
6
|
className?: string;
|
|
21
|
-
badgeBorder?: boolean;
|
|
22
7
|
}
|
|
23
8
|
export declare const Badge: {
|
|
24
|
-
({ styleVariant, className, favorite,
|
|
9
|
+
({ styleVariant, className, favorite, children, ...props }: IBadgeProps): import("react/jsx-runtime").JSX.Element | null;
|
|
25
10
|
displayName: string;
|
|
26
11
|
};
|
|
27
12
|
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -152,6 +152,7 @@ let COLOR = /* @__PURE__ */ function(COLOR$1) {
|
|
|
152
152
|
COLOR$1["ULTRA_LIGHT_GRAY"] = "ultra-light-gray";
|
|
153
153
|
COLOR$1["TURQUOISE"] = "turquoise";
|
|
154
154
|
COLOR$1["RED"] = "red";
|
|
155
|
+
COLOR$1["DARK_GRAY"] = "dark-gray";
|
|
155
156
|
COLOR$1["GRAY"] = "gray";
|
|
156
157
|
COLOR$1["WHITE"] = "white";
|
|
157
158
|
COLOR$1["PURPLE"] = "purple";
|
|
@@ -223,51 +224,74 @@ ActionIcon.displayName = "ActionIcon";
|
|
|
223
224
|
|
|
224
225
|
//#endregion
|
|
225
226
|
//#region src/components/alert/index.tsx
|
|
226
|
-
const Alert = ({ show,
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
size: 26,
|
|
244
|
-
"data-testid": "check-circle-icon"
|
|
245
|
-
});
|
|
227
|
+
const Alert = ({ show, title, description, type = "warning", button, plain = false, closable = false, className, icon, onClose,...props }) => {
|
|
228
|
+
if (!show || !title) return null;
|
|
229
|
+
const typeConfig = {
|
|
230
|
+
success: {
|
|
231
|
+
bg: "bg-green-light",
|
|
232
|
+
iconColor: "text-green",
|
|
233
|
+
Icon: __tabler_icons_react.IconCircleCheck
|
|
234
|
+
},
|
|
235
|
+
warning: {
|
|
236
|
+
bg: "bg-warning-light",
|
|
237
|
+
iconColor: "text-warning",
|
|
238
|
+
Icon: __tabler_icons_react.IconAlertTriangle
|
|
239
|
+
},
|
|
240
|
+
error: {
|
|
241
|
+
bg: "bg-red-50",
|
|
242
|
+
iconColor: "text-red-500",
|
|
243
|
+
Icon: __tabler_icons_react.IconAlertCircle
|
|
246
244
|
}
|
|
247
|
-
return null;
|
|
248
245
|
};
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}, className),
|
|
246
|
+
const config = typeConfig[type];
|
|
247
|
+
const { bg, iconColor, Icon } = config;
|
|
248
|
+
const descriptionId = description ? `alert-desc` : undefined;
|
|
249
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
250
|
+
role: "alert",
|
|
251
|
+
"aria-live": "assertive",
|
|
252
|
+
"aria-atomic": "true",
|
|
253
|
+
"aria-describedby": descriptionId,
|
|
254
|
+
className: cn("flex justify-between items-start rounded-md px-5 py-3", bg, plain && "border-none py-4 text-sm font-medium", className),
|
|
259
255
|
"data-component": "Alert",
|
|
260
256
|
"data-testid": "alert",
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
257
|
+
...props,
|
|
258
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
259
|
+
className: "flex flex-col gap-2 flex-1",
|
|
260
|
+
children: [
|
|
261
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
262
|
+
className: "flex items-center gap-2",
|
|
263
|
+
children: [!plain && (icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
264
|
+
"data-testid": "alert-custom-icon",
|
|
265
|
+
"aria-hidden": "true",
|
|
266
|
+
children: icon
|
|
267
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
268
|
+
size: 20,
|
|
269
|
+
className: cn(iconColor, "shrink-0"),
|
|
270
|
+
"data-testid": "alert-icon",
|
|
271
|
+
"aria-hidden": "true"
|
|
272
|
+
})), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
273
|
+
className: "text-base font-medium",
|
|
274
|
+
children: title
|
|
275
|
+
})]
|
|
276
|
+
}),
|
|
277
|
+
description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
278
|
+
id: descriptionId,
|
|
279
|
+
className: "text-sm text-color-gray-900",
|
|
280
|
+
children: description
|
|
281
|
+
}),
|
|
282
|
+
button && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: button })
|
|
283
|
+
]
|
|
284
|
+
}), closable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
285
|
+
type: "button",
|
|
286
|
+
className: "ml-4 text-gray-500 hover:text-gray-700",
|
|
287
|
+
onClick: onClose,
|
|
288
|
+
"aria-label": "Dismiss alert",
|
|
289
|
+
"data-testid": "alert-close",
|
|
290
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconX, {
|
|
291
|
+
size: 18,
|
|
292
|
+
"aria-hidden": "true"
|
|
293
|
+
})
|
|
294
|
+
})]
|
|
271
295
|
});
|
|
272
296
|
};
|
|
273
297
|
Alert.displayName = "Alert";
|
|
@@ -634,48 +658,32 @@ const AvatarIndicator = ({ indicatorCount, className }) => /* @__PURE__ */ (0, r
|
|
|
634
658
|
|
|
635
659
|
//#endregion
|
|
636
660
|
//#region src/components/badge/index.tsx
|
|
637
|
-
const Badge = ({ styleVariant = COLOR.ACCENT_BLUE, className, favorite,
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
"
|
|
642
|
-
"
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
"bg-gray-50 text-gray-800": styleVariant === COLOR.GRAY,
|
|
658
|
-
"bg-pink-light text-pink": styleVariant === COLOR.PINK_LIGHT,
|
|
659
|
-
"bg-pink text-white": styleVariant === COLOR.PINK,
|
|
660
|
-
"bg-white text-black": styleVariant === COLOR.WHITE
|
|
661
|
-
}, className),
|
|
662
|
-
...props,
|
|
663
|
-
children: [
|
|
664
|
-
leftSection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
665
|
-
"data-testid": "left-section",
|
|
666
|
-
children: leftSection
|
|
667
|
-
}),
|
|
668
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
661
|
+
const Badge = ({ styleVariant = COLOR.ACCENT_BLUE, className, favorite, children,...props }) => {
|
|
662
|
+
if (!children) return null;
|
|
663
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
664
|
+
"data-testid": "badge",
|
|
665
|
+
"data-component": "Badge",
|
|
666
|
+
className: (0, clsx.default)("inline-flex h-[1.375rem] max-w-full place-content-center items-center p-[10px] align-middle text-xs leading-[20px] font-medium tracking-wide text-wrap whitespace-normal normal-case rounded-sm", {
|
|
667
|
+
"bg-accent-blue-light text-accent-blue": styleVariant === COLOR.ACCENT_BLUE,
|
|
668
|
+
"bg-green-light text-green": styleVariant === COLOR.GREEN_LIGHT,
|
|
669
|
+
"bg-red-50 text-red-500": styleVariant === COLOR.RED,
|
|
670
|
+
"bg-purple-light text-purple": styleVariant === COLOR.PURPLE,
|
|
671
|
+
"bg-warning-light text-warning": styleVariant === COLOR.WARNING,
|
|
672
|
+
"bg-gray-50 text-black": styleVariant === COLOR.DARK_GRAY,
|
|
673
|
+
"bg-black text-white": styleVariant === COLOR.BLACK,
|
|
674
|
+
"bg-gray-50 text-gray-800": styleVariant === COLOR.GRAY,
|
|
675
|
+
"bg-pink-light text-pink": styleVariant === COLOR.PINK_LIGHT,
|
|
676
|
+
"bg-pink text-white": styleVariant === COLOR.PINK,
|
|
677
|
+
"bg-white text-black": styleVariant === COLOR.WHITE
|
|
678
|
+
}, className),
|
|
679
|
+
...props,
|
|
680
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
669
681
|
"data-testid": "badge-content",
|
|
670
682
|
className: cn("block h-5 overflow-hidden text-ellipsis whitespace-nowrap", { "flex items-center": favorite }),
|
|
671
683
|
children
|
|
672
|
-
}),
|
|
673
|
-
rightSection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
674
|
-
"data-testid": "right-section",
|
|
675
|
-
children: rightSection
|
|
676
684
|
})
|
|
677
|
-
|
|
678
|
-
}
|
|
685
|
+
});
|
|
686
|
+
};
|
|
679
687
|
Badge.displayName = "Badge";
|
|
680
688
|
|
|
681
689
|
//#endregion
|