@jbpark/ui-kit 1.1.4 → 1.1.6

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.
@@ -0,0 +1,10 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+
4
+ //#region src/lib/utils/index.ts
5
+ function cn(...inputs) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+
9
+ //#endregion
10
+ export { cn as t };
package/dist/utils.mjs CHANGED
@@ -1,10 +1,3 @@
1
- import { clsx } from "clsx";
2
- import { twMerge } from "tailwind-merge";
1
+ import { t as cn } from "./utils-DEenfsJ-.mjs";
3
2
 
4
- //#region src/lib/utils/index.ts
5
- function cn(...inputs) {
6
- return twMerge(clsx(inputs));
7
- }
8
-
9
- //#endregion
10
3
  export { cn };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbpark/ui-kit",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Modern React UI component library built with TypeScript, Tailwind CSS, and Radix UI. Featuring atoms, molecules, organisms and layout templates for building beautiful interfaces.",
5
5
  "keywords": [
6
6
  "react",
@@ -1,235 +0,0 @@
1
- import { ChevronDown } from "lucide-react";
2
- import { cn } from "@repo/ui/utils";
3
- import { createElement, useEffect, useRef, useState } from "react";
4
- import { jsx, jsxs } from "react/jsx-runtime";
5
- import { AnimatePresence, motion } from "motion/react";
6
- import { Typography } from "@repo/ui";
7
-
8
- //#region src/components/molecules/Menu/index.tsx
9
- const MENU_CLASSNAMES = [
10
- "p-0",
11
- "bg-white",
12
- "shadow-md",
13
- "rounded-md"
14
- ];
15
- const OPEN_CLASSNAMES = ["underline", "underline-offset-8"];
16
- const HOVER_CLASSNAMES = ["hover:underline", "hover:underline-offset-8"];
17
- const OFFSET = [8, 8];
18
- const INLINE_OFFSET = 16;
19
- function findKey(menu, targetKeys) {
20
- if (targetKeys.includes(menu.key)) return true;
21
- if (menu.children && Array.isArray(menu.children)) {
22
- for (const child of menu.children) if (findKey(child, targetKeys)) return true;
23
- }
24
- return false;
25
- }
26
- const Label = ({ children, level = 4, className, ...props }) => {
27
- if (typeof children === "string") return /* @__PURE__ */ jsx(Typography.Text, {
28
- level,
29
- className: cn(className),
30
- ...props,
31
- children
32
- });
33
- return children;
34
- };
35
- const Item = ({ itemKey = "", keyPath = [], root = false, mode, label, children, selectedKeys = [], fullSize, classNames, styles, offset = OFFSET, inlineOffset = INLINE_OFFSET, onClick, ...props }) => {
36
- const [open, setOpen] = useState(false);
37
- const [position, setPosition] = useState({
38
- top: 0,
39
- left: 0
40
- });
41
- const itemRef = useRef(null);
42
- const isHorizontal = mode === "horizontal";
43
- const isInline = mode === "inline";
44
- const [left, top] = offset;
45
- const item = {
46
- ...props,
47
- label,
48
- key: itemKey,
49
- children
50
- };
51
- const itemClassNames = cn("px-4 py-2", "cursor-pointer", "whitespace-nowrap", root && isHorizontal ? "inline-flex" : "flex", ...root ? [
52
- "h-full",
53
- "rounded-none border-transparent",
54
- !!children?.length && "hover:border-current",
55
- isHorizontal ? "border-b-2" : "border-r-2",
56
- isInline && "border-none",
57
- classNames?.rootItem
58
- ] : [
59
- "rounded-md",
60
- ...HOVER_CLASSNAMES,
61
- classNames?.item
62
- ]);
63
- const childrenContainerClassNames = cn(isInline ? "relative overflow-hidden" : "absolute min-w-[200px]", !isInline && root && isHorizontal ? "left-0 top-full pt-2 pl-0" : !isInline ? "left-full top-0 pl-2 pt-0" : "pl-4", ...fullSize ? [
64
- ...MENU_CLASSNAMES,
65
- "fixed flex justify-center items-start",
66
- isHorizontal ? "inset-x-0 w-screen" : "inset-y-0 h-screen"
67
- ] : []);
68
- const childrenContainerStyle = fullSize ? isHorizontal ? {
69
- top: position.top,
70
- marginTop: top
71
- } : {
72
- left: position.left,
73
- marginLeft: left
74
- } : isInline ? { paddingLeft: inlineOffset } : root && isHorizontal ? { paddingTop: top } : { paddingLeft: left };
75
- useEffect(() => {
76
- if (!itemRef.current) return;
77
- const $item = itemRef.current;
78
- const onResize = () => {
79
- setPosition({
80
- top: $item.offsetTop + $item.offsetHeight,
81
- left: $item.offsetLeft + $item.offsetWidth
82
- });
83
- };
84
- onResize();
85
- window.addEventListener("resize", onResize);
86
- return () => window.removeEventListener("resize", onResize);
87
- }, []);
88
- if (!root && fullSize) return /* @__PURE__ */ jsxs("li", {
89
- className: cn("basis-1/6", "min-w-[180px]"),
90
- children: [/* @__PURE__ */ jsx("div", {
91
- className: cn(itemClassNames, "justify-center"),
92
- onClick: (e) => {
93
- e.stopPropagation();
94
- onClick?.({
95
- domEvent: e,
96
- key: itemKey,
97
- keyPath,
98
- item
99
- });
100
- },
101
- children: /* @__PURE__ */ jsx(Label, {
102
- className: "font-semibold",
103
- children: label
104
- })
105
- }), /* @__PURE__ */ jsx("ul", { children: children?.map((child) => /* @__PURE__ */ jsx("li", {
106
- className: cn(itemClassNames, "justify-center", ...findKey(child, selectedKeys) ? [...OPEN_CLASSNAMES, ...HOVER_CLASSNAMES] : []),
107
- onClick: (e) => {
108
- e.stopPropagation();
109
- onClick?.({
110
- domEvent: e,
111
- key: child.key,
112
- keyPath: [...keyPath, child.key],
113
- item: child
114
- });
115
- },
116
- children: /* @__PURE__ */ jsx(Label, {
117
- level: 5,
118
- className: "text-center text-wrap",
119
- children: child.label
120
- })
121
- }, child.key)) })]
122
- });
123
- return /* @__PURE__ */ jsxs("li", {
124
- ref: itemRef,
125
- className: cn("group", "relative", root && isHorizontal ? "inline-block" : "block"),
126
- onMouseEnter: () => {
127
- if (isInline) return;
128
- setOpen(true);
129
- },
130
- onMouseLeave: () => {
131
- if (isInline) return;
132
- setOpen(false);
133
- },
134
- children: [/* @__PURE__ */ jsx("div", {
135
- className: cn(itemClassNames, ...findKey(item, selectedKeys) ? root ? ["border-current"] : [...OPEN_CLASSNAMES, ...HOVER_CLASSNAMES] : root && !!children?.length ? ["group-hover:border-current"] : []),
136
- style: root ? styles?.rootItem : styles?.item,
137
- onClick: (e) => {
138
- e.stopPropagation();
139
- if (isInline) setOpen(!open);
140
- onClick?.({
141
- domEvent: e,
142
- key: itemKey,
143
- keyPath,
144
- item
145
- });
146
- },
147
- children: /* @__PURE__ */ jsxs("div", {
148
- className: cn("w-full", "inline-flex items-center justify-between"),
149
- children: [
150
- /* @__PURE__ */ jsx(Label, {
151
- className: cn(classNames?.label, root && classNames?.rootItem, ...findKey(item, selectedKeys) ? root ? [] : [...OPEN_CLASSNAMES, ...HOVER_CLASSNAMES] : []),
152
- style: styles?.label,
153
- children: label
154
- }),
155
- !root && !isInline && !!children?.length && /* @__PURE__ */ jsx(ChevronDown, { className: cn("-rotate-90") }),
156
- isInline && !!children?.length && /* @__PURE__ */ jsx(ChevronDown, { className: cn("transition-all", open ? "-rotate-180" : "rotate-0") })
157
- ]
158
- })
159
- }), /* @__PURE__ */ jsx(AnimatePresence, { children: !!children?.length && open && /* @__PURE__ */ jsx(motion.div, {
160
- className: cn(childrenContainerClassNames),
161
- style: childrenContainerStyle,
162
- initial: isInline ? {
163
- height: 0,
164
- opacity: 0
165
- } : { opacity: 0 },
166
- animate: isInline ? {
167
- height: "auto",
168
- opacity: 1
169
- } : { opacity: 1 },
170
- exit: isInline ? {
171
- height: 0,
172
- opacity: 0
173
- } : { opacity: 0 },
174
- transition: { duration: .2 },
175
- children: /* @__PURE__ */ jsx("ul", {
176
- className: cn(fullSize ? [
177
- "h-auto",
178
- "flex flex-nowrap gap-y-4",
179
- "p-8"
180
- ] : MENU_CLASSNAMES, isInline && "shadow-none", classNames?.subMenu),
181
- style: styles?.subMenu,
182
- children: children.map((child) => /* @__PURE__ */ createElement(Item, {
183
- ...child,
184
- key: child.key,
185
- itemKey: child.key,
186
- keyPath: [...keyPath, child.key],
187
- mode,
188
- selectedKeys,
189
- fullSize,
190
- classNames,
191
- styles,
192
- offset,
193
- inlineOffset,
194
- onClick
195
- }))
196
- })
197
- }) })]
198
- });
199
- };
200
- const Menu = ({ items, mode = "vertical", fullSize = false, defaultSelectedKeys: _defaultSelectedKeys = [], selectedKeys: _selectedKeys = [], className, classNames, styles, offset, inlineOffset, onClick = () => {}, ...props }) => {
201
- const [selectedKeys, setSelectedKeys] = useState(_defaultSelectedKeys);
202
- useEffect(() => {
203
- if (!_defaultSelectedKeys.length) return;
204
- setSelectedKeys(_defaultSelectedKeys);
205
- return () => setSelectedKeys([]);
206
- }, [_defaultSelectedKeys]);
207
- useEffect(() => {
208
- if (!_selectedKeys.length) return;
209
- setSelectedKeys(_selectedKeys);
210
- return () => setSelectedKeys([]);
211
- }, [_selectedKeys]);
212
- return /* @__PURE__ */ jsx("ul", {
213
- className: cn(MENU_CLASSNAMES, mode === "horizontal" ? "flex" : "inline-block", className),
214
- ...props,
215
- children: items?.map((item) => /* @__PURE__ */ createElement(Item, {
216
- root: true,
217
- ...item,
218
- key: item.key,
219
- itemKey: item.key,
220
- keyPath: [item.key],
221
- selectedKeys,
222
- mode,
223
- fullSize,
224
- classNames,
225
- styles,
226
- offset,
227
- inlineOffset,
228
- onClick
229
- }))
230
- });
231
- };
232
- var Menu_default = Menu;
233
-
234
- //#endregion
235
- export { findKey as n, Menu_default as t };
File without changes