@js-empire/emperor-ui 1.2.7 → 1.3.0

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.
Files changed (35) hide show
  1. package/dist/emperor-ui.js +160 -0
  2. package/dist/emperor-ui.umd.cjs +77 -0
  3. package/dist/globals.css +1 -0
  4. package/dist/icons/emperor-ui-logo.ico +0 -0
  5. package/dist/images/avatar-female.jpg +0 -0
  6. package/dist/images/avatar-male.jpg +0 -0
  7. package/dist/images/emperor-ui-logo.png +0 -0
  8. package/dist/index-CK7pu2VH.js +6 -0
  9. package/dist/index-DoF4sONu.js +60191 -0
  10. package/dist/index-yq9M8Mqg.js +291 -0
  11. package/dist/index.d.ts +1353 -0
  12. package/dist/src-UW24ZMRV-DZ8MyM4k.js +6 -0
  13. package/package.json +1 -4
  14. package/src/components/molecules/item-card/components/actions/index.ts +3 -0
  15. package/src/components/molecules/item-card/components/actions/item-actions-overlay.tsx +50 -0
  16. package/src/components/molecules/item-card/components/additions/index.ts +2 -0
  17. package/src/components/molecules/item-card/{item-banner.tsx → components/additions/item-banner.tsx} +1 -1
  18. package/src/components/molecules/item-card/{loading-item.tsx → components/additions/loading-item.tsx} +1 -1
  19. package/src/components/molecules/item-card/components/card/index.ts +4 -0
  20. package/src/components/molecules/item-card/{item-card-body.tsx → components/card/item-card-body.tsx} +2 -2
  21. package/src/components/molecules/item-card/{item-card-footer.tsx → components/card/item-card-footer.tsx} +6 -3
  22. package/src/components/molecules/item-card/{item-card-header.tsx → components/card/item-card-header.tsx} +6 -4
  23. package/src/components/molecules/item-card/{item-card.tsx → components/card/item-card.tsx} +14 -15
  24. package/src/components/molecules/item-card/components/index.ts +3 -0
  25. package/src/components/molecules/item-card/index.ts +2 -9
  26. package/src/components/molecules/item-card/stories/item-card.stories.tsx +2 -2
  27. package/src/components/molecules/item-card/styles/classes.ts +11 -8
  28. package/src/components/organisms/deletion-confirmor/deletion-confirmor.tsx +4 -8
  29. package/src/components/organisms/deletion-confirmor/stories/components.tsx +3 -0
  30. package/src/constants/card.tsx +15 -2
  31. package/src/index.ts +2 -0
  32. package/vite.config.ts +1 -0
  33. package/src/components/molecules/item-card/item-actions-overlay.tsx +0 -41
  34. /package/src/components/molecules/item-card/{item-actions-buttons.tsx → components/actions/item-actions-buttons.tsx} +0 -0
  35. /package/src/components/molecules/item-card/{item-actions-dropdown.tsx → components/actions/item-actions-dropdown.tsx} +0 -0
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ import { d as a } from "./index-DoF4sONu.js";
3
+ var e = a;
4
+ export {
5
+ e as default
6
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@js-empire/emperor-ui",
3
3
  "description": "They provide the atoms, we provide the empire.",
4
- "version": "1.2.7",
4
+ "version": "1.3.0",
5
5
  "author": "JS Empire - Mustafa Alhasanat",
6
6
  "license": "ISC",
7
7
  "type": "module",
@@ -78,8 +78,6 @@
78
78
  "@internationalized/date": "^3.11.0",
79
79
  "@storybook/react": "^10.1.8",
80
80
  "@tailwindcss/vite": "^4.1.17",
81
- "@tanstack/react-query": "^5.90.20",
82
- "@tanstack/react-query-devtools": "^5.91.3",
83
81
  "browser-image-compression": "^2.0.2",
84
82
  "class-variance-authority": "^0.7.1",
85
83
  "clsx": "^2.1.1",
@@ -87,7 +85,6 @@
87
85
  "husky": "^9.1.7",
88
86
  "lucide-react": "^0.560.0",
89
87
  "motion": "^12.26.2",
90
- "next": "^16.1.6",
91
88
  "next-themes": "^0.4.6",
92
89
  "prettier": "^3.7.4",
93
90
  "react": "^19.2.0",
@@ -0,0 +1,3 @@
1
+ export * from "./item-actions-dropdown";
2
+ export * from "./item-actions-buttons";
3
+ export * from "./item-actions-overlay";
@@ -0,0 +1,50 @@
1
+ "use client";
2
+
3
+ import type { ItemCardProps } from "@/types";
4
+ import { cn } from "@/utils";
5
+ import { Button } from "@heroui/button";
6
+ import { Tooltip } from "@heroui/tooltip";
7
+
8
+ type ItemActionsOverlayProps = Pick<
9
+ ItemCardProps,
10
+ "actions" | "classNames" | "onActionClick" | "orientation"
11
+ >;
12
+
13
+ export function ItemActionsOverlay({
14
+ actions,
15
+ classNames,
16
+ onActionClick,
17
+ orientation,
18
+ }: ItemActionsOverlayProps) {
19
+ if (!actions || actions?.length === 0) return null;
20
+
21
+ return (
22
+ <div
23
+ data-slot="emperor-ui-item-card-actions-overlay"
24
+ className={cn(
25
+ "absolute inset-0 z-20 gap-3 flex items-center justify-center bg-black/60 opacity-0",
26
+ orientation === "horizontal" ? "flex-row" : "flex-col",
27
+ "transition-opacity duration-200 group-hover:opacity-100",
28
+ classNames?.actions,
29
+ )}
30
+ >
31
+ {actions?.map(
32
+ ({ key, label, className: actionClassName, ...props }, index) => {
33
+ return (
34
+ <Tooltip content={label}>
35
+ <Button
36
+ key={key ?? index}
37
+ data-slot="emperor-ui-item-card-actions-overlay-button"
38
+ isIconOnly
39
+ radius="full"
40
+ className={cn(classNames?.action, actionClassName)}
41
+ onPress={() => key && onActionClick?.(String(key))}
42
+ {...props}
43
+ />
44
+ </Tooltip>
45
+ );
46
+ },
47
+ )}
48
+ </div>
49
+ );
50
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./loading-item";
2
+ export * from "./item-banner";
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { ItemCardProps } from "@/types";
4
4
  import { cn } from "@/utils";
5
- import { itemBannerClasses } from "./styles";
5
+ import { itemBannerClasses } from "@/components";
6
6
 
7
7
  export function ItemBanner({
8
8
  item,
@@ -12,7 +12,7 @@ import {
12
12
  itemBodyClasses,
13
13
  itemFooterClasses,
14
14
  itemChipsClasses,
15
- } from "./styles";
15
+ } from "@/components";
16
16
  import { getCardMotion } from "@/constants";
17
17
  import type { ItemCardProps } from "@/types";
18
18
 
@@ -0,0 +1,4 @@
1
+ export * from "./item-card";
2
+ export * from "./item-card-header";
3
+ export * from "./item-card-body";
4
+ export * from "./item-card-footer";
@@ -7,9 +7,9 @@ import {
7
7
  itemDescriptionClasses,
8
8
  itemPriceClasses,
9
9
  itemTitleClasses,
10
- } from "./styles";
10
+ ItemActionsDropdown,
11
+ } from "@/components";
11
12
  import { CardBody } from "@heroui/card";
12
- import { ItemActionsDropdown } from "./item-actions-dropdown";
13
13
 
14
14
  export function ItemCardBody({
15
15
  item,
@@ -2,10 +2,13 @@
2
2
 
3
3
  import type { ItemCardProps } from "@/types";
4
4
  import { cn } from "@/utils";
5
- import { itemFooterClasses, itemChipsClasses } from "./styles";
5
+ import {
6
+ ItemActionsButtons,
7
+ itemFooterClasses,
8
+ itemChipsClasses,
9
+ } from "@/components";
6
10
  import { CardFooter } from "@heroui/card";
7
11
  import { Chip } from "@heroui/chip";
8
- import { ItemActionsButtons } from "./item-actions-buttons";
9
12
 
10
13
  export function ItemCardFooter({
11
14
  item,
@@ -63,7 +66,7 @@ export function ItemCardFooter({
63
66
  </menu>
64
67
  )}
65
68
 
66
- {actionsViewVariant === "buttons" && actions && actions.length > 0 && (
69
+ {actionsViewVariant === "buttons" && actions && actions?.length > 0 && (
67
70
  <ItemActionsButtons
68
71
  actions={actions}
69
72
  classNames={classNames}
@@ -2,11 +2,13 @@
2
2
 
3
3
  import { CardHeader } from "@heroui/card";
4
4
  import { cn } from "@/utils";
5
- import { itemHeaderClasses } from "./styles";
6
- import { itemImageWrapperClasses } from "./styles";
5
+ import {
6
+ itemHeaderClasses,
7
+ ItemActionsDropdown,
8
+ itemImageWrapperClasses,
9
+ ItemBanner,
10
+ } from "@/components";
7
11
  import { Image } from "@heroui/image";
8
- import { ItemBanner } from "@/components";
9
- import { ItemActionsDropdown } from "./item-actions-dropdown";
10
12
  import type { ItemCardProps } from "@/types";
11
13
 
12
14
  export function ItemCardHeader({
@@ -8,7 +8,11 @@ import type {
8
8
  import { cn } from "@/utils";
9
9
  import { Card } from "@heroui/card";
10
10
  import { motion } from "framer-motion";
11
- import { itemMainWrapperClasses, itemCardMotionClasses } from "./styles";
11
+ import {
12
+ itemMainWrapperClasses,
13
+ itemCardMotionClasses,
14
+ ItemActionsOverlay,
15
+ } from "@/components";
12
16
  import { getCardMotion } from "@/constants";
13
17
  import {
14
18
  LoadingItem,
@@ -17,7 +21,6 @@ import {
17
21
  ItemCardFooter,
18
22
  } from "@/components";
19
23
  import { useWindowSize } from "@/hooks";
20
- import { ItemActionsOverlay } from "./item-actions-overlay";
21
24
 
22
25
  export function ItemCard({
23
26
  variants,
@@ -47,8 +50,10 @@ export function ItemCard({
47
50
  );
48
51
 
49
52
  const hasActions = actions && actions.length > 0;
53
+
50
54
  const isDropdownVariant: boolean =
51
55
  (actionsViewVariant as ItemCardActionsViewVariant) === "dropdown";
56
+
52
57
  const isHoverOverlayVariant: boolean =
53
58
  (actionsViewVariant as ItemCardActionsViewVariant) === "hover-overlay";
54
59
 
@@ -103,20 +108,14 @@ export function ItemCard({
103
108
  onActionClick={onActionClick}
104
109
  actionsViewVariant={actionsViewVariant}
105
110
  />
111
+
106
112
  {isHoverOverlayVariant && hasActions && (
107
- <div
108
- data-slot="emperor-ui-item-card-actions-hover-overlay"
109
- className={cn(
110
- "pointer-events-none absolute inset-0 z-20 flex items-center justify-center bg-black/60 opacity-0",
111
- "transition-opacity duration-200 group-hover:opacity-100",
112
- )}
113
- >
114
- <ItemActionsOverlay
115
- actions={actions}
116
- classNames={classNames}
117
- onActionClick={onActionClick}
118
- />
119
- </div>
113
+ <ItemActionsOverlay
114
+ actions={actions}
115
+ classNames={classNames}
116
+ onActionClick={onActionClick}
117
+ orientation={orientation}
118
+ />
120
119
  )}
121
120
  </Card>
122
121
  </motion.div>
@@ -0,0 +1,3 @@
1
+ export * from "./additions";
2
+ export * from "./card";
3
+ export * from "./actions";
@@ -1,9 +1,2 @@
1
- export * from "./item-card";
2
- export * from "./loading-item";
3
- export * from "./item-banner";
4
- export * from "./item-actions-dropdown";
5
- export * from "./item-actions-buttons";
6
- export * from "./item-actions-overlay";
7
- export * from "./item-card-header";
8
- export * from "./item-card-body";
9
- export * from "./item-card-footer";
1
+ export * from "./components";
2
+ export * from "./styles";
@@ -1,8 +1,8 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import type { MockItemType } from "@/mocks";
2
3
  import { ItemCard } from "@/components";
3
4
  import { getStorybookDecorators } from "@/utils";
4
5
  import { getListing, MOCK_LISTINGS } from "@/mocks";
5
- import type { MockItemType } from "@/mocks";
6
6
  import { useEffect, useState } from "storybook/internal/preview-api";
7
7
  import { ItemCardProps } from "@/types";
8
8
  import { ITEM_CARD_ACTIONS } from "@/constants";
@@ -102,7 +102,7 @@ export const WithHorizontalLoading: Story = {
102
102
  },
103
103
  };
104
104
 
105
- export const WithActions: Story = {
105
+ export const WithDropdownActions: Story = {
106
106
  args: {
107
107
  item: {
108
108
  key: String(MOCK_LISTINGS[0]?.id),
@@ -58,16 +58,19 @@ export const itemBodyClasses = cva(["relative flex flex-col gap-2 p-4"], {
58
58
  compoundVariants: [],
59
59
  });
60
60
 
61
- export const itemFooterClasses = cva(["flex items-center p-4"], {
62
- variants: {
63
- orientation: {
64
- vertical: "",
65
- horizontal: "justify-end",
61
+ export const itemFooterClasses = cva(
62
+ ["flex flex-wrap flex-col p-4 gap-4 items-start"],
63
+ {
64
+ variants: {
65
+ orientation: {
66
+ vertical: "",
67
+ horizontal: "justify-end",
68
+ },
66
69
  },
70
+ defaultVariants: {},
71
+ compoundVariants: [],
67
72
  },
68
- defaultVariants: {},
69
- compoundVariants: [],
70
- });
73
+ );
71
74
 
72
75
  export const itemTitleClasses = cva(
73
76
  ["line-clamp-1 font-semibold text-foreground"],
@@ -85,16 +85,12 @@ export function DeletionConfirmor({
85
85
  onPress={handleDecline}
86
86
  className={cn(declineProps?.className, classNames?.declineButton)}
87
87
  >
88
- {declineProps?.children ??
89
- deletionConfirmorLocale?.decline ??
90
- "Decline"}
88
+ {declineProps?.children ?? deletionConfirmorLocale?.decline}
91
89
  </Button>
92
90
 
93
91
  <Button
94
92
  color="danger"
95
93
  size="sm"
96
- {...confirmProps}
97
- className={cn(confirmProps?.className, classNames?.confirmButton)}
98
94
  startContent={
99
95
  confirmProps?.isLoading
100
96
  ? undefined
@@ -102,10 +98,10 @@ export function DeletionConfirmor({
102
98
  <Trash2 className="size-4" aria-hidden />
103
99
  ))
104
100
  }
101
+ {...confirmProps}
102
+ className={cn(confirmProps?.className, classNames?.confirmButton)}
105
103
  >
106
- {confirmProps?.children ??
107
- deletionConfirmorLocale?.confirm ??
108
- "Confirm"}
104
+ {confirmProps?.children ?? deletionConfirmorLocale?.confirm}
109
105
  </Button>
110
106
  </ModalFooter>
111
107
  </ModalContent>
@@ -13,6 +13,9 @@ export const DeletionConfirmorWithTrigger = (args: DeletionConfirmorProps) => {
13
13
  </Button>
14
14
 
15
15
  <DeletionConfirmor
16
+ confirmProps={{
17
+ onPress: () => setIsOpen(false),
18
+ }}
16
19
  {...args}
17
20
  isOpen={isOpen}
18
21
  onClose={() => setIsOpen(false)}
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react-refresh/only-export-components */
1
2
  import { Eye, Pencil, Trash2 } from "lucide-react";
2
3
  import { ItemCardAction } from "@/types";
3
4
 
@@ -8,7 +9,7 @@ export const ITEM_CARD_ACTIONS: ItemCardAction[] = [
8
9
  color: "primary",
9
10
  variant: "flat",
10
11
  size: "sm",
11
- startContent: <Eye className="size-5" />,
12
+ startContent: <Eye className="size-4" />,
12
13
  },
13
14
  {
14
15
  key: "edit",
@@ -16,7 +17,7 @@ export const ITEM_CARD_ACTIONS: ItemCardAction[] = [
16
17
  color: "secondary",
17
18
  variant: "flat",
18
19
  size: "sm",
19
- startContent: <Pencil className="size-5" />,
20
+ startContent: <Pencil className="size-4" />,
20
21
  },
21
22
  {
22
23
  key: "delete",
@@ -27,3 +28,15 @@ export const ITEM_CARD_ACTIONS: ItemCardAction[] = [
27
28
  startContent: <Trash2 className="size-4" />,
28
29
  },
29
30
  ];
31
+
32
+ export const ITEM_CARD_ACTIONS_OVERLAY: ItemCardAction[] =
33
+ ITEM_CARD_ACTIONS.map((action) => ({
34
+ ...action,
35
+ variant: "solid",
36
+ size: "lg",
37
+ startContent: {
38
+ view: <Eye className="size-5" />,
39
+ edit: <Pencil className="size-5" />,
40
+ delete: <Trash2 className="size-5" />,
41
+ }[action?.key],
42
+ }));
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import "./styles/globals.css";
2
4
 
3
5
  export * from "./components";
package/vite.config.ts CHANGED
@@ -38,6 +38,7 @@ export default defineConfig({
38
38
  "react-dom": "ReactDOM",
39
39
  },
40
40
  assetFileNames: "globals.css",
41
+ banner: '"use client";',
41
42
  },
42
43
  },
43
44
  },
@@ -1,41 +0,0 @@
1
- "use client";
2
-
3
- import type { ItemCardProps } from "@/types";
4
- import { cn } from "@/utils";
5
- import { Button } from "@heroui/button";
6
-
7
- type ItemActionsOverlayProps = Pick<
8
- ItemCardProps,
9
- "actions" | "classNames" | "onActionClick"
10
- >;
11
-
12
- export function ItemActionsOverlay({
13
- actions,
14
- classNames,
15
- onActionClick,
16
- }: ItemActionsOverlayProps) {
17
- if (!actions || actions.length === 0) return null;
18
-
19
- return (
20
- <div
21
- data-slot="emperor-ui-item-card-actions-overlay-buttons"
22
- className={cn("flex flex-col items-center gap-3", classNames?.actions)}
23
- >
24
- {actions?.map(
25
- ({ key, label, className: actionClassName, ...props }, index) => {
26
- return (
27
- <Button
28
- key={key ?? index}
29
- data-slot="emperor-ui-item-card-actions-overlay-button"
30
- isIconOnly
31
- radius="full"
32
- className={cn(classNames?.action, actionClassName)}
33
- onPress={() => key && onActionClick?.(String(key))}
34
- {...props}
35
- />
36
- );
37
- },
38
- )}
39
- </div>
40
- );
41
- }