-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.mjs
More file actions
162 lines (152 loc) · 7.55 KB
/
Copy pathplugin.mjs
File metadata and controls
162 lines (152 loc) · 7.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Plugin: profile — auto-generated, do not edit
export default function(sdk, deps) {
const React = deps.react;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// factory-ext-react:react
var require_react = __commonJS({
"factory-ext-react:react"(exports, module) {
module.exports = deps.react;
}
});
// factory-ext-@brainquest/plugin-sdk:@brainquest/plugin-sdk
var require_plugin_sdk = __commonJS({
"factory-ext-@brainquest/plugin-sdk:@brainquest/plugin-sdk"(exports, module) {
module.exports = sdk;
}
});
// factory-ext-lucide-react:lucide-react
var require_lucide_react = __commonJS({
"factory-ext-lucide-react:lucide-react"(exports, module) {
module.exports = deps["lucide-react"];
}
});
// factory-host:@/components/ui/button
var require_button = __commonJS({
"factory-host:@/components/ui/button"(exports, module) {
module.exports = deps.host;
}
});
// factory-host:@/components/ui/card
var require_card = __commonJS({
"factory-host:@/components/ui/card"(exports, module) {
module.exports = deps.host;
}
});
// factory-host:@/lib/utils
var require_utils = __commonJS({
"factory-host:@/lib/utils"(exports, module) {
module.exports = deps.host;
}
});
// factory-host:../../ui
var require_ui = __commonJS({
"factory-host:../../ui"(exports, module) {
module.exports = deps.host;
}
});
// src/plugins/profile/ProfilePage.tsx
var ProfilePage_exports = {};
__export(ProfilePage_exports, {
default: () => ProfilePage
});
function PluginToggle({ plugin, enabled, onToggle }) {
return /* @__PURE__ */ React.createElement(import_card.Card, { className: (0, import_utils.cn)("p-4", enabled && "bg-indigo-50/50 border-indigo-200") }, /* @__PURE__ */ React.createElement(
import_button.Button,
{
variant: "ghost",
onClick: onToggle,
className: "w-full h-auto p-0 justify-start items-start gap-3 hover:bg-transparent hover:opacity-80 font-normal whitespace-normal"
},
/* @__PURE__ */ React.createElement(plugin.icon, { size: 20, className: `shrink-0 mt-0.5 ${enabled ? "text-indigo-600" : "text-gray-400"}` }),
/* @__PURE__ */ React.createElement("div", { className: "flex-1 min-w-0 text-left" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React.createElement("span", { className: "text-[13px] font-semibold text-gray-900" }, plugin.label), plugin.group && /* @__PURE__ */ React.createElement("span", { className: "text-[10px] px-1.5 py-0.5 rounded bg-gray-100 text-gray-400 font-mono" }, plugin.group), enabled && /* @__PURE__ */ React.createElement(import_lucide_react.Check, { size: 14, className: "text-indigo-600" })), /* @__PURE__ */ React.createElement("p", { className: "text-[12px] text-gray-500 mt-0.5 leading-relaxed" }, plugin.description), plugin.repo && /* @__PURE__ */ React.createElement(
"a",
{
href: plugin.repo,
target: "_blank",
rel: "noopener noreferrer",
onClick: (e) => e.stopPropagation(),
className: "inline-flex items-center gap-1 text-[11px] text-indigo-500 hover:text-indigo-700 mt-1"
},
/* @__PURE__ */ React.createElement(import_lucide_react.ExternalLink, { size: 10 }),
" Kod \u017Ar\xF3d\u0142owy"
)),
/* @__PURE__ */ React.createElement(import_lucide_react.Power, { size: 14, className: enabled ? "text-green-500" : "text-gray-300" })
));
}
function ProfilePage() {
const [profile, update] = (0, import_plugin_sdk.useProfile)();
const plugins = (0, import_plugin_sdk.getAllPluginsForUI)().filter((p) => !p.alwaysOn);
const [dirty, setDirty] = (0, import_react.useState)(false);
const toggle = (pluginId) => {
const plugin = plugins.find((p) => p.id === pluginId);
const enabling = profile[pluginId] === false;
const patch = { [pluginId]: enabling };
if (enabling && plugin?.group) {
for (const p of plugins) {
if (p.group === plugin.group && p.id !== pluginId) patch[p.id] = false;
}
}
update(patch);
setDirty(true);
};
return /* @__PURE__ */ React.createElement(import_ui.PageScroll, null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h2", { className: "text-lg font-bold text-gray-900" }, "Pluginy"), /* @__PURE__ */ React.createElement("p", { className: "text-sm text-gray-500 mt-1" }, "W\u0142\u0105cz, wy\u0142\u0105cz i konfiguruj")), /* @__PURE__ */ React.createElement("section", null, /* @__PURE__ */ React.createElement(import_ui.SectionLabel, null, "Pluginy"), /* @__PURE__ */ React.createElement("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-2 mt-2" }, plugins.map((p) => /* @__PURE__ */ React.createElement(
PluginToggle,
{
key: p.id,
plugin: p,
enabled: profile[p.id] !== false,
onToggle: () => toggle(p.id)
}
)))), dirty ? /* @__PURE__ */ React.createElement(import_button.Button, { className: "w-full", onClick: () => window.location.reload() }, /* @__PURE__ */ React.createElement(import_lucide_react.RefreshCw, { size: 14 }), " Od\u015Bwie\u017C, \u017Ceby zastosowa\u0107 zmiany") : /* @__PURE__ */ React.createElement("p", { className: "text-[11px] text-gray-400 text-center" }, "Twoje post\u0119py zostaj\u0105 zachowane."));
}
var import_react, import_lucide_react, import_plugin_sdk, import_button, import_card, import_utils, import_ui;
var init_ProfilePage = __esm({
"src/plugins/profile/ProfilePage.tsx"() {
import_react = __toESM(require_react(), 1);
import_lucide_react = __toESM(require_lucide_react(), 1);
import_plugin_sdk = __toESM(require_plugin_sdk(), 1);
import_button = __toESM(require_button(), 1);
import_card = __toESM(require_card(), 1);
import_utils = __toESM(require_utils(), 1);
import_ui = __toESM(require_ui(), 1);
}
});
// src/plugins/profile/plugin.ts
var import_react2 = __toESM(require_react(), 1);
var import_plugin_sdk2 = __toESM(require_plugin_sdk(), 1);
(0, import_plugin_sdk2.addFilter)("routes", (routes) => [
...routes,
{ path: "profile", scope: "global", component: (0, import_react2.lazy)(() => Promise.resolve().then(() => (init_ProfilePage(), ProfilePage_exports))), pluginId: "profile" }
]);
}