analytica-frontend-lib 1.0.22 → 1.0.23
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/Alert/Alert.d.mts +13 -0
- package/dist/Alert/Alert.d.ts +13 -0
- package/dist/Alert/Alert.js +158 -0
- package/dist/Alert/Alert.mjs +85 -0
- package/dist/Badge/Badge.d.mts +47 -0
- package/dist/Badge/Badge.d.ts +47 -0
- package/dist/Badge/Badge.js +117 -0
- package/dist/Badge/Badge.mjs +92 -0
- package/dist/Button/Button.d.mts +46 -0
- package/dist/Button/Button.d.ts +46 -0
- package/dist/Button/Button.js +84 -0
- package/dist/Button/Button.mjs +59 -0
- package/dist/CheckBox/CheckBox.d.mts +74 -0
- package/dist/CheckBox/CheckBox.d.ts +74 -0
- package/dist/CheckBox/CheckBox.js +264 -0
- package/dist/CheckBox/CheckBox.mjs +195 -0
- package/dist/DropdownMenu/DropdownMenu.d.mts +29 -0
- package/dist/DropdownMenu/DropdownMenu.d.ts +29 -0
- package/dist/DropdownMenu/DropdownMenu.js +262 -0
- package/dist/DropdownMenu/DropdownMenu.mjs +242 -0
- package/dist/IconButton/IconButton.d.mts +77 -0
- package/dist/IconButton/IconButton.d.ts +77 -0
- package/dist/IconButton/IconButton.js +79 -0
- package/dist/IconButton/IconButton.mjs +54 -0
- package/dist/IconRoundedButton/IconRoundedButton.d.mts +35 -0
- package/dist/IconRoundedButton/IconRoundedButton.d.ts +35 -0
- package/dist/IconRoundedButton/IconRoundedButton.js +68 -0
- package/dist/IconRoundedButton/IconRoundedButton.mjs +43 -0
- package/dist/NavButton/NavButton.d.mts +58 -0
- package/dist/NavButton/NavButton.d.ts +58 -0
- package/dist/NavButton/NavButton.js +76 -0
- package/dist/NavButton/NavButton.mjs +51 -0
- package/dist/SelectionButton/SelectionButton.d.mts +58 -0
- package/dist/SelectionButton/SelectionButton.d.ts +58 -0
- package/dist/SelectionButton/SelectionButton.js +81 -0
- package/dist/SelectionButton/SelectionButton.mjs +56 -0
- package/dist/Table/Table.d.mts +17 -0
- package/dist/Table/Table.d.ts +17 -0
- package/dist/Table/Table.js +139 -0
- package/dist/Table/Table.mjs +107 -0
- package/dist/Text/Text.d.mts +59 -0
- package/dist/Text/Text.d.ts +59 -0
- package/dist/Text/Text.js +77 -0
- package/dist/Text/Text.mjs +6 -0
- package/dist/TextArea/TextArea.d.mts +69 -0
- package/dist/TextArea/TextArea.d.ts +69 -0
- package/dist/TextArea/TextArea.js +211 -0
- package/dist/TextArea/TextArea.mjs +142 -0
- package/dist/Toast/Toast.d.mts +17 -0
- package/dist/Toast/Toast.d.ts +17 -0
- package/dist/Toast/Toast.js +100 -0
- package/dist/Toast/Toast.mjs +7 -0
- package/dist/Toast/utils/ToastStore.d.mts +19 -0
- package/dist/Toast/utils/ToastStore.d.ts +19 -0
- package/dist/Toast/utils/ToastStore.js +44 -0
- package/dist/Toast/utils/ToastStore.mjs +6 -0
- package/dist/Toast/utils/Toaster.d.mts +11 -0
- package/dist/Toast/utils/Toaster.d.ts +11 -0
- package/dist/Toast/utils/Toaster.js +145 -0
- package/dist/Toast/utils/Toaster.mjs +35 -0
- package/dist/chunk-MI5FIRHM.mjs +75 -0
- package/dist/chunk-TT3VCQGR.mjs +53 -0
- package/dist/chunk-WIOCQOM7.mjs +20 -0
- package/package.json +71 -3
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Text
|
|
4
|
+
} from "../chunk-TT3VCQGR.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/CheckBox/CheckBox.tsx
|
|
7
|
+
import {
|
|
8
|
+
forwardRef,
|
|
9
|
+
useState,
|
|
10
|
+
useId
|
|
11
|
+
} from "react";
|
|
12
|
+
import { Check, Minus } from "phosphor-react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var SIZE_CLASSES = {
|
|
15
|
+
small: {
|
|
16
|
+
checkbox: "w-4 h-4",
|
|
17
|
+
// 16px x 16px
|
|
18
|
+
textSize: "sm",
|
|
19
|
+
spacing: "gap-1.5",
|
|
20
|
+
// 6px
|
|
21
|
+
borderWidth: "border-2",
|
|
22
|
+
iconSize: 14,
|
|
23
|
+
// pixels for Phosphor icons
|
|
24
|
+
labelHeight: "h-[21px]"
|
|
25
|
+
},
|
|
26
|
+
medium: {
|
|
27
|
+
checkbox: "w-5 h-5",
|
|
28
|
+
// 20px x 20px
|
|
29
|
+
textSize: "md",
|
|
30
|
+
spacing: "gap-2",
|
|
31
|
+
// 8px
|
|
32
|
+
borderWidth: "border-2",
|
|
33
|
+
iconSize: 16,
|
|
34
|
+
// pixels for Phosphor icons
|
|
35
|
+
labelHeight: "h-6"
|
|
36
|
+
},
|
|
37
|
+
large: {
|
|
38
|
+
checkbox: "w-6 h-6",
|
|
39
|
+
// 24px x 24px
|
|
40
|
+
textSize: "lg",
|
|
41
|
+
spacing: "gap-2",
|
|
42
|
+
// 8px
|
|
43
|
+
borderWidth: "border-[3px]",
|
|
44
|
+
// 3px border
|
|
45
|
+
iconSize: 20,
|
|
46
|
+
// pixels for Phosphor icons
|
|
47
|
+
labelHeight: "h-[27px]"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var BASE_CHECKBOX_CLASSES = "rounded border cursor-pointer transition-all duration-200 flex items-center justify-center focus:outline-none";
|
|
51
|
+
var STATE_CLASSES = {
|
|
52
|
+
default: {
|
|
53
|
+
unchecked: "border-border-400 bg-background hover:border-border-500",
|
|
54
|
+
checked: "border-primary-950 bg-primary-950 text-text hover:border-primary-800 hover:bg-primary-800"
|
|
55
|
+
},
|
|
56
|
+
hovered: {
|
|
57
|
+
unchecked: "border-border-500 bg-background",
|
|
58
|
+
checked: "border-primary-800 bg-primary-800 text-text"
|
|
59
|
+
},
|
|
60
|
+
focused: {
|
|
61
|
+
unchecked: "border-indicator-info bg-background ring-2 ring-indicator-info/20",
|
|
62
|
+
checked: "border-indicator-info bg-primary-950 text-text ring-2 ring-indicator-info/20"
|
|
63
|
+
},
|
|
64
|
+
invalid: {
|
|
65
|
+
unchecked: "border-error-700 bg-background hover:border-error-600",
|
|
66
|
+
checked: "border-error-700 bg-primary-950 text-text"
|
|
67
|
+
},
|
|
68
|
+
disabled: {
|
|
69
|
+
unchecked: "border-border-400 bg-background cursor-not-allowed opacity-40",
|
|
70
|
+
checked: "border-primary-600 bg-primary-600 text-text cursor-not-allowed opacity-40"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var CheckBox = forwardRef(
|
|
74
|
+
({
|
|
75
|
+
label,
|
|
76
|
+
size = "medium",
|
|
77
|
+
state = "default",
|
|
78
|
+
indeterminate = false,
|
|
79
|
+
errorMessage,
|
|
80
|
+
helperText,
|
|
81
|
+
className = "",
|
|
82
|
+
labelClassName = "",
|
|
83
|
+
checked: checkedProp,
|
|
84
|
+
disabled,
|
|
85
|
+
id,
|
|
86
|
+
onChange,
|
|
87
|
+
...props
|
|
88
|
+
}, ref) => {
|
|
89
|
+
const generatedId = useId();
|
|
90
|
+
const inputId = id ?? `checkbox-${generatedId}`;
|
|
91
|
+
const [internalChecked, setInternalChecked] = useState(false);
|
|
92
|
+
const isControlled = checkedProp !== void 0;
|
|
93
|
+
const checked = isControlled ? checkedProp : internalChecked;
|
|
94
|
+
const handleChange = (event) => {
|
|
95
|
+
if (!isControlled) {
|
|
96
|
+
setInternalChecked(event.target.checked);
|
|
97
|
+
}
|
|
98
|
+
onChange?.(event);
|
|
99
|
+
};
|
|
100
|
+
const currentState = disabled ? "disabled" : state;
|
|
101
|
+
const sizeClasses = SIZE_CLASSES[size];
|
|
102
|
+
const checkVariant = checked || indeterminate ? "checked" : "unchecked";
|
|
103
|
+
const stylingClasses = STATE_CLASSES[currentState][checkVariant];
|
|
104
|
+
const borderWidthClass = state === "focused" || state === "hovered" && size === "large" ? "border-[3px]" : sizeClasses.borderWidth;
|
|
105
|
+
const checkboxClasses = `${BASE_CHECKBOX_CLASSES} ${sizeClasses.checkbox} ${borderWidthClass} ${stylingClasses} ${className}`;
|
|
106
|
+
const renderIcon = () => {
|
|
107
|
+
if (indeterminate) {
|
|
108
|
+
return /* @__PURE__ */ jsx(
|
|
109
|
+
Minus,
|
|
110
|
+
{
|
|
111
|
+
size: sizeClasses.iconSize,
|
|
112
|
+
weight: "bold",
|
|
113
|
+
color: "currentColor"
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (checked) {
|
|
118
|
+
return /* @__PURE__ */ jsx(
|
|
119
|
+
Check,
|
|
120
|
+
{
|
|
121
|
+
size: sizeClasses.iconSize,
|
|
122
|
+
weight: "bold",
|
|
123
|
+
color: "currentColor"
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
};
|
|
129
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
130
|
+
/* @__PURE__ */ jsxs(
|
|
131
|
+
"div",
|
|
132
|
+
{
|
|
133
|
+
className: `flex flex-row items-center ${sizeClasses.spacing} ${disabled ? "opacity-40" : ""}`,
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ jsx(
|
|
136
|
+
"input",
|
|
137
|
+
{
|
|
138
|
+
ref,
|
|
139
|
+
type: "checkbox",
|
|
140
|
+
id: inputId,
|
|
141
|
+
checked,
|
|
142
|
+
disabled,
|
|
143
|
+
onChange: handleChange,
|
|
144
|
+
className: "sr-only",
|
|
145
|
+
...props
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ jsx("label", { htmlFor: inputId, className: checkboxClasses, children: renderIcon() }),
|
|
149
|
+
label && /* @__PURE__ */ jsx(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
className: `flex flex-row items-center ${sizeClasses.labelHeight}`,
|
|
153
|
+
children: /* @__PURE__ */ jsx(
|
|
154
|
+
Text,
|
|
155
|
+
{
|
|
156
|
+
as: "label",
|
|
157
|
+
htmlFor: inputId,
|
|
158
|
+
size: sizeClasses.textSize,
|
|
159
|
+
weight: "normal",
|
|
160
|
+
className: `cursor-pointer select-none leading-[150%] flex items-center font-roboto ${labelClassName}`,
|
|
161
|
+
children: label
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
errorMessage && /* @__PURE__ */ jsx(
|
|
170
|
+
Text,
|
|
171
|
+
{
|
|
172
|
+
size: "sm",
|
|
173
|
+
weight: "normal",
|
|
174
|
+
className: "mt-1.5",
|
|
175
|
+
color: "text-error-600",
|
|
176
|
+
children: errorMessage
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
helperText && !errorMessage && /* @__PURE__ */ jsx(
|
|
180
|
+
Text,
|
|
181
|
+
{
|
|
182
|
+
size: "sm",
|
|
183
|
+
weight: "normal",
|
|
184
|
+
className: "mt-1.5",
|
|
185
|
+
color: "text-text-500",
|
|
186
|
+
children: helperText
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
] });
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
CheckBox.displayName = "CheckBox";
|
|
193
|
+
export {
|
|
194
|
+
CheckBox
|
|
195
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, ButtonHTMLAttributes, HTMLAttributes } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
interface DropdownMenuProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const DropdownMenu: ({ children, open, onOpenChange }: DropdownMenuProps) => react_jsx_runtime.JSX.Element;
|
|
11
|
+
declare const DropdownMenuTrigger: react.ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & react.RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
declare const MenuLabel: react.ForwardRefExoticComponent<HTMLAttributes<HTMLFieldSetElement> & {
|
|
13
|
+
inset?: boolean;
|
|
14
|
+
} & react.RefAttributes<HTMLFieldSetElement>>;
|
|
15
|
+
declare const MenuContent: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
16
|
+
align?: "start" | "center" | "end";
|
|
17
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
18
|
+
sideOffset?: number;
|
|
19
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
declare const MenuItem: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
21
|
+
inset?: boolean;
|
|
22
|
+
size?: "small" | "medium";
|
|
23
|
+
iconLeft?: ReactNode;
|
|
24
|
+
iconRight?: ReactNode;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
27
|
+
declare const MenuSeparator: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & react.RefAttributes<HTMLDivElement>>;
|
|
28
|
+
|
|
29
|
+
export { DropdownMenu, DropdownMenuTrigger, MenuContent, MenuItem, MenuLabel, MenuSeparator };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, ButtonHTMLAttributes, HTMLAttributes } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
interface DropdownMenuProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const DropdownMenu: ({ children, open, onOpenChange }: DropdownMenuProps) => react_jsx_runtime.JSX.Element;
|
|
11
|
+
declare const DropdownMenuTrigger: react.ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & react.RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
declare const MenuLabel: react.ForwardRefExoticComponent<HTMLAttributes<HTMLFieldSetElement> & {
|
|
13
|
+
inset?: boolean;
|
|
14
|
+
} & react.RefAttributes<HTMLFieldSetElement>>;
|
|
15
|
+
declare const MenuContent: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
16
|
+
align?: "start" | "center" | "end";
|
|
17
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
18
|
+
sideOffset?: number;
|
|
19
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
declare const MenuItem: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
21
|
+
inset?: boolean;
|
|
22
|
+
size?: "small" | "medium";
|
|
23
|
+
iconLeft?: ReactNode;
|
|
24
|
+
iconRight?: ReactNode;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
27
|
+
declare const MenuSeparator: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & react.RefAttributes<HTMLDivElement>>;
|
|
28
|
+
|
|
29
|
+
export { DropdownMenu, DropdownMenuTrigger, MenuContent, MenuItem, MenuLabel, MenuSeparator };
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/DropdownMenu/DropdownMenu.tsx
|
|
22
|
+
var DropdownMenu_exports = {};
|
|
23
|
+
__export(DropdownMenu_exports, {
|
|
24
|
+
DropdownMenu: () => DropdownMenu,
|
|
25
|
+
DropdownMenuTrigger: () => DropdownMenuTrigger,
|
|
26
|
+
MenuContent: () => MenuContent,
|
|
27
|
+
MenuItem: () => MenuItem,
|
|
28
|
+
MenuLabel: () => MenuLabel,
|
|
29
|
+
MenuSeparator: () => MenuSeparator
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(DropdownMenu_exports);
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var DropdownMenuContext = (0, import_react.createContext)(
|
|
35
|
+
void 0
|
|
36
|
+
);
|
|
37
|
+
var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
38
|
+
const [internalOpen, setInternalOpen] = (0, import_react.useState)(false);
|
|
39
|
+
const isControlled = open !== void 0;
|
|
40
|
+
const currentOpen = isControlled ? open : internalOpen;
|
|
41
|
+
const setOpen = (0, import_react.useCallback)(
|
|
42
|
+
(newOpen) => {
|
|
43
|
+
if (onOpenChange) onOpenChange(newOpen);
|
|
44
|
+
if (!isControlled) setInternalOpen(newOpen);
|
|
45
|
+
},
|
|
46
|
+
[isControlled, onOpenChange]
|
|
47
|
+
);
|
|
48
|
+
const menuRef = (0, import_react.useRef)(null);
|
|
49
|
+
const handleArrowDownOrArrowUp = (event) => {
|
|
50
|
+
const menuContent = menuRef.current?.querySelector('[role="menu"]');
|
|
51
|
+
if (menuContent) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
const items = Array.from(
|
|
54
|
+
menuContent.querySelectorAll(
|
|
55
|
+
'[role="menuitem"]:not([aria-disabled="true"])'
|
|
56
|
+
)
|
|
57
|
+
).filter((el) => el instanceof HTMLElement);
|
|
58
|
+
if (items.length === 0) return;
|
|
59
|
+
const focusedItem = document.activeElement;
|
|
60
|
+
const currentIndex = items.findIndex((item) => item === focusedItem);
|
|
61
|
+
let nextIndex;
|
|
62
|
+
if (event.key === "ArrowDown") {
|
|
63
|
+
nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % items.length;
|
|
64
|
+
} else {
|
|
65
|
+
nextIndex = currentIndex === -1 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length;
|
|
66
|
+
}
|
|
67
|
+
items[nextIndex]?.focus();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const handleDownkey = (event) => {
|
|
71
|
+
if (event.key === "Escape") {
|
|
72
|
+
setOpen(false);
|
|
73
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
74
|
+
handleArrowDownOrArrowUp(event);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const handleClickOutside = (event) => {
|
|
78
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
79
|
+
setOpen(false);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
(0, import_react.useEffect)(() => {
|
|
83
|
+
if (currentOpen) {
|
|
84
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
85
|
+
document.addEventListener("keydown", handleDownkey);
|
|
86
|
+
}
|
|
87
|
+
return () => {
|
|
88
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
89
|
+
document.removeEventListener("keydown", handleDownkey);
|
|
90
|
+
};
|
|
91
|
+
}, [currentOpen]);
|
|
92
|
+
const value = (0, import_react.useMemo)(
|
|
93
|
+
() => ({ open: currentOpen, setOpen }),
|
|
94
|
+
[currentOpen, setOpen]
|
|
95
|
+
);
|
|
96
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative", ref: menuRef, children }) });
|
|
97
|
+
};
|
|
98
|
+
var DropdownMenuTrigger = (0, import_react.forwardRef)(({ className, children, onClick, ...props }, ref) => {
|
|
99
|
+
const context = (0, import_react.useContext)(DropdownMenuContext);
|
|
100
|
+
if (!context)
|
|
101
|
+
throw new Error("DropdownMenuTrigger must be used within a DropdownMenu");
|
|
102
|
+
const { open, setOpen } = context;
|
|
103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
ref,
|
|
107
|
+
className: `border border-border-200 cursor-pointer bg-background-muted hover:bg-background-200 transition-colors px-4 py-2 rounded-sm ${className}`,
|
|
108
|
+
onClick: (e) => {
|
|
109
|
+
e.stopPropagation();
|
|
110
|
+
setOpen(!open);
|
|
111
|
+
if (onClick) onClick(e);
|
|
112
|
+
},
|
|
113
|
+
"aria-expanded": open,
|
|
114
|
+
...props,
|
|
115
|
+
children
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
DropdownMenuTrigger.displayName = "DropdownMenuTrigger";
|
|
120
|
+
var ITEM_SIZE_CLASSES = {
|
|
121
|
+
small: "text-sm",
|
|
122
|
+
medium: "text-md"
|
|
123
|
+
};
|
|
124
|
+
var SIDE_CLASSES = {
|
|
125
|
+
top: "bottom-full",
|
|
126
|
+
right: "top-full",
|
|
127
|
+
bottom: "top-full",
|
|
128
|
+
left: "top-full"
|
|
129
|
+
};
|
|
130
|
+
var ALIGN_CLASSES = {
|
|
131
|
+
start: "left-0",
|
|
132
|
+
center: "left-1/2 -translate-x-1/2",
|
|
133
|
+
end: "right-0"
|
|
134
|
+
};
|
|
135
|
+
var MenuLabel = (0, import_react.forwardRef)(({ className, inset, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
136
|
+
"fieldset",
|
|
137
|
+
{
|
|
138
|
+
ref,
|
|
139
|
+
role: "group",
|
|
140
|
+
className: `text-sm w-full ${inset ? "pl-8" : ""} ${className ?? ""}`,
|
|
141
|
+
...props
|
|
142
|
+
}
|
|
143
|
+
));
|
|
144
|
+
MenuLabel.displayName = "MenuLabel";
|
|
145
|
+
var MenuContent = (0, import_react.forwardRef)(
|
|
146
|
+
({
|
|
147
|
+
className,
|
|
148
|
+
align = "start",
|
|
149
|
+
side = "bottom",
|
|
150
|
+
sideOffset = 4,
|
|
151
|
+
children,
|
|
152
|
+
...props
|
|
153
|
+
}, ref) => {
|
|
154
|
+
const { open } = (0, import_react.useContext)(DropdownMenuContext);
|
|
155
|
+
const [isVisible, setIsVisible] = (0, import_react.useState)(open);
|
|
156
|
+
(0, import_react.useEffect)(() => {
|
|
157
|
+
if (open) {
|
|
158
|
+
setIsVisible(true);
|
|
159
|
+
} else {
|
|
160
|
+
const timer = setTimeout(() => setIsVisible(false), 200);
|
|
161
|
+
return () => clearTimeout(timer);
|
|
162
|
+
}
|
|
163
|
+
}, [open]);
|
|
164
|
+
if (!isVisible) return null;
|
|
165
|
+
const getPositionClasses = () => {
|
|
166
|
+
const vertical = SIDE_CLASSES[side];
|
|
167
|
+
const horizontal = ALIGN_CLASSES[align];
|
|
168
|
+
return `absolute ${vertical} ${horizontal}`;
|
|
169
|
+
};
|
|
170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
ref,
|
|
174
|
+
role: "menu",
|
|
175
|
+
className: `
|
|
176
|
+
bg-background z-50 min-w-[210px] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md border-border-100
|
|
177
|
+
${open ? "animate-in fade-in-0 zoom-in-95" : "animate-out fade-out-0 zoom-out-95"}
|
|
178
|
+
${getPositionClasses()}
|
|
179
|
+
${className}
|
|
180
|
+
`,
|
|
181
|
+
style: {
|
|
182
|
+
marginTop: side === "bottom" ? sideOffset : void 0,
|
|
183
|
+
marginBottom: side === "top" ? sideOffset : void 0,
|
|
184
|
+
marginLeft: side === "right" ? sideOffset : void 0,
|
|
185
|
+
marginRight: side === "left" ? sideOffset : void 0
|
|
186
|
+
},
|
|
187
|
+
...props,
|
|
188
|
+
children
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
MenuContent.displayName = "MenuContent";
|
|
194
|
+
var MenuItem = (0, import_react.forwardRef)(
|
|
195
|
+
({
|
|
196
|
+
className,
|
|
197
|
+
inset,
|
|
198
|
+
size = "small",
|
|
199
|
+
children,
|
|
200
|
+
iconRight,
|
|
201
|
+
iconLeft,
|
|
202
|
+
disabled = false,
|
|
203
|
+
onClick,
|
|
204
|
+
...props
|
|
205
|
+
}, ref) => {
|
|
206
|
+
const sizeClasses = ITEM_SIZE_CLASSES[size];
|
|
207
|
+
const handleClick = (e) => {
|
|
208
|
+
if (disabled) {
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
e.stopPropagation();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
onClick?.(e);
|
|
214
|
+
};
|
|
215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
216
|
+
"div",
|
|
217
|
+
{
|
|
218
|
+
ref,
|
|
219
|
+
role: "menuitem",
|
|
220
|
+
"aria-disabled": disabled,
|
|
221
|
+
className: `
|
|
222
|
+
focus-visible:bg-background-50
|
|
223
|
+
relative flex select-none items-center gap-2 rounded-sm p-3 text-sm outline-none transition-colors [&>svg]:size-4 [&>svg]:shrink-0
|
|
224
|
+
${inset && "pl-8"}
|
|
225
|
+
${sizeClasses}
|
|
226
|
+
${className}
|
|
227
|
+
${disabled ? "cursor-not-allowed text-text-400" : "cursor-pointer hover:bg-background-50 text-text-700 focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground"}
|
|
228
|
+
`,
|
|
229
|
+
onClick: handleClick,
|
|
230
|
+
onKeyDown: (e) => {
|
|
231
|
+
if (e.key === "Enter" || e.key === " ") handleClick(e);
|
|
232
|
+
},
|
|
233
|
+
tabIndex: disabled ? -1 : 0,
|
|
234
|
+
...props,
|
|
235
|
+
children: [
|
|
236
|
+
iconLeft,
|
|
237
|
+
children,
|
|
238
|
+
iconRight
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
MenuItem.displayName = "MenuItem";
|
|
245
|
+
var MenuSeparator = (0, import_react.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
246
|
+
"div",
|
|
247
|
+
{
|
|
248
|
+
ref,
|
|
249
|
+
className: `my-1 h-px bg-border-200 ${className}`,
|
|
250
|
+
...props
|
|
251
|
+
}
|
|
252
|
+
));
|
|
253
|
+
MenuSeparator.displayName = "MenuSeparator";
|
|
254
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
255
|
+
0 && (module.exports = {
|
|
256
|
+
DropdownMenu,
|
|
257
|
+
DropdownMenuTrigger,
|
|
258
|
+
MenuContent,
|
|
259
|
+
MenuItem,
|
|
260
|
+
MenuLabel,
|
|
261
|
+
MenuSeparator
|
|
262
|
+
});
|