@fuf-stack/pixels 0.1.2 → 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/Button/index.js +3 -5
- package/dist/Button/index.js.map +1 -1
- 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/chunk-3EFVWEGP.js +94 -0
- package/dist/chunk-3EFVWEGP.js.map +1 -0
- package/dist/chunk-NFWS2SSN.js +11 -0
- package/dist/chunk-NFWS2SSN.js.map +1 -0
- package/package.json +3 -3
package/dist/Button/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Button_default
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-NFWS2SSN.js";
|
|
4
|
+
import "../chunk-6QVKZ4AT.js";
|
|
4
5
|
import "../chunk-ZFEVTQWW.js";
|
|
5
|
-
|
|
6
|
-
// src/Button/index.ts
|
|
7
|
-
var Button_default2 = Button_default;
|
|
8
6
|
export {
|
|
9
|
-
|
|
7
|
+
Button_default as default
|
|
10
8
|
};
|
|
11
9
|
//# sourceMappingURL=index.js.map
|
package/dist/Button/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAyB;AACzB,gBAA0D;AAC1D,6BAAsB;AAEtB,IAAAA,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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A,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;","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;A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AA,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"]}
|
|
@@ -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,UA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,SAAO,oBAAC,SAAI,WAAW,GAAG,SAAS,GAAI,mBAAS,SAAQ;AAC1D;AAEA,IAAO,eAAQ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Button/index.ts"],"sourcesContent":["import type { ButtonProps } from './Button';\n\nimport Button from './Button';\n\nexport default Button;\n\nexport type { ButtonProps };\n"],"mappings":";;;;;AAIA,IAAOA,kBAAQ;","names":["Button_default"]}
|
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.1
|
|
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",
|