@fuf-stack/pixels 0.1.1 → 0.2.1
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/Json/Json.cjs +204 -0
- package/dist/Json/Json.cjs.map +1 -0
- package/dist/Json/Json.d.cts +16 -0
- package/dist/Json/Json.d.ts +16 -0
- package/dist/Json/Json.js +10 -0
- package/dist/Json/Json.js.map +1 -0
- package/dist/Json/index.cjs +209 -0
- package/dist/Json/index.cjs.map +1 -0
- package/dist/Json/index.d.cts +6 -0
- package/dist/Json/index.d.ts +6 -0
- package/dist/Json/index.js +13 -0
- package/dist/Json/index.js.map +1 -0
- package/dist/Menu/Menu.cjs +12 -92
- package/dist/Menu/Menu.cjs.map +1 -1
- package/dist/Menu/Menu.js +1 -4
- package/dist/Menu/index.cjs +12 -92
- package/dist/Menu/index.cjs.map +1 -1
- package/dist/Menu/index.js +1 -4
- package/dist/Menu/index.js.map +1 -1
- package/dist/chunk-3EFVWEGP.js +94 -0
- package/dist/chunk-3EFVWEGP.js.map +1 -0
- package/dist/{chunk-K3QI56MF.js → chunk-Y35GJHOR.js} +6 -6
- package/dist/chunk-Y35GJHOR.js.map +1 -0
- package/package.json +3 -3
- package/dist/chunk-K3QI56MF.js.map +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/Json/Json.tsx
|
|
31
|
+
var Json_exports = {};
|
|
32
|
+
__export(Json_exports, {
|
|
33
|
+
default: () => Json_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(Json_exports);
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_fa = require("react-icons/fa");
|
|
38
|
+
var import_react_json_view = __toESM(require("react-json-view"), 1);
|
|
39
|
+
var import_classnames2 = __toESM(require("classnames"), 1);
|
|
40
|
+
|
|
41
|
+
// src/Button/Button.tsx
|
|
42
|
+
var import_button = require("@nextui-org/button");
|
|
43
|
+
var import_classnames = __toESM(require("classnames"), 1);
|
|
44
|
+
|
|
45
|
+
// src/Button/subcomponents/LoadingSpinner.tsx
|
|
46
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
+
var LoadingSpinner_default = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
48
|
+
"svg",
|
|
49
|
+
{
|
|
50
|
+
className: "animate-spin h-5 w-5 text-current",
|
|
51
|
+
fill: "none",
|
|
52
|
+
viewBox: "0 0 24 24",
|
|
53
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
|
+
"circle",
|
|
57
|
+
{
|
|
58
|
+
className: "opacity-25",
|
|
59
|
+
cx: "12",
|
|
60
|
+
cy: "12",
|
|
61
|
+
r: "10",
|
|
62
|
+
stroke: "currentColor",
|
|
63
|
+
strokeWidth: "4"
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
67
|
+
"path",
|
|
68
|
+
{
|
|
69
|
+
className: "opacity-75",
|
|
70
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",
|
|
71
|
+
fill: "currentColor"
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// src/Button/Button.tsx
|
|
79
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
80
|
+
var Button = ({
|
|
81
|
+
ariaLabel = void 0,
|
|
82
|
+
children = void 0,
|
|
83
|
+
className = void 0,
|
|
84
|
+
color = "default",
|
|
85
|
+
disabled = false,
|
|
86
|
+
icon = void 0,
|
|
87
|
+
loading = false,
|
|
88
|
+
onClick = void 0,
|
|
89
|
+
size = void 0,
|
|
90
|
+
testId = void 0,
|
|
91
|
+
type = void 0,
|
|
92
|
+
variant = "solid",
|
|
93
|
+
...passthrouhProps
|
|
94
|
+
}) => {
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
96
|
+
import_button.Button,
|
|
97
|
+
{
|
|
98
|
+
"aria-label": ariaLabel,
|
|
99
|
+
className: (0, import_classnames.default)(className),
|
|
100
|
+
color,
|
|
101
|
+
"data-testid": testId,
|
|
102
|
+
isDisabled: disabled,
|
|
103
|
+
isIconOnly: !!(icon && !children),
|
|
104
|
+
isLoading: loading,
|
|
105
|
+
onPress: onClick,
|
|
106
|
+
size,
|
|
107
|
+
spinner: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingSpinner_default, {}),
|
|
108
|
+
type,
|
|
109
|
+
variant,
|
|
110
|
+
...passthrouhProps,
|
|
111
|
+
children: [
|
|
112
|
+
icon,
|
|
113
|
+
children
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
var Button_default = Button;
|
|
119
|
+
|
|
120
|
+
// src/Button/index.ts
|
|
121
|
+
var Button_default2 = Button_default;
|
|
122
|
+
|
|
123
|
+
// src/Json/Json.tsx
|
|
124
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
125
|
+
var getValue = (value) => {
|
|
126
|
+
if (typeof value === "string") {
|
|
127
|
+
return JSON.parse(value);
|
|
128
|
+
}
|
|
129
|
+
if (typeof value === "object") {
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
throw new Error(`${typeof value} can not be visualized`);
|
|
133
|
+
};
|
|
134
|
+
var Json = ({ className = null, collapsed = false, value }) => {
|
|
135
|
+
const isDarkMode = document.body.classList.contains("dark");
|
|
136
|
+
let content = null;
|
|
137
|
+
let error = null;
|
|
138
|
+
const [showDetails, setShowDetails] = (0, import_react.useState)(false);
|
|
139
|
+
try {
|
|
140
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
141
|
+
import_react_json_view.default,
|
|
142
|
+
{
|
|
143
|
+
theme: isDarkMode ? "tomorrow" : "rjv-default",
|
|
144
|
+
style: {
|
|
145
|
+
fontSize: "12px",
|
|
146
|
+
backgroundColor: "unset"
|
|
147
|
+
},
|
|
148
|
+
name: false,
|
|
149
|
+
displayDataTypes: false,
|
|
150
|
+
src: getValue(value),
|
|
151
|
+
collapsed
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
} catch (err) {
|
|
155
|
+
error = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: "mb-4 flex flex-col items-center rounded-lg border border-danger bg-danger-50 p-4 text-sm text-danger",
|
|
159
|
+
role: "alert",
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex w-full justify-between gap-6", children: [
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center", children: [
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_fa.FaTimesCircle, { className: "mr-2" }),
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "font-medium", children: "Failed to parse JSON data" })
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
167
|
+
Button_default2,
|
|
168
|
+
{
|
|
169
|
+
color: "danger",
|
|
170
|
+
size: "sm",
|
|
171
|
+
variant: "light",
|
|
172
|
+
onClick: () => setShowDetails(!showDetails),
|
|
173
|
+
children: showDetails ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
174
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_fa.FaChevronUp, {}),
|
|
175
|
+
" Hide Details"
|
|
176
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
177
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_fa.FaChevronDown, {}),
|
|
178
|
+
" Show Details"
|
|
179
|
+
] })
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
] }),
|
|
183
|
+
showDetails && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mt-4 w-full text-left", children: [
|
|
184
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
185
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "Error:" }),
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("pre", { children: [
|
|
187
|
+
err?.name,
|
|
188
|
+
": ",
|
|
189
|
+
err?.message
|
|
190
|
+
] })
|
|
191
|
+
] }),
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mt-4", children: [
|
|
193
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "Data:" }),
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { children: typeof value !== "string" ? JSON.stringify(value, null, 2) : value })
|
|
195
|
+
] })
|
|
196
|
+
] })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_classnames2.default)(className), children: error || content });
|
|
202
|
+
};
|
|
203
|
+
var Json_default = Json;
|
|
204
|
+
//# sourceMappingURL=Json.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Json/Json.tsx","../../src/Button/Button.tsx","../../src/Button/subcomponents/LoadingSpinner.tsx","../../src/Button/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { useState } from 'react';\nimport { FaChevronDown, FaChevronUp, FaTimesCircle } from 'react-icons/fa';\nimport ReactJson from 'react-json-view';\n\nimport cn from 'classnames';\n\nimport Button from '../Button';\n\n/**\n * returns the value (JSON string or object) as object\n */\nconst getValue = (value: string | object) => {\n if (typeof value === 'string') {\n return JSON.parse(value);\n }\n if (typeof value === 'object') {\n return value;\n }\n throw new Error(`${typeof value} can not be visualized`);\n};\n\nexport interface JsonProps {\n /** CSS class name */\n className?: string | string[] | null;\n /** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. */\n collapsed?: boolean | number;\n /** Object to be visualized JSON string or object */\n value: string | object;\n}\n\n/**\n * Json renderer based on [react-json-view](https://mac-s-g.github.io/react-json-view/demo/dist/)\n */\nconst Json = ({ className = null, collapsed = false, value }: JsonProps) => {\n const isDarkMode = document.body.classList.contains('dark');\n\n let content: ReactNode = null;\n let error: ReactNode = null;\n\n const [showDetails, setShowDetails] = useState(false);\n\n try {\n content = (\n <ReactJson\n theme={isDarkMode ? 'tomorrow' : 'rjv-default'}\n style={{\n fontSize: '12px',\n backgroundColor: 'unset',\n }}\n name={false}\n displayDataTypes={false}\n src={getValue(value)}\n collapsed={collapsed}\n />\n );\n } catch (err) {\n error = (\n <div\n className=\"mb-4 flex flex-col items-center rounded-lg border border-danger bg-danger-50 p-4 text-sm text-danger\"\n role=\"alert\"\n >\n <div className=\"flex w-full justify-between gap-6\">\n <div className=\"flex items-center\">\n <FaTimesCircle className=\"mr-2\" />\n <span className=\"font-medium\">Failed to parse JSON data</span>\n </div>\n <Button\n color=\"danger\"\n size=\"sm\"\n variant=\"light\"\n onClick={() => setShowDetails(!showDetails)}\n >\n {showDetails ? (\n <>\n <FaChevronUp /> Hide Details\n </>\n ) : (\n <>\n <FaChevronDown /> Show Details\n </>\n )}\n </Button>\n </div>\n {showDetails && (\n <div className=\"mt-4 w-full text-left\">\n <div>\n <strong>Error:</strong>\n <pre>\n {/* @ts-expect-error is ok */}\n {err?.name}: {err?.message}\n </pre>\n </div>\n <div className=\"mt-4\">\n <strong>Data:</strong>\n <pre>\n {typeof value !== 'string'\n ? JSON.stringify(value, null, 2)\n : value}\n </pre>\n </div>\n </div>\n )}\n </div>\n );\n }\n return <div className={cn(className)}>{error || content}</div>;\n};\n\nexport default Json;\n","import type { ButtonProps as NextButtonProps } from '@nextui-org/button';\nimport type { ReactNode } from 'react';\n\nimport { Button as NextButton } from '@nextui-org/button';\nimport cn from 'classnames';\n\nimport LoadingSpinner from './subcomponents/LoadingSpinner';\n\nexport interface ButtonProps {\n /** sets HTML aria-label attribute */\n ariaLabel?: string;\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** next ui button color */\n color?: NextButtonProps['color'];\n /** disables function of the button. */\n disabled?: boolean;\n /** If set loading animation is shown */\n loading?: boolean;\n /** optional icon */\n icon?: ReactNode;\n /** on click event */\n onClick?: NextButtonProps['onPress'];\n /** 3 size options */\n size?: NextButtonProps['size'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** sets the button type. */\n type?: 'button' | 'submit' | 'reset' | undefined;\n /** next ui button variants */\n variant?: NextButtonProps['variant'];\n}\n\n/**\n * Button component based on [NextUI Button](https://nextui.org/docs/components/button)\n */\nconst Button = ({\n ariaLabel = undefined,\n children = undefined,\n className = undefined,\n color = 'default',\n disabled = false,\n icon = undefined,\n loading = false,\n onClick = undefined,\n size = undefined,\n testId = undefined,\n type = undefined,\n variant = 'solid',\n ...passthrouhProps\n}: ButtonProps) => {\n return (\n <NextButton\n aria-label={ariaLabel}\n className={cn(className)}\n color={color}\n data-testid={testId}\n isDisabled={disabled}\n isIconOnly={!!(icon && !children)}\n isLoading={loading}\n onPress={onClick}\n size={size}\n spinner={<LoadingSpinner />}\n type={type}\n variant={variant}\n {...passthrouhProps}\n >\n {icon}\n {children}\n </NextButton>\n );\n};\n\nexport default Button;\n","/**\n * svg loading spinner for button\n * @see https://nextui.org/docs/components/button#loading\n * */\nexport default () => (\n <svg\n className=\"animate-spin h-5 w-5 text-current\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n fill=\"currentColor\"\n />\n </svg>\n);\n","import type { ButtonProps } from './Button';\n\nimport Button from './Button';\n\nexport default Button;\n\nexport type { ButtonProps };\n"],"mappings":"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","names":["import_classnames","import_jsx_runtime","NextButton","cn","Button_default","import_jsx_runtime","ReactJson","Button_default","cn"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface JsonProps {
|
|
4
|
+
/** CSS class name */
|
|
5
|
+
className?: string | string[] | null;
|
|
6
|
+
/** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. */
|
|
7
|
+
collapsed?: boolean | number;
|
|
8
|
+
/** Object to be visualized JSON string or object */
|
|
9
|
+
value: string | object;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Json renderer based on [react-json-view](https://mac-s-g.github.io/react-json-view/demo/dist/)
|
|
13
|
+
*/
|
|
14
|
+
declare const Json: ({ className, collapsed, value }: JsonProps) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
|
|
16
|
+
export { type JsonProps, Json as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface JsonProps {
|
|
4
|
+
/** CSS class name */
|
|
5
|
+
className?: string | string[] | null;
|
|
6
|
+
/** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. */
|
|
7
|
+
collapsed?: boolean | number;
|
|
8
|
+
/** Object to be visualized JSON string or object */
|
|
9
|
+
value: string | object;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Json renderer based on [react-json-view](https://mac-s-g.github.io/react-json-view/demo/dist/)
|
|
13
|
+
*/
|
|
14
|
+
declare const Json: ({ className, collapsed, value }: JsonProps) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
|
|
16
|
+
export { type JsonProps, Json as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/Json/index.ts
|
|
31
|
+
var Json_exports = {};
|
|
32
|
+
__export(Json_exports, {
|
|
33
|
+
default: () => Json_default2
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(Json_exports);
|
|
36
|
+
|
|
37
|
+
// src/Json/Json.tsx
|
|
38
|
+
var import_react = require("react");
|
|
39
|
+
var import_fa = require("react-icons/fa");
|
|
40
|
+
var import_react_json_view = __toESM(require("react-json-view"), 1);
|
|
41
|
+
var import_classnames2 = __toESM(require("classnames"), 1);
|
|
42
|
+
|
|
43
|
+
// src/Button/Button.tsx
|
|
44
|
+
var import_button = require("@nextui-org/button");
|
|
45
|
+
var import_classnames = __toESM(require("classnames"), 1);
|
|
46
|
+
|
|
47
|
+
// src/Button/subcomponents/LoadingSpinner.tsx
|
|
48
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
|
+
var LoadingSpinner_default = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
50
|
+
"svg",
|
|
51
|
+
{
|
|
52
|
+
className: "animate-spin h-5 w-5 text-current",
|
|
53
|
+
fill: "none",
|
|
54
|
+
viewBox: "0 0 24 24",
|
|
55
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
|
+
"circle",
|
|
59
|
+
{
|
|
60
|
+
className: "opacity-25",
|
|
61
|
+
cx: "12",
|
|
62
|
+
cy: "12",
|
|
63
|
+
r: "10",
|
|
64
|
+
stroke: "currentColor",
|
|
65
|
+
strokeWidth: "4"
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
+
"path",
|
|
70
|
+
{
|
|
71
|
+
className: "opacity-75",
|
|
72
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",
|
|
73
|
+
fill: "currentColor"
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// src/Button/Button.tsx
|
|
81
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
82
|
+
var Button = ({
|
|
83
|
+
ariaLabel = void 0,
|
|
84
|
+
children = void 0,
|
|
85
|
+
className = void 0,
|
|
86
|
+
color = "default",
|
|
87
|
+
disabled = false,
|
|
88
|
+
icon = void 0,
|
|
89
|
+
loading = false,
|
|
90
|
+
onClick = void 0,
|
|
91
|
+
size = void 0,
|
|
92
|
+
testId = void 0,
|
|
93
|
+
type = void 0,
|
|
94
|
+
variant = "solid",
|
|
95
|
+
...passthrouhProps
|
|
96
|
+
}) => {
|
|
97
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
98
|
+
import_button.Button,
|
|
99
|
+
{
|
|
100
|
+
"aria-label": ariaLabel,
|
|
101
|
+
className: (0, import_classnames.default)(className),
|
|
102
|
+
color,
|
|
103
|
+
"data-testid": testId,
|
|
104
|
+
isDisabled: disabled,
|
|
105
|
+
isIconOnly: !!(icon && !children),
|
|
106
|
+
isLoading: loading,
|
|
107
|
+
onPress: onClick,
|
|
108
|
+
size,
|
|
109
|
+
spinner: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingSpinner_default, {}),
|
|
110
|
+
type,
|
|
111
|
+
variant,
|
|
112
|
+
...passthrouhProps,
|
|
113
|
+
children: [
|
|
114
|
+
icon,
|
|
115
|
+
children
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
var Button_default = Button;
|
|
121
|
+
|
|
122
|
+
// src/Button/index.ts
|
|
123
|
+
var Button_default2 = Button_default;
|
|
124
|
+
|
|
125
|
+
// src/Json/Json.tsx
|
|
126
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
127
|
+
var getValue = (value) => {
|
|
128
|
+
if (typeof value === "string") {
|
|
129
|
+
return JSON.parse(value);
|
|
130
|
+
}
|
|
131
|
+
if (typeof value === "object") {
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
throw new Error(`${typeof value} can not be visualized`);
|
|
135
|
+
};
|
|
136
|
+
var Json = ({ className = null, collapsed = false, value }) => {
|
|
137
|
+
const isDarkMode = document.body.classList.contains("dark");
|
|
138
|
+
let content = null;
|
|
139
|
+
let error = null;
|
|
140
|
+
const [showDetails, setShowDetails] = (0, import_react.useState)(false);
|
|
141
|
+
try {
|
|
142
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
143
|
+
import_react_json_view.default,
|
|
144
|
+
{
|
|
145
|
+
theme: isDarkMode ? "tomorrow" : "rjv-default",
|
|
146
|
+
style: {
|
|
147
|
+
fontSize: "12px",
|
|
148
|
+
backgroundColor: "unset"
|
|
149
|
+
},
|
|
150
|
+
name: false,
|
|
151
|
+
displayDataTypes: false,
|
|
152
|
+
src: getValue(value),
|
|
153
|
+
collapsed
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
error = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
className: "mb-4 flex flex-col items-center rounded-lg border border-danger bg-danger-50 p-4 text-sm text-danger",
|
|
161
|
+
role: "alert",
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex w-full justify-between gap-6", children: [
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center", children: [
|
|
165
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_fa.FaTimesCircle, { className: "mr-2" }),
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "font-medium", children: "Failed to parse JSON data" })
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
169
|
+
Button_default2,
|
|
170
|
+
{
|
|
171
|
+
color: "danger",
|
|
172
|
+
size: "sm",
|
|
173
|
+
variant: "light",
|
|
174
|
+
onClick: () => setShowDetails(!showDetails),
|
|
175
|
+
children: showDetails ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
176
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_fa.FaChevronUp, {}),
|
|
177
|
+
" Hide Details"
|
|
178
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
179
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_fa.FaChevronDown, {}),
|
|
180
|
+
" Show Details"
|
|
181
|
+
] })
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
] }),
|
|
185
|
+
showDetails && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mt-4 w-full text-left", children: [
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "Error:" }),
|
|
188
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("pre", { children: [
|
|
189
|
+
err?.name,
|
|
190
|
+
": ",
|
|
191
|
+
err?.message
|
|
192
|
+
] })
|
|
193
|
+
] }),
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mt-4", children: [
|
|
195
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "Data:" }),
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { children: typeof value !== "string" ? JSON.stringify(value, null, 2) : value })
|
|
197
|
+
] })
|
|
198
|
+
] })
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_classnames2.default)(className), children: error || content });
|
|
204
|
+
};
|
|
205
|
+
var Json_default = Json;
|
|
206
|
+
|
|
207
|
+
// src/Json/index.ts
|
|
208
|
+
var Json_default2 = Json_default;
|
|
209
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Json/index.ts","../../src/Json/Json.tsx","../../src/Button/Button.tsx","../../src/Button/subcomponents/LoadingSpinner.tsx","../../src/Button/index.ts"],"sourcesContent":["import Json from './Json';\n\nexport default Json;\n","import type { ReactNode } from 'react';\n\nimport { useState } from 'react';\nimport { FaChevronDown, FaChevronUp, FaTimesCircle } from 'react-icons/fa';\nimport ReactJson from 'react-json-view';\n\nimport cn from 'classnames';\n\nimport Button from '../Button';\n\n/**\n * returns the value (JSON string or object) as object\n */\nconst getValue = (value: string | object) => {\n if (typeof value === 'string') {\n return JSON.parse(value);\n }\n if (typeof value === 'object') {\n return value;\n }\n throw new Error(`${typeof value} can not be visualized`);\n};\n\nexport interface JsonProps {\n /** CSS class name */\n className?: string | string[] | null;\n /** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. */\n collapsed?: boolean | number;\n /** Object to be visualized JSON string or object */\n value: string | object;\n}\n\n/**\n * Json renderer based on [react-json-view](https://mac-s-g.github.io/react-json-view/demo/dist/)\n */\nconst Json = ({ className = null, collapsed = false, value }: JsonProps) => {\n const isDarkMode = document.body.classList.contains('dark');\n\n let content: ReactNode = null;\n let error: ReactNode = null;\n\n const [showDetails, setShowDetails] = useState(false);\n\n try {\n content = (\n <ReactJson\n theme={isDarkMode ? 'tomorrow' : 'rjv-default'}\n style={{\n fontSize: '12px',\n backgroundColor: 'unset',\n }}\n name={false}\n displayDataTypes={false}\n src={getValue(value)}\n collapsed={collapsed}\n />\n );\n } catch (err) {\n error = (\n <div\n className=\"mb-4 flex flex-col items-center rounded-lg border border-danger bg-danger-50 p-4 text-sm text-danger\"\n role=\"alert\"\n >\n <div className=\"flex w-full justify-between gap-6\">\n <div className=\"flex items-center\">\n <FaTimesCircle className=\"mr-2\" />\n <span className=\"font-medium\">Failed to parse JSON data</span>\n </div>\n <Button\n color=\"danger\"\n size=\"sm\"\n variant=\"light\"\n onClick={() => setShowDetails(!showDetails)}\n >\n {showDetails ? (\n <>\n <FaChevronUp /> Hide Details\n </>\n ) : (\n <>\n <FaChevronDown /> Show Details\n </>\n )}\n </Button>\n </div>\n {showDetails && (\n <div className=\"mt-4 w-full text-left\">\n <div>\n <strong>Error:</strong>\n <pre>\n {/* @ts-expect-error is ok */}\n {err?.name}: {err?.message}\n </pre>\n </div>\n <div className=\"mt-4\">\n <strong>Data:</strong>\n <pre>\n {typeof value !== 'string'\n ? JSON.stringify(value, null, 2)\n : value}\n </pre>\n </div>\n </div>\n )}\n </div>\n );\n }\n return <div className={cn(className)}>{error || content}</div>;\n};\n\nexport default Json;\n","import type { ButtonProps as NextButtonProps } from '@nextui-org/button';\nimport type { ReactNode } from 'react';\n\nimport { Button as NextButton } from '@nextui-org/button';\nimport cn from 'classnames';\n\nimport LoadingSpinner from './subcomponents/LoadingSpinner';\n\nexport interface ButtonProps {\n /** sets HTML aria-label attribute */\n ariaLabel?: string;\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** next ui button color */\n color?: NextButtonProps['color'];\n /** disables function of the button. */\n disabled?: boolean;\n /** If set loading animation is shown */\n loading?: boolean;\n /** optional icon */\n icon?: ReactNode;\n /** on click event */\n onClick?: NextButtonProps['onPress'];\n /** 3 size options */\n size?: NextButtonProps['size'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** sets the button type. */\n type?: 'button' | 'submit' | 'reset' | undefined;\n /** next ui button variants */\n variant?: NextButtonProps['variant'];\n}\n\n/**\n * Button component based on [NextUI Button](https://nextui.org/docs/components/button)\n */\nconst Button = ({\n ariaLabel = undefined,\n children = undefined,\n className = undefined,\n color = 'default',\n disabled = false,\n icon = undefined,\n loading = false,\n onClick = undefined,\n size = undefined,\n testId = undefined,\n type = undefined,\n variant = 'solid',\n ...passthrouhProps\n}: ButtonProps) => {\n return (\n <NextButton\n aria-label={ariaLabel}\n className={cn(className)}\n color={color}\n data-testid={testId}\n isDisabled={disabled}\n isIconOnly={!!(icon && !children)}\n isLoading={loading}\n onPress={onClick}\n size={size}\n spinner={<LoadingSpinner />}\n type={type}\n variant={variant}\n {...passthrouhProps}\n >\n {icon}\n {children}\n </NextButton>\n );\n};\n\nexport default Button;\n","/**\n * svg loading spinner for button\n * @see https://nextui.org/docs/components/button#loading\n * */\nexport default () => (\n <svg\n className=\"animate-spin h-5 w-5 text-current\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n fill=\"currentColor\"\n />\n </svg>\n);\n","import type { ButtonProps } from './Button';\n\nimport Button from './Button';\n\nexport default Button;\n\nexport type { ButtonProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACEA,mBAAyB;AACzB,gBAA0D;AAC1D,6BAAsB;AAEtB,IAAAC,qBAAe;;;ACHf,oBAAqC;AACrC,wBAAe;;;ACCb;AADF,IAAO,yBAAQ,MACb;AAAA,EAAC;AAAA;AAAA,IACC,WAAU;AAAA,IACV,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,OAAM;AAAA,IAEN;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,IAAG;AAAA,UACH,IAAG;AAAA,UACH,GAAE;AAAA,UACF,QAAO;AAAA,UACP,aAAY;AAAA;AAAA,MACd;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,GAAE;AAAA,UACF,MAAK;AAAA;AAAA,MACP;AAAA;AAAA;AACF;;;AD8BE,IAAAC,sBAAA;AAhBJ,IAAM,SAAS,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AAAA,EACV,GAAG;AACL,MAAmB;AACjB,SACE;AAAA,IAAC,cAAAC;AAAA,IAAA;AAAA,MACC,cAAY;AAAA,MACZ,eAAW,kBAAAC,SAAG,SAAS;AAAA,MACvB;AAAA,MACA,eAAa;AAAA,MACb,YAAY;AAAA,MACZ,YAAY,CAAC,EAAE,QAAQ,CAAC;AAAA,MACxB,WAAW;AAAA,MACX,SAAS;AAAA,MACT;AAAA,MACA,SAAS,6CAAC,0BAAe;AAAA,MACzB;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,iBAAQ;;;AEvEf,IAAOC,kBAAQ;;;AHyCT,IAAAC,sBAAA;AAhCN,IAAM,WAAW,CAAC,UAA2B;AAC3C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,QAAM,IAAI,MAAM,GAAG,OAAO,KAAK,wBAAwB;AACzD;AAcA,IAAM,OAAO,CAAC,EAAE,YAAY,MAAM,YAAY,OAAO,MAAM,MAAiB;AAC1E,QAAM,aAAa,SAAS,KAAK,UAAU,SAAS,MAAM;AAE1D,MAAI,UAAqB;AACzB,MAAI,QAAmB;AAEvB,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,KAAK;AAEpD,MAAI;AACF,cACE;AAAA,MAAC,uBAAAC;AAAA,MAAA;AAAA,QACC,OAAO,aAAa,aAAa;AAAA,QACjC,OAAO;AAAA,UACL,UAAU;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,QACA,MAAM;AAAA,QACN,kBAAkB;AAAA,QAClB,KAAK,SAAS,KAAK;AAAA,QACnB;AAAA;AAAA,IACF;AAAA,EAEJ,SAAS,KAAK;AACZ,YACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,MAAK;AAAA,QAEL;AAAA,wDAAC,SAAI,WAAU,qCACb;AAAA,0DAAC,SAAI,WAAU,qBACb;AAAA,2DAAC,2BAAc,WAAU,QAAO;AAAA,cAChC,6CAAC,UAAK,WAAU,eAAc,uCAAyB;AAAA,eACzD;AAAA,YACA;AAAA,cAACC;AAAA,cAAA;AAAA,gBACC,OAAM;AAAA,gBACN,MAAK;AAAA,gBACL,SAAQ;AAAA,gBACR,SAAS,MAAM,eAAe,CAAC,WAAW;AAAA,gBAEzC,wBACC,8EACE;AAAA,+DAAC,yBAAY;AAAA,kBAAE;AAAA,mBACjB,IAEA,8EACE;AAAA,+DAAC,2BAAc;AAAA,kBAAE;AAAA,mBACnB;AAAA;AAAA,YAEJ;AAAA,aACF;AAAA,UACC,eACC,8CAAC,SAAI,WAAU,yBACb;AAAA,0DAAC,SACC;AAAA,2DAAC,YAAO,oBAAM;AAAA,cACd,8CAAC,SAEE;AAAA,qBAAK;AAAA,gBAAK;AAAA,gBAAG,KAAK;AAAA,iBACrB;AAAA,eACF;AAAA,YACA,8CAAC,SAAI,WAAU,QACb;AAAA,2DAAC,YAAO,mBAAK;AAAA,cACb,6CAAC,SACE,iBAAO,UAAU,WACd,KAAK,UAAU,OAAO,MAAM,CAAC,IAC7B,OACN;AAAA,eACF;AAAA,aACF;AAAA;AAAA;AAAA,IAEJ;AAAA,EAEJ;AACA,SAAO,6CAAC,SAAI,eAAW,mBAAAC,SAAG,SAAS,GAAI,mBAAS,SAAQ;AAC1D;AAEA,IAAO,eAAQ;;;AD5Gf,IAAOC,gBAAQ;","names":["Json_default","import_classnames","import_jsx_runtime","NextButton","cn","Button_default","import_jsx_runtime","ReactJson","Button_default","cn","Json_default"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Json_default
|
|
3
|
+
} from "../chunk-3EFVWEGP.js";
|
|
4
|
+
import "../chunk-NFWS2SSN.js";
|
|
5
|
+
import "../chunk-6QVKZ4AT.js";
|
|
6
|
+
import "../chunk-ZFEVTQWW.js";
|
|
7
|
+
|
|
8
|
+
// src/Json/index.ts
|
|
9
|
+
var Json_default2 = Json_default;
|
|
10
|
+
export {
|
|
11
|
+
Json_default2 as default
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Json/index.ts"],"sourcesContent":["import Json from './Json';\n\nexport default Json;\n"],"mappings":";;;;;;;;AAEA,IAAOA,gBAAQ;","names":["Json_default"]}
|
package/dist/Menu/Menu.cjs
CHANGED
|
@@ -34,101 +34,18 @@ __export(Menu_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(Menu_exports);
|
|
36
36
|
var import_fa6 = require("react-icons/fa6");
|
|
37
|
-
var import_dropdown = require("@nextui-org/dropdown");
|
|
38
|
-
var import_classnames2 = __toESM(require("classnames"), 1);
|
|
39
|
-
var import_debug = __toESM(require("debug"), 1);
|
|
40
|
-
|
|
41
|
-
// src/Button/Button.tsx
|
|
42
37
|
var import_button = require("@nextui-org/button");
|
|
38
|
+
var import_dropdown = require("@nextui-org/dropdown");
|
|
43
39
|
var import_classnames = __toESM(require("classnames"), 1);
|
|
44
|
-
|
|
45
|
-
// src/Button/subcomponents/LoadingSpinner.tsx
|
|
40
|
+
var import_debug = __toESM(require("debug"), 1);
|
|
46
41
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
-
var LoadingSpinner_default = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
48
|
-
"svg",
|
|
49
|
-
{
|
|
50
|
-
className: "animate-spin h-5 w-5 text-current",
|
|
51
|
-
fill: "none",
|
|
52
|
-
viewBox: "0 0 24 24",
|
|
53
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
-
children: [
|
|
55
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
|
-
"circle",
|
|
57
|
-
{
|
|
58
|
-
className: "opacity-25",
|
|
59
|
-
cx: "12",
|
|
60
|
-
cy: "12",
|
|
61
|
-
r: "10",
|
|
62
|
-
stroke: "currentColor",
|
|
63
|
-
strokeWidth: "4"
|
|
64
|
-
}
|
|
65
|
-
),
|
|
66
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
67
|
-
"path",
|
|
68
|
-
{
|
|
69
|
-
className: "opacity-75",
|
|
70
|
-
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",
|
|
71
|
-
fill: "currentColor"
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
// src/Button/Button.tsx
|
|
79
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
80
|
-
var Button = ({
|
|
81
|
-
ariaLabel = void 0,
|
|
82
|
-
children = void 0,
|
|
83
|
-
className = void 0,
|
|
84
|
-
color = "default",
|
|
85
|
-
disabled = false,
|
|
86
|
-
icon = void 0,
|
|
87
|
-
loading = false,
|
|
88
|
-
onClick = void 0,
|
|
89
|
-
size = void 0,
|
|
90
|
-
testId = void 0,
|
|
91
|
-
type = void 0,
|
|
92
|
-
variant = "solid",
|
|
93
|
-
...passthrouhProps
|
|
94
|
-
}) => {
|
|
95
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
96
|
-
import_button.Button,
|
|
97
|
-
{
|
|
98
|
-
"aria-label": ariaLabel,
|
|
99
|
-
className: (0, import_classnames.default)(className),
|
|
100
|
-
color,
|
|
101
|
-
"data-testid": testId,
|
|
102
|
-
isDisabled: disabled,
|
|
103
|
-
isIconOnly: !!(icon && !children),
|
|
104
|
-
isLoading: loading,
|
|
105
|
-
onPress: onClick,
|
|
106
|
-
size,
|
|
107
|
-
spinner: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingSpinner_default, {}),
|
|
108
|
-
type,
|
|
109
|
-
variant,
|
|
110
|
-
...passthrouhProps,
|
|
111
|
-
children: [
|
|
112
|
-
icon,
|
|
113
|
-
children
|
|
114
|
-
]
|
|
115
|
-
}
|
|
116
|
-
);
|
|
117
|
-
};
|
|
118
|
-
var Button_default = Button;
|
|
119
|
-
|
|
120
|
-
// src/Button/index.ts
|
|
121
|
-
var Button_default2 = Button_default;
|
|
122
|
-
|
|
123
|
-
// src/Menu/Menu.tsx
|
|
124
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
125
42
|
var debug = (0, import_debug.default)("component:Menu");
|
|
126
43
|
var getDisabledKeys = (items) => {
|
|
127
44
|
return items.map((item) => typeof item?.items === "undefined" ? item : item.items).flat().filter((item) => {
|
|
128
45
|
return Object.hasOwn(item, "disabled") && item.disabled === true;
|
|
129
46
|
}).map((item) => item.key);
|
|
130
47
|
};
|
|
131
|
-
var renderMenuItem = (item) => /* @__PURE__ */ (0,
|
|
48
|
+
var renderMenuItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
132
49
|
import_dropdown.DropdownItem,
|
|
133
50
|
{
|
|
134
51
|
className: item.className,
|
|
@@ -149,12 +66,15 @@ var Menu = ({
|
|
|
149
66
|
items
|
|
150
67
|
}) => {
|
|
151
68
|
debug("Menu", { items });
|
|
152
|
-
return /* @__PURE__ */ (0,
|
|
153
|
-
/* @__PURE__ */ (0,
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dropdown.Dropdown, { isDisabled, children: [
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dropdown.DropdownTrigger, { className: (0, import_classnames.default)(className), "data-testid": testId, children: children ? (
|
|
154
71
|
// eslint-disable-next-line react/button-has-type
|
|
155
|
-
/* @__PURE__ */ (0,
|
|
156
|
-
) :
|
|
157
|
-
|
|
72
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { children })
|
|
73
|
+
) : (
|
|
74
|
+
// INFO: we use next button here so that ref passing works
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", variant: "flat", className: "min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa6.FaEllipsisVertical, {}) })
|
|
76
|
+
) }),
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
158
78
|
import_dropdown.DropdownMenu,
|
|
159
79
|
{
|
|
160
80
|
items,
|
|
@@ -162,7 +82,7 @@ var Menu = ({
|
|
|
162
82
|
onAction,
|
|
163
83
|
children: (item) => {
|
|
164
84
|
if ("items" in item) {
|
|
165
|
-
return /* @__PURE__ */ (0,
|
|
85
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
166
86
|
import_dropdown.DropdownSection,
|
|
167
87
|
{
|
|
168
88
|
items: item.items,
|
package/dist/Menu/Menu.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Menu/Menu.tsx"
|
|
1
|
+
{"version":3,"sources":["../../src/Menu/Menu.tsx"],"sourcesContent":["import type { DropdownSectionProps } from '@nextui-org/dropdown';\nimport type { Key, MouseEventHandler, ReactNode } from 'react';\n\nimport { FaEllipsisVertical } from 'react-icons/fa6';\n\nimport { Button } from '@nextui-org/button';\nimport {\n Dropdown as NextDropdown,\n DropdownItem as NextDropdownItem,\n DropdownMenu as NextDropdownMenu,\n DropdownSection as NextDropdownSection,\n DropdownTrigger as NextDropdownTrigger,\n} from '@nextui-org/dropdown';\nimport cn from 'classnames';\nimport createDebug from 'debug';\n\nconst debug = createDebug('component:Menu');\n\n/**\n * Menu item type\n */\nexport interface MenuItem {\n /** unique identifier */\n key: string;\n /** CSS class name */\n className?: string;\n /** additional description shown under the label */\n description?: string;\n /** disables the menu item */\n disabled?: boolean;\n /** menu item icon */\n icon?: ReactNode;\n /** menu item name */\n label: ReactNode;\n /** click event handler */\n onClick?: MouseEventHandler<HTMLLIElement>;\n /** e2e test identifier */\n testId?: string;\n}\n\n/**\n * Menu section type\n */\nexport interface MenuSection {\n /** unique identifier */\n key: string;\n /** section label */\n label: ReactNode;\n /** section items (array of MenuItem) */\n items: MenuItem[];\n}\n\nexport interface MenuProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** menu item structure */\n items: (MenuSection | MenuItem)[];\n /** disable menu trigger */\n isDisabled?: boolean;\n /** called if item is selected */\n onAction?: (key: Key) => void;\n}\n\n/** returns String[] of disabled items/keys */\nconst getDisabledKeys = (items: (MenuSection | MenuItem)[]) => {\n return (\n items\n // @ts-expect-error typing issue with MenuSection | MenuItem\n .map((item) => (typeof item?.items === 'undefined' ? item : item.items))\n .flat<MenuItem[]>()\n .filter((item) => {\n return Object.hasOwn(item, 'disabled') && item.disabled === true;\n })\n .map((item) => item.key)\n );\n};\n\nconst renderMenuItem = (item: MenuItem) => (\n <NextDropdownItem\n className={item.className}\n data-testid={item.testId || item.key}\n description={item.description}\n key={item.key}\n onClick={item.onClick}\n startContent={item.icon}\n >\n {item.label}\n </NextDropdownItem>\n);\n\n/**\n * Dropdown menu component based on [NextUI Dropdown](https://nextui.org/docs/components/dropdown)\n */\nconst Menu = ({\n children = null,\n className = undefined,\n onAction = undefined,\n testId = undefined,\n isDisabled = false,\n items,\n}: MenuProps) => {\n debug('Menu', { items });\n\n return (\n <NextDropdown isDisabled={isDisabled}>\n <NextDropdownTrigger className={cn(className)} data-testid={testId}>\n {children ? (\n // eslint-disable-next-line react/button-has-type\n <button>{children}</button>\n ) : (\n // INFO: we use next button here so that ref passing works\n <Button size=\"sm\" variant=\"flat\" className=\"min-w-0\">\n <FaEllipsisVertical />\n </Button>\n )}\n </NextDropdownTrigger>\n <NextDropdownMenu\n // aria-label=\"Dynamic Actions\"\n items={items}\n disabledKeys={getDisabledKeys(items)}\n onAction={onAction}\n >\n {(item) => {\n if ('items' in item) {\n return (\n <NextDropdownSection\n items={item.items as MenuSection['items']}\n title={item.label as DropdownSectionProps['title']}\n key={item.key}\n >\n {/* @ts-expect-error ts problem here with render fn */}\n {(sectionItem) => {\n return renderMenuItem(sectionItem);\n }}\n </NextDropdownSection>\n );\n }\n return renderMenuItem(item);\n }}\n </NextDropdownMenu>\n </NextDropdown>\n );\n};\n\nexport default Menu;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAmC;AAEnC,oBAAuB;AACvB,sBAMO;AACP,wBAAe;AACf,mBAAwB;AAoEtB;AAlEF,IAAM,YAAQ,aAAAA,SAAY,gBAAgB;AAoD1C,IAAM,kBAAkB,CAAC,UAAsC;AAC7D,SACE,MAEG,IAAI,CAAC,SAAU,OAAO,MAAM,UAAU,cAAc,OAAO,KAAK,KAAM,EACtE,KAAiB,EACjB,OAAO,CAAC,SAAS;AAChB,WAAO,OAAO,OAAO,MAAM,UAAU,KAAK,KAAK,aAAa;AAAA,EAC9D,CAAC,EACA,IAAI,CAAC,SAAS,KAAK,GAAG;AAE7B;AAEA,IAAM,iBAAiB,CAAC,SACtB;AAAA,EAAC,gBAAAC;AAAA,EAAA;AAAA,IACC,WAAW,KAAK;AAAA,IAChB,eAAa,KAAK,UAAU,KAAK;AAAA,IACjC,aAAa,KAAK;AAAA,IAElB,SAAS,KAAK;AAAA,IACd,cAAc,KAAK;AAAA,IAElB,eAAK;AAAA;AAAA,EAJD,KAAK;AAKZ;AAMF,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,SAAS;AAAA,EACT,aAAa;AAAA,EACb;AACF,MAAiB;AACf,QAAM,QAAQ,EAAE,MAAM,CAAC;AAEvB,SACE,6CAAC,gBAAAC,UAAA,EAAa,YACZ;AAAA,gDAAC,gBAAAC,iBAAA,EAAoB,eAAW,kBAAAC,SAAG,SAAS,GAAG,eAAa,QACzD;AAAA;AAAA,MAEC,4CAAC,YAAQ,UAAS;AAAA;AAAA;AAAA,MAGlB,4CAAC,wBAAO,MAAK,MAAK,SAAQ,QAAO,WAAU,WACzC,sDAAC,iCAAmB,GACtB;AAAA,OAEJ;AAAA,IACA;AAAA,MAAC,gBAAAC;AAAA,MAAA;AAAA,QAEC;AAAA,QACA,cAAc,gBAAgB,KAAK;AAAA,QACnC;AAAA,QAEC,WAAC,SAAS;AACT,cAAI,WAAW,MAAM;AACnB,mBACE;AAAA,cAAC,gBAAAC;AAAA,cAAA;AAAA,gBACC,OAAO,KAAK;AAAA,gBACZ,OAAO,KAAK;AAAA,gBAIX,WAAC,gBAAgB;AAChB,yBAAO,eAAe,WAAW;AAAA,gBACnC;AAAA;AAAA,cALK,KAAK;AAAA,YAMZ;AAAA,UAEJ;AACA,iBAAO,eAAe,IAAI;AAAA,QAC5B;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;AAEA,IAAO,eAAQ;","names":["createDebug","NextDropdownItem","NextDropdown","NextDropdownTrigger","cn","NextDropdownMenu","NextDropdownSection"]}
|
package/dist/Menu/Menu.js
CHANGED
package/dist/Menu/index.cjs
CHANGED
|
@@ -36,101 +36,18 @@ module.exports = __toCommonJS(Menu_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/Menu/Menu.tsx
|
|
38
38
|
var import_fa6 = require("react-icons/fa6");
|
|
39
|
-
var import_dropdown = require("@nextui-org/dropdown");
|
|
40
|
-
var import_classnames2 = __toESM(require("classnames"), 1);
|
|
41
|
-
var import_debug = __toESM(require("debug"), 1);
|
|
42
|
-
|
|
43
|
-
// src/Button/Button.tsx
|
|
44
39
|
var import_button = require("@nextui-org/button");
|
|
40
|
+
var import_dropdown = require("@nextui-org/dropdown");
|
|
45
41
|
var import_classnames = __toESM(require("classnames"), 1);
|
|
46
|
-
|
|
47
|
-
// src/Button/subcomponents/LoadingSpinner.tsx
|
|
42
|
+
var import_debug = __toESM(require("debug"), 1);
|
|
48
43
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
|
-
var LoadingSpinner_default = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
50
|
-
"svg",
|
|
51
|
-
{
|
|
52
|
-
className: "animate-spin h-5 w-5 text-current",
|
|
53
|
-
fill: "none",
|
|
54
|
-
viewBox: "0 0 24 24",
|
|
55
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
56
|
-
children: [
|
|
57
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
|
-
"circle",
|
|
59
|
-
{
|
|
60
|
-
className: "opacity-25",
|
|
61
|
-
cx: "12",
|
|
62
|
-
cy: "12",
|
|
63
|
-
r: "10",
|
|
64
|
-
stroke: "currentColor",
|
|
65
|
-
strokeWidth: "4"
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
-
"path",
|
|
70
|
-
{
|
|
71
|
-
className: "opacity-75",
|
|
72
|
-
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",
|
|
73
|
-
fill: "currentColor"
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
// src/Button/Button.tsx
|
|
81
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
82
|
-
var Button = ({
|
|
83
|
-
ariaLabel = void 0,
|
|
84
|
-
children = void 0,
|
|
85
|
-
className = void 0,
|
|
86
|
-
color = "default",
|
|
87
|
-
disabled = false,
|
|
88
|
-
icon = void 0,
|
|
89
|
-
loading = false,
|
|
90
|
-
onClick = void 0,
|
|
91
|
-
size = void 0,
|
|
92
|
-
testId = void 0,
|
|
93
|
-
type = void 0,
|
|
94
|
-
variant = "solid",
|
|
95
|
-
...passthrouhProps
|
|
96
|
-
}) => {
|
|
97
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
98
|
-
import_button.Button,
|
|
99
|
-
{
|
|
100
|
-
"aria-label": ariaLabel,
|
|
101
|
-
className: (0, import_classnames.default)(className),
|
|
102
|
-
color,
|
|
103
|
-
"data-testid": testId,
|
|
104
|
-
isDisabled: disabled,
|
|
105
|
-
isIconOnly: !!(icon && !children),
|
|
106
|
-
isLoading: loading,
|
|
107
|
-
onPress: onClick,
|
|
108
|
-
size,
|
|
109
|
-
spinner: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingSpinner_default, {}),
|
|
110
|
-
type,
|
|
111
|
-
variant,
|
|
112
|
-
...passthrouhProps,
|
|
113
|
-
children: [
|
|
114
|
-
icon,
|
|
115
|
-
children
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
};
|
|
120
|
-
var Button_default = Button;
|
|
121
|
-
|
|
122
|
-
// src/Button/index.ts
|
|
123
|
-
var Button_default2 = Button_default;
|
|
124
|
-
|
|
125
|
-
// src/Menu/Menu.tsx
|
|
126
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
127
44
|
var debug = (0, import_debug.default)("component:Menu");
|
|
128
45
|
var getDisabledKeys = (items) => {
|
|
129
46
|
return items.map((item) => typeof item?.items === "undefined" ? item : item.items).flat().filter((item) => {
|
|
130
47
|
return Object.hasOwn(item, "disabled") && item.disabled === true;
|
|
131
48
|
}).map((item) => item.key);
|
|
132
49
|
};
|
|
133
|
-
var renderMenuItem = (item) => /* @__PURE__ */ (0,
|
|
50
|
+
var renderMenuItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
51
|
import_dropdown.DropdownItem,
|
|
135
52
|
{
|
|
136
53
|
className: item.className,
|
|
@@ -151,12 +68,15 @@ var Menu = ({
|
|
|
151
68
|
items
|
|
152
69
|
}) => {
|
|
153
70
|
debug("Menu", { items });
|
|
154
|
-
return /* @__PURE__ */ (0,
|
|
155
|
-
/* @__PURE__ */ (0,
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dropdown.Dropdown, { isDisabled, children: [
|
|
72
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dropdown.DropdownTrigger, { className: (0, import_classnames.default)(className), "data-testid": testId, children: children ? (
|
|
156
73
|
// eslint-disable-next-line react/button-has-type
|
|
157
|
-
/* @__PURE__ */ (0,
|
|
158
|
-
) :
|
|
159
|
-
|
|
74
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { children })
|
|
75
|
+
) : (
|
|
76
|
+
// INFO: we use next button here so that ref passing works
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", variant: "flat", className: "min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa6.FaEllipsisVertical, {}) })
|
|
78
|
+
) }),
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
160
80
|
import_dropdown.DropdownMenu,
|
|
161
81
|
{
|
|
162
82
|
items,
|
|
@@ -164,7 +84,7 @@ var Menu = ({
|
|
|
164
84
|
onAction,
|
|
165
85
|
children: (item) => {
|
|
166
86
|
if ("items" in item) {
|
|
167
|
-
return /* @__PURE__ */ (0,
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
88
|
import_dropdown.DropdownSection,
|
|
169
89
|
{
|
|
170
90
|
items: item.items,
|
package/dist/Menu/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Menu/index.ts","../../src/Menu/Menu.tsx"
|
|
1
|
+
{"version":3,"sources":["../../src/Menu/index.ts","../../src/Menu/Menu.tsx"],"sourcesContent":["import Menu from './Menu';\n\nexport default Menu;\n","import type { DropdownSectionProps } from '@nextui-org/dropdown';\nimport type { Key, MouseEventHandler, ReactNode } from 'react';\n\nimport { FaEllipsisVertical } from 'react-icons/fa6';\n\nimport { Button } from '@nextui-org/button';\nimport {\n Dropdown as NextDropdown,\n DropdownItem as NextDropdownItem,\n DropdownMenu as NextDropdownMenu,\n DropdownSection as NextDropdownSection,\n DropdownTrigger as NextDropdownTrigger,\n} from '@nextui-org/dropdown';\nimport cn from 'classnames';\nimport createDebug from 'debug';\n\nconst debug = createDebug('component:Menu');\n\n/**\n * Menu item type\n */\nexport interface MenuItem {\n /** unique identifier */\n key: string;\n /** CSS class name */\n className?: string;\n /** additional description shown under the label */\n description?: string;\n /** disables the menu item */\n disabled?: boolean;\n /** menu item icon */\n icon?: ReactNode;\n /** menu item name */\n label: ReactNode;\n /** click event handler */\n onClick?: MouseEventHandler<HTMLLIElement>;\n /** e2e test identifier */\n testId?: string;\n}\n\n/**\n * Menu section type\n */\nexport interface MenuSection {\n /** unique identifier */\n key: string;\n /** section label */\n label: ReactNode;\n /** section items (array of MenuItem) */\n items: MenuItem[];\n}\n\nexport interface MenuProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** menu item structure */\n items: (MenuSection | MenuItem)[];\n /** disable menu trigger */\n isDisabled?: boolean;\n /** called if item is selected */\n onAction?: (key: Key) => void;\n}\n\n/** returns String[] of disabled items/keys */\nconst getDisabledKeys = (items: (MenuSection | MenuItem)[]) => {\n return (\n items\n // @ts-expect-error typing issue with MenuSection | MenuItem\n .map((item) => (typeof item?.items === 'undefined' ? item : item.items))\n .flat<MenuItem[]>()\n .filter((item) => {\n return Object.hasOwn(item, 'disabled') && item.disabled === true;\n })\n .map((item) => item.key)\n );\n};\n\nconst renderMenuItem = (item: MenuItem) => (\n <NextDropdownItem\n className={item.className}\n data-testid={item.testId || item.key}\n description={item.description}\n key={item.key}\n onClick={item.onClick}\n startContent={item.icon}\n >\n {item.label}\n </NextDropdownItem>\n);\n\n/**\n * Dropdown menu component based on [NextUI Dropdown](https://nextui.org/docs/components/dropdown)\n */\nconst Menu = ({\n children = null,\n className = undefined,\n onAction = undefined,\n testId = undefined,\n isDisabled = false,\n items,\n}: MenuProps) => {\n debug('Menu', { items });\n\n return (\n <NextDropdown isDisabled={isDisabled}>\n <NextDropdownTrigger className={cn(className)} data-testid={testId}>\n {children ? (\n // eslint-disable-next-line react/button-has-type\n <button>{children}</button>\n ) : (\n // INFO: we use next button here so that ref passing works\n <Button size=\"sm\" variant=\"flat\" className=\"min-w-0\">\n <FaEllipsisVertical />\n </Button>\n )}\n </NextDropdownTrigger>\n <NextDropdownMenu\n // aria-label=\"Dynamic Actions\"\n items={items}\n disabledKeys={getDisabledKeys(items)}\n onAction={onAction}\n >\n {(item) => {\n if ('items' in item) {\n return (\n <NextDropdownSection\n items={item.items as MenuSection['items']}\n title={item.label as DropdownSectionProps['title']}\n key={item.key}\n >\n {/* @ts-expect-error ts problem here with render fn */}\n {(sectionItem) => {\n return renderMenuItem(sectionItem);\n }}\n </NextDropdownSection>\n );\n }\n return renderMenuItem(item);\n }}\n </NextDropdownMenu>\n </NextDropdown>\n );\n};\n\nexport default Menu;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACGA,iBAAmC;AAEnC,oBAAuB;AACvB,sBAMO;AACP,wBAAe;AACf,mBAAwB;AAoEtB;AAlEF,IAAM,YAAQ,aAAAC,SAAY,gBAAgB;AAoD1C,IAAM,kBAAkB,CAAC,UAAsC;AAC7D,SACE,MAEG,IAAI,CAAC,SAAU,OAAO,MAAM,UAAU,cAAc,OAAO,KAAK,KAAM,EACtE,KAAiB,EACjB,OAAO,CAAC,SAAS;AAChB,WAAO,OAAO,OAAO,MAAM,UAAU,KAAK,KAAK,aAAa;AAAA,EAC9D,CAAC,EACA,IAAI,CAAC,SAAS,KAAK,GAAG;AAE7B;AAEA,IAAM,iBAAiB,CAAC,SACtB;AAAA,EAAC,gBAAAC;AAAA,EAAA;AAAA,IACC,WAAW,KAAK;AAAA,IAChB,eAAa,KAAK,UAAU,KAAK;AAAA,IACjC,aAAa,KAAK;AAAA,IAElB,SAAS,KAAK;AAAA,IACd,cAAc,KAAK;AAAA,IAElB,eAAK;AAAA;AAAA,EAJD,KAAK;AAKZ;AAMF,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,SAAS;AAAA,EACT,aAAa;AAAA,EACb;AACF,MAAiB;AACf,QAAM,QAAQ,EAAE,MAAM,CAAC;AAEvB,SACE,6CAAC,gBAAAC,UAAA,EAAa,YACZ;AAAA,gDAAC,gBAAAC,iBAAA,EAAoB,eAAW,kBAAAC,SAAG,SAAS,GAAG,eAAa,QACzD;AAAA;AAAA,MAEC,4CAAC,YAAQ,UAAS;AAAA;AAAA;AAAA,MAGlB,4CAAC,wBAAO,MAAK,MAAK,SAAQ,QAAO,WAAU,WACzC,sDAAC,iCAAmB,GACtB;AAAA,OAEJ;AAAA,IACA;AAAA,MAAC,gBAAAC;AAAA,MAAA;AAAA,QAEC;AAAA,QACA,cAAc,gBAAgB,KAAK;AAAA,QACnC;AAAA,QAEC,WAAC,SAAS;AACT,cAAI,WAAW,MAAM;AACnB,mBACE;AAAA,cAAC,gBAAAC;AAAA,cAAA;AAAA,gBACC,OAAO,KAAK;AAAA,gBACZ,OAAO,KAAK;AAAA,gBAIX,WAAC,gBAAgB;AAChB,yBAAO,eAAe,WAAW;AAAA,gBACnC;AAAA;AAAA,cALK,KAAK;AAAA,YAMZ;AAAA,UAEJ;AACA,iBAAO,eAAe,IAAI;AAAA,QAC5B;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;AAEA,IAAO,eAAQ;;;ADlJf,IAAOC,gBAAQ;","names":["Menu_default","createDebug","NextDropdownItem","NextDropdown","NextDropdownTrigger","cn","NextDropdownMenu","NextDropdownSection","Menu_default"]}
|
package/dist/Menu/index.js
CHANGED
package/dist/Menu/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Menu/index.ts"],"sourcesContent":["import Menu from './Menu';\n\nexport default Menu;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/Menu/index.ts"],"sourcesContent":["import Menu from './Menu';\n\nexport default Menu;\n"],"mappings":";;;;;AAEA,IAAOA,gBAAQ;","names":["Menu_default"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button_default
|
|
3
|
+
} from "./chunk-NFWS2SSN.js";
|
|
4
|
+
|
|
5
|
+
// src/Json/Json.tsx
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { FaChevronDown, FaChevronUp, FaTimesCircle } from "react-icons/fa";
|
|
8
|
+
import ReactJson from "react-json-view";
|
|
9
|
+
import cn from "classnames";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
var getValue = (value) => {
|
|
12
|
+
if (typeof value === "string") {
|
|
13
|
+
return JSON.parse(value);
|
|
14
|
+
}
|
|
15
|
+
if (typeof value === "object") {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`${typeof value} can not be visualized`);
|
|
19
|
+
};
|
|
20
|
+
var Json = ({ className = null, collapsed = false, value }) => {
|
|
21
|
+
const isDarkMode = document.body.classList.contains("dark");
|
|
22
|
+
let content = null;
|
|
23
|
+
let error = null;
|
|
24
|
+
const [showDetails, setShowDetails] = useState(false);
|
|
25
|
+
try {
|
|
26
|
+
content = /* @__PURE__ */ jsx(
|
|
27
|
+
ReactJson,
|
|
28
|
+
{
|
|
29
|
+
theme: isDarkMode ? "tomorrow" : "rjv-default",
|
|
30
|
+
style: {
|
|
31
|
+
fontSize: "12px",
|
|
32
|
+
backgroundColor: "unset"
|
|
33
|
+
},
|
|
34
|
+
name: false,
|
|
35
|
+
displayDataTypes: false,
|
|
36
|
+
src: getValue(value),
|
|
37
|
+
collapsed
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
error = /* @__PURE__ */ jsxs(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
className: "mb-4 flex flex-col items-center rounded-lg border border-danger bg-danger-50 p-4 text-sm text-danger",
|
|
45
|
+
role: "alert",
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between gap-6", children: [
|
|
48
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
49
|
+
/* @__PURE__ */ jsx(FaTimesCircle, { className: "mr-2" }),
|
|
50
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "Failed to parse JSON data" })
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
Button_default,
|
|
54
|
+
{
|
|
55
|
+
color: "danger",
|
|
56
|
+
size: "sm",
|
|
57
|
+
variant: "light",
|
|
58
|
+
onClick: () => setShowDetails(!showDetails),
|
|
59
|
+
children: showDetails ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
+
/* @__PURE__ */ jsx(FaChevronUp, {}),
|
|
61
|
+
" Hide Details"
|
|
62
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
63
|
+
/* @__PURE__ */ jsx(FaChevronDown, {}),
|
|
64
|
+
" Show Details"
|
|
65
|
+
] })
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] }),
|
|
69
|
+
showDetails && /* @__PURE__ */ jsxs("div", { className: "mt-4 w-full text-left", children: [
|
|
70
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
71
|
+
/* @__PURE__ */ jsx("strong", { children: "Error:" }),
|
|
72
|
+
/* @__PURE__ */ jsxs("pre", { children: [
|
|
73
|
+
err?.name,
|
|
74
|
+
": ",
|
|
75
|
+
err?.message
|
|
76
|
+
] })
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-4", children: [
|
|
79
|
+
/* @__PURE__ */ jsx("strong", { children: "Data:" }),
|
|
80
|
+
/* @__PURE__ */ jsx("pre", { children: typeof value !== "string" ? JSON.stringify(value, null, 2) : value })
|
|
81
|
+
] })
|
|
82
|
+
] })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return /* @__PURE__ */ jsx("div", { className: cn(className), children: error || content });
|
|
88
|
+
};
|
|
89
|
+
var Json_default = Json;
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
Json_default
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=chunk-3EFVWEGP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Json/Json.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { useState } from 'react';\nimport { FaChevronDown, FaChevronUp, FaTimesCircle } from 'react-icons/fa';\nimport ReactJson from 'react-json-view';\n\nimport cn from 'classnames';\n\nimport Button from '../Button';\n\n/**\n * returns the value (JSON string or object) as object\n */\nconst getValue = (value: string | object) => {\n if (typeof value === 'string') {\n return JSON.parse(value);\n }\n if (typeof value === 'object') {\n return value;\n }\n throw new Error(`${typeof value} can not be visualized`);\n};\n\nexport interface JsonProps {\n /** CSS class name */\n className?: string | string[] | null;\n /** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. */\n collapsed?: boolean | number;\n /** Object to be visualized JSON string or object */\n value: string | object;\n}\n\n/**\n * Json renderer based on [react-json-view](https://mac-s-g.github.io/react-json-view/demo/dist/)\n */\nconst Json = ({ className = null, collapsed = false, value }: JsonProps) => {\n const isDarkMode = document.body.classList.contains('dark');\n\n let content: ReactNode = null;\n let error: ReactNode = null;\n\n const [showDetails, setShowDetails] = useState(false);\n\n try {\n content = (\n <ReactJson\n theme={isDarkMode ? 'tomorrow' : 'rjv-default'}\n style={{\n fontSize: '12px',\n backgroundColor: 'unset',\n }}\n name={false}\n displayDataTypes={false}\n src={getValue(value)}\n collapsed={collapsed}\n />\n );\n } catch (err) {\n error = (\n <div\n className=\"mb-4 flex flex-col items-center rounded-lg border border-danger bg-danger-50 p-4 text-sm text-danger\"\n role=\"alert\"\n >\n <div className=\"flex w-full justify-between gap-6\">\n <div className=\"flex items-center\">\n <FaTimesCircle className=\"mr-2\" />\n <span className=\"font-medium\">Failed to parse JSON data</span>\n </div>\n <Button\n color=\"danger\"\n size=\"sm\"\n variant=\"light\"\n onClick={() => setShowDetails(!showDetails)}\n >\n {showDetails ? (\n <>\n <FaChevronUp /> Hide Details\n </>\n ) : (\n <>\n <FaChevronDown /> Show Details\n </>\n )}\n </Button>\n </div>\n {showDetails && (\n <div className=\"mt-4 w-full text-left\">\n <div>\n <strong>Error:</strong>\n <pre>\n {/* @ts-expect-error is ok */}\n {err?.name}: {err?.message}\n </pre>\n </div>\n <div className=\"mt-4\">\n <strong>Data:</strong>\n <pre>\n {typeof value !== 'string'\n ? JSON.stringify(value, null, 2)\n : value}\n </pre>\n </div>\n </div>\n )}\n </div>\n );\n }\n return <div className={cn(className)}>{error || content}</div>;\n};\n\nexport default Json;\n"],"mappings":";;;;;AAEA,SAAS,gBAAgB;AACzB,SAAS,eAAe,aAAa,qBAAqB;AAC1D,OAAO,eAAe;AAEtB,OAAO,QAAQ;AAuCT,SA8BQ,UA9BR,KAmBI,YAnBJ;AAhCN,IAAM,WAAW,CAAC,UAA2B;AAC3C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,QAAM,IAAI,MAAM,GAAG,OAAO,KAAK,wBAAwB;AACzD;AAcA,IAAM,OAAO,CAAC,EAAE,YAAY,MAAM,YAAY,OAAO,MAAM,MAAiB;AAC1E,QAAM,aAAa,SAAS,KAAK,UAAU,SAAS,MAAM;AAE1D,MAAI,UAAqB;AACzB,MAAI,QAAmB;AAEvB,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AAEpD,MAAI;AACF,cACE;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,aAAa,aAAa;AAAA,QACjC,OAAO;AAAA,UACL,UAAU;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,QACA,MAAM;AAAA,QACN,kBAAkB;AAAA,QAClB,KAAK,SAAS,KAAK;AAAA,QACnB;AAAA;AAAA,IACF;AAAA,EAEJ,SAAS,KAAK;AACZ,YACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,MAAK;AAAA,QAEL;AAAA,+BAAC,SAAI,WAAU,qCACb;AAAA,iCAAC,SAAI,WAAU,qBACb;AAAA,kCAAC,iBAAc,WAAU,QAAO;AAAA,cAChC,oBAAC,UAAK,WAAU,eAAc,uCAAyB;AAAA,eACzD;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAM;AAAA,gBACN,MAAK;AAAA,gBACL,SAAQ;AAAA,gBACR,SAAS,MAAM,eAAe,CAAC,WAAW;AAAA,gBAEzC,wBACC,iCACE;AAAA,sCAAC,eAAY;AAAA,kBAAE;AAAA,mBACjB,IAEA,iCACE;AAAA,sCAAC,iBAAc;AAAA,kBAAE;AAAA,mBACnB;AAAA;AAAA,YAEJ;AAAA,aACF;AAAA,UACC,eACC,qBAAC,SAAI,WAAU,yBACb;AAAA,iCAAC,SACC;AAAA,kCAAC,YAAO,oBAAM;AAAA,cACd,qBAAC,SAEE;AAAA,qBAAK;AAAA,gBAAK;AAAA,gBAAG,KAAK;AAAA,iBACrB;AAAA,eACF;AAAA,YACA,qBAAC,SAAI,WAAU,QACb;AAAA,kCAAC,YAAO,mBAAK;AAAA,cACb,oBAAC,SACE,iBAAO,UAAU,WACd,KAAK,UAAU,OAAO,MAAM,CAAC,IAC7B,OACN;AAAA,eACF;AAAA,aACF;AAAA;AAAA;AAAA,IAEJ;AAAA,EAEJ;AACA,SAAO,oBAAC,SAAI,WAAW,GAAG,SAAS,GAAI,mBAAS,SAAQ;AAC1D;AAEA,IAAO,eAAQ;","names":[]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button_default
|
|
3
|
-
} from "./chunk-NFWS2SSN.js";
|
|
4
|
-
|
|
5
1
|
// src/Menu/Menu.tsx
|
|
6
2
|
import { FaEllipsisVertical } from "react-icons/fa6";
|
|
3
|
+
import { Button } from "@nextui-org/button";
|
|
7
4
|
import {
|
|
8
5
|
Dropdown as NextDropdown,
|
|
9
6
|
DropdownItem as NextDropdownItem,
|
|
@@ -45,7 +42,10 @@ var Menu = ({
|
|
|
45
42
|
/* @__PURE__ */ jsx(NextDropdownTrigger, { className: cn(className), "data-testid": testId, children: children ? (
|
|
46
43
|
// eslint-disable-next-line react/button-has-type
|
|
47
44
|
/* @__PURE__ */ jsx("button", { children })
|
|
48
|
-
) :
|
|
45
|
+
) : (
|
|
46
|
+
// INFO: we use next button here so that ref passing works
|
|
47
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "flat", className: "min-w-0", children: /* @__PURE__ */ jsx(FaEllipsisVertical, {}) })
|
|
48
|
+
) }),
|
|
49
49
|
/* @__PURE__ */ jsx(
|
|
50
50
|
NextDropdownMenu,
|
|
51
51
|
{
|
|
@@ -77,4 +77,4 @@ var Menu_default = Menu;
|
|
|
77
77
|
export {
|
|
78
78
|
Menu_default
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-Y35GJHOR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Menu/Menu.tsx"],"sourcesContent":["import type { DropdownSectionProps } from '@nextui-org/dropdown';\nimport type { Key, MouseEventHandler, ReactNode } from 'react';\n\nimport { FaEllipsisVertical } from 'react-icons/fa6';\n\nimport { Button } from '@nextui-org/button';\nimport {\n Dropdown as NextDropdown,\n DropdownItem as NextDropdownItem,\n DropdownMenu as NextDropdownMenu,\n DropdownSection as NextDropdownSection,\n DropdownTrigger as NextDropdownTrigger,\n} from '@nextui-org/dropdown';\nimport cn from 'classnames';\nimport createDebug from 'debug';\n\nconst debug = createDebug('component:Menu');\n\n/**\n * Menu item type\n */\nexport interface MenuItem {\n /** unique identifier */\n key: string;\n /** CSS class name */\n className?: string;\n /** additional description shown under the label */\n description?: string;\n /** disables the menu item */\n disabled?: boolean;\n /** menu item icon */\n icon?: ReactNode;\n /** menu item name */\n label: ReactNode;\n /** click event handler */\n onClick?: MouseEventHandler<HTMLLIElement>;\n /** e2e test identifier */\n testId?: string;\n}\n\n/**\n * Menu section type\n */\nexport interface MenuSection {\n /** unique identifier */\n key: string;\n /** section label */\n label: ReactNode;\n /** section items (array of MenuItem) */\n items: MenuItem[];\n}\n\nexport interface MenuProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** menu item structure */\n items: (MenuSection | MenuItem)[];\n /** disable menu trigger */\n isDisabled?: boolean;\n /** called if item is selected */\n onAction?: (key: Key) => void;\n}\n\n/** returns String[] of disabled items/keys */\nconst getDisabledKeys = (items: (MenuSection | MenuItem)[]) => {\n return (\n items\n // @ts-expect-error typing issue with MenuSection | MenuItem\n .map((item) => (typeof item?.items === 'undefined' ? item : item.items))\n .flat<MenuItem[]>()\n .filter((item) => {\n return Object.hasOwn(item, 'disabled') && item.disabled === true;\n })\n .map((item) => item.key)\n );\n};\n\nconst renderMenuItem = (item: MenuItem) => (\n <NextDropdownItem\n className={item.className}\n data-testid={item.testId || item.key}\n description={item.description}\n key={item.key}\n onClick={item.onClick}\n startContent={item.icon}\n >\n {item.label}\n </NextDropdownItem>\n);\n\n/**\n * Dropdown menu component based on [NextUI Dropdown](https://nextui.org/docs/components/dropdown)\n */\nconst Menu = ({\n children = null,\n className = undefined,\n onAction = undefined,\n testId = undefined,\n isDisabled = false,\n items,\n}: MenuProps) => {\n debug('Menu', { items });\n\n return (\n <NextDropdown isDisabled={isDisabled}>\n <NextDropdownTrigger className={cn(className)} data-testid={testId}>\n {children ? (\n // eslint-disable-next-line react/button-has-type\n <button>{children}</button>\n ) : (\n // INFO: we use next button here so that ref passing works\n <Button size=\"sm\" variant=\"flat\" className=\"min-w-0\">\n <FaEllipsisVertical />\n </Button>\n )}\n </NextDropdownTrigger>\n <NextDropdownMenu\n // aria-label=\"Dynamic Actions\"\n items={items}\n disabledKeys={getDisabledKeys(items)}\n onAction={onAction}\n >\n {(item) => {\n if ('items' in item) {\n return (\n <NextDropdownSection\n items={item.items as MenuSection['items']}\n title={item.label as DropdownSectionProps['title']}\n key={item.key}\n >\n {/* @ts-expect-error ts problem here with render fn */}\n {(sectionItem) => {\n return renderMenuItem(sectionItem);\n }}\n </NextDropdownSection>\n );\n }\n return renderMenuItem(item);\n }}\n </NextDropdownMenu>\n </NextDropdown>\n );\n};\n\nexport default Menu;\n"],"mappings":";AAGA,SAAS,0BAA0B;AAEnC,SAAS,cAAc;AACvB;AAAA,EACE,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,OACd;AACP,OAAO,QAAQ;AACf,OAAO,iBAAiB;AAoEtB,cA0BE,YA1BF;AAlEF,IAAM,QAAQ,YAAY,gBAAgB;AAoD1C,IAAM,kBAAkB,CAAC,UAAsC;AAC7D,SACE,MAEG,IAAI,CAAC,SAAU,OAAO,MAAM,UAAU,cAAc,OAAO,KAAK,KAAM,EACtE,KAAiB,EACjB,OAAO,CAAC,SAAS;AAChB,WAAO,OAAO,OAAO,MAAM,UAAU,KAAK,KAAK,aAAa;AAAA,EAC9D,CAAC,EACA,IAAI,CAAC,SAAS,KAAK,GAAG;AAE7B;AAEA,IAAM,iBAAiB,CAAC,SACtB;AAAA,EAAC;AAAA;AAAA,IACC,WAAW,KAAK;AAAA,IAChB,eAAa,KAAK,UAAU,KAAK;AAAA,IACjC,aAAa,KAAK;AAAA,IAElB,SAAS,KAAK;AAAA,IACd,cAAc,KAAK;AAAA,IAElB,eAAK;AAAA;AAAA,EAJD,KAAK;AAKZ;AAMF,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,SAAS;AAAA,EACT,aAAa;AAAA,EACb;AACF,MAAiB;AACf,QAAM,QAAQ,EAAE,MAAM,CAAC;AAEvB,SACE,qBAAC,gBAAa,YACZ;AAAA,wBAAC,uBAAoB,WAAW,GAAG,SAAS,GAAG,eAAa,QACzD;AAAA;AAAA,MAEC,oBAAC,YAAQ,UAAS;AAAA;AAAA;AAAA,MAGlB,oBAAC,UAAO,MAAK,MAAK,SAAQ,QAAO,WAAU,WACzC,8BAAC,sBAAmB,GACtB;AAAA,OAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QAEC;AAAA,QACA,cAAc,gBAAgB,KAAK;AAAA,QACnC;AAAA,QAEC,WAAC,SAAS;AACT,cAAI,WAAW,MAAM;AACnB,mBACE;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO,KAAK;AAAA,gBACZ,OAAO,KAAK;AAAA,gBAIX,WAAC,gBAAgB;AAChB,yBAAO,eAAe,WAAW;AAAA,gBACnC;AAAA;AAAA,cALK,KAAK;AAAA,YAMZ;AAAA,UAEJ;AACA,iBAAO,eAAe,IAAI;AAAA,QAC5B;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;AAEA,IAAO,eAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@fuf-stack/pixels",
|
|
3
3
|
"description": "fuf react component library",
|
|
4
4
|
"author": "Hannes Tiede",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.2.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
"./": "./dist/"
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"@types/debug": "4.1.12",
|
|
57
57
|
"@types/react": "18.2.69",
|
|
58
58
|
"@types/react-dom": "18.2.22",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
59
|
+
"tailwind-config": "0.0.1",
|
|
60
|
+
"storybook-config": "0.0.1"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "rm -rf ./dist && tsup",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Menu/Menu.tsx"],"sourcesContent":["import type { DropdownSectionProps } from '@nextui-org/dropdown';\nimport type { Key, MouseEventHandler, ReactNode } from 'react';\n\nimport { FaEllipsisVertical } from 'react-icons/fa6';\n\nimport {\n Dropdown as NextDropdown,\n DropdownItem as NextDropdownItem,\n DropdownMenu as NextDropdownMenu,\n DropdownSection as NextDropdownSection,\n DropdownTrigger as NextDropdownTrigger,\n} from '@nextui-org/dropdown';\nimport cn from 'classnames';\nimport createDebug from 'debug';\n\nimport Button from '../Button';\n\nconst debug = createDebug('component:Menu');\n\n/**\n * Menu item type\n */\nexport interface MenuItem {\n /** unique identifier */\n key: string;\n /** CSS class name */\n className?: string;\n /** additional description shown under the label */\n description?: string;\n /** disables the menu item */\n disabled?: boolean;\n /** menu item icon */\n icon?: ReactNode;\n /** menu item name */\n label: ReactNode;\n /** click event handler */\n onClick?: MouseEventHandler<HTMLLIElement>;\n /** e2e test identifier */\n testId?: string;\n}\n\n/**\n * Menu section type\n */\nexport interface MenuSection {\n /** unique identifier */\n key: string;\n /** section label */\n label: ReactNode;\n /** section items (array of MenuItem) */\n items: MenuItem[];\n}\n\nexport interface MenuProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** menu item structure */\n items: (MenuSection | MenuItem)[];\n /** disable menu trigger */\n isDisabled?: boolean;\n /** called if item is selected */\n onAction?: (key: Key) => void;\n}\n\n/** returns String[] of disabled items/keys */\nconst getDisabledKeys = (items: (MenuSection | MenuItem)[]) => {\n return (\n items\n // @ts-expect-error typing issue with MenuSection | MenuItem\n .map((item) => (typeof item?.items === 'undefined' ? item : item.items))\n .flat<MenuItem[]>()\n .filter((item) => {\n return Object.hasOwn(item, 'disabled') && item.disabled === true;\n })\n .map((item) => item.key)\n );\n};\n\nconst renderMenuItem = (item: MenuItem) => (\n <NextDropdownItem\n className={item.className}\n data-testid={item.testId || item.key}\n description={item.description}\n key={item.key}\n onClick={item.onClick}\n startContent={item.icon}\n >\n {item.label}\n </NextDropdownItem>\n);\n\n/**\n * Dropdown menu component based on [NextUI Dropdown](https://nextui.org/docs/components/dropdown)\n */\nconst Menu = ({\n children = null,\n className = undefined,\n onAction = undefined,\n testId = undefined,\n isDisabled = false,\n items,\n}: MenuProps) => {\n debug('Menu', { items });\n\n return (\n <NextDropdown isDisabled={isDisabled}>\n <NextDropdownTrigger className={cn(className)} data-testid={testId}>\n {children ? (\n // eslint-disable-next-line react/button-has-type\n <button>{children}</button>\n ) : (\n <Button size=\"sm\" variant=\"bordered\" className=\"min-w-0\">\n <FaEllipsisVertical />\n </Button>\n )}\n </NextDropdownTrigger>\n <NextDropdownMenu\n // aria-label=\"Dynamic Actions\"\n items={items}\n disabledKeys={getDisabledKeys(items)}\n onAction={onAction}\n >\n {(item) => {\n if ('items' in item) {\n return (\n <NextDropdownSection\n items={item.items as MenuSection['items']}\n title={item.label as DropdownSectionProps['title']}\n key={item.key}\n >\n {/* @ts-expect-error ts problem here with render fn */}\n {(sectionItem) => {\n return renderMenuItem(sectionItem);\n }}\n </NextDropdownSection>\n );\n }\n return renderMenuItem(item);\n }}\n </NextDropdownMenu>\n </NextDropdown>\n );\n};\n\nexport default Menu;\n"],"mappings":";;;;;AAGA,SAAS,0BAA0B;AAEnC;AAAA,EACE,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,OACd;AACP,OAAO,QAAQ;AACf,OAAO,iBAAiB;AAsEtB,cA0BE,YA1BF;AAlEF,IAAM,QAAQ,YAAY,gBAAgB;AAoD1C,IAAM,kBAAkB,CAAC,UAAsC;AAC7D,SACE,MAEG,IAAI,CAAC,SAAU,OAAO,MAAM,UAAU,cAAc,OAAO,KAAK,KAAM,EACtE,KAAiB,EACjB,OAAO,CAAC,SAAS;AAChB,WAAO,OAAO,OAAO,MAAM,UAAU,KAAK,KAAK,aAAa;AAAA,EAC9D,CAAC,EACA,IAAI,CAAC,SAAS,KAAK,GAAG;AAE7B;AAEA,IAAM,iBAAiB,CAAC,SACtB;AAAA,EAAC;AAAA;AAAA,IACC,WAAW,KAAK;AAAA,IAChB,eAAa,KAAK,UAAU,KAAK;AAAA,IACjC,aAAa,KAAK;AAAA,IAElB,SAAS,KAAK;AAAA,IACd,cAAc,KAAK;AAAA,IAElB,eAAK;AAAA;AAAA,EAJD,KAAK;AAKZ;AAMF,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,SAAS;AAAA,EACT,aAAa;AAAA,EACb;AACF,MAAiB;AACf,QAAM,QAAQ,EAAE,MAAM,CAAC;AAEvB,SACE,qBAAC,gBAAa,YACZ;AAAA,wBAAC,uBAAoB,WAAW,GAAG,SAAS,GAAG,eAAa,QACzD;AAAA;AAAA,MAEC,oBAAC,YAAQ,UAAS;AAAA,QAElB,oBAAC,kBAAO,MAAK,MAAK,SAAQ,YAAW,WAAU,WAC7C,8BAAC,sBAAmB,GACtB,GAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QAEC;AAAA,QACA,cAAc,gBAAgB,KAAK;AAAA,QACnC;AAAA,QAEC,WAAC,SAAS;AACT,cAAI,WAAW,MAAM;AACnB,mBACE;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO,KAAK;AAAA,gBACZ,OAAO,KAAK;AAAA,gBAIX,WAAC,gBAAgB;AAChB,yBAAO,eAAe,WAAW;AAAA,gBACnC;AAAA;AAAA,cALK,KAAK;AAAA,YAMZ;AAAA,UAEJ;AACA,iBAAO,eAAe,IAAI;AAAA,QAC5B;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;AAEA,IAAO,eAAQ;","names":[]}
|