@blocklet/pages-kit-inner-components 0.4.99 → 0.4.101
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/lib/cjs/add-component.js +378 -0
- package/lib/cjs/chunks/array-BMkoDb_A.js +507 -0
- package/lib/cjs/chunks/config-color-Da8lKUL0.js +21 -0
- package/lib/cjs/chunks/{draft-data-Quz8toC_.js → draft-data-UP_7unuZ.js} +1 -1
- package/lib/cjs/chunks/home-CMaoUDJD.js +36 -0
- package/lib/cjs/chunks/publish-button-ByqPCT2Y.js +1 -0
- package/lib/cjs/chunks/state-BoXTl4DM.js +1 -0
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +1 -1
- package/lib/cjs/setting.js +3 -23
- package/lib/cjs/theme.js +3 -3
- package/lib/es/add-component.js +2991 -0
- package/lib/es/chunks/array-C85JziT_.js +2086 -0
- package/lib/es/chunks/config-color-B-ax03qd.js +328 -0
- package/lib/es/chunks/{draft-data-B1GJKphX.js → draft-data-0n1CKRWr.js} +1 -1
- package/lib/es/chunks/home-BBfstt15.js +470 -0
- package/lib/es/chunks/{publish-button-BY10Od4q.js → publish-button-OwaTBakj.js} +8 -7
- package/lib/es/chunks/state-DsXKwImw.js +425 -0
- package/lib/es/home.js +10 -8
- package/lib/es/locales.js +17 -179
- package/lib/es/setting.js +929 -1112
- package/lib/es/theme.js +53 -59
- package/package.json +21 -19
- package/lib/cjs/chunks/home-D9IcqQld.js +0 -542
- package/lib/cjs/chunks/publish-button-6WQRr1s7.js +0 -1
- package/lib/cjs/chunks/state-eTpgUKhB.js +0 -1
- package/lib/es/chunks/home-Cclj5ETj.js +0 -2357
- package/lib/es/chunks/state-CYDNg8EG.js +0 -420
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { jsx as o, jsxs as f, Fragment as W } from "react/jsx-runtime";
|
|
2
|
+
import j from "@arcblock/ux/lib/Empty";
|
|
3
|
+
import { useLocaleContext as G } from "@arcblock/ux/lib/Locale/context";
|
|
4
|
+
import { styled as R } from "@arcblock/ux/lib/Theme";
|
|
5
|
+
import { useMuiColorPalette as E } from "@blocklet/pages-kit/contexts/color";
|
|
6
|
+
import { isGradient as B, getSafeGradient as S, isColorString as H } from "@blocklet/pages-kit/utils/style";
|
|
7
|
+
import "@emotion/css";
|
|
8
|
+
import { TextField as L, Stack as P, FormControlLabel as _, Switch as U, Box as a, InputAdornment as X, Dialog as N, DialogTitle as O, Typography as I, ButtonGroup as Y, Button as K, DialogContent as $, Tooltip as q, Skeleton as J, DialogActions as Q } from "@mui/material";
|
|
9
|
+
import { useReactive as Z, useLocalStorageState as ee, useBoolean as oe } from "ahooks";
|
|
10
|
+
import "lodash/without";
|
|
11
|
+
import { forwardRef as A, useState as ie, useEffect as re, useImperativeHandle as V, lazy as te, useCallback as le, Suspense as ne } from "react";
|
|
12
|
+
import ae from "tinycolor2";
|
|
13
|
+
import { red as ce, pink as se, purple as ue, indigo as de, blue as me, cyan as pe, teal as fe, green as ge, lime as he, yellow as ye, amber as be, orange as xe, brown as Ce, grey as ve, blueGrey as ke } from "@mui/material/colors";
|
|
14
|
+
import { getImageSize as z, getVideoSize as D, UploaderButton as Ke } from "../uploader.js";
|
|
15
|
+
import { Icon as we } from "@iconify-icon/react";
|
|
16
|
+
import { useDebounce as Ie } from "react-use";
|
|
17
|
+
import { b as F } from "./state-DsXKwImw.js";
|
|
18
|
+
ce[300], se[300], ue[300], // deepPurple['300'],
|
|
19
|
+
de[300], me[300], // lightBlue['300'],
|
|
20
|
+
pe[300], fe[300], ge[300], // lightGreen['300'],
|
|
21
|
+
he[300], ye[300], be[300], xe[300], // deepOrange['300'],
|
|
22
|
+
Ce[300], ve[300], ke[300];
|
|
23
|
+
const Ue = A(function({ showMarkdown: g, markdown: c, onMarkdownChange: s, showUploader: e, value: t, meta: w, onChange: u, ...d }, y) {
|
|
24
|
+
const [l, b] = ie("");
|
|
25
|
+
re(() => {
|
|
26
|
+
b(t || "");
|
|
27
|
+
}, [t, b]);
|
|
28
|
+
const k = async () => {
|
|
29
|
+
if (l !== t) {
|
|
30
|
+
const i = F(l);
|
|
31
|
+
if (!i) {
|
|
32
|
+
u(l, void 0);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const p = await z(i).catch(() => D(i)).catch(() => {
|
|
36
|
+
});
|
|
37
|
+
u(l, { ...p, filename: l });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
Ie(
|
|
41
|
+
() => {
|
|
42
|
+
l !== t && u(l);
|
|
43
|
+
},
|
|
44
|
+
300,
|
|
45
|
+
[l]
|
|
46
|
+
), V(y, () => ({
|
|
47
|
+
submit: k
|
|
48
|
+
}));
|
|
49
|
+
const m = {};
|
|
50
|
+
return e && (m.InputProps = {
|
|
51
|
+
sx: { pr: 0 },
|
|
52
|
+
endAdornment: /* @__PURE__ */ o(X, { position: "end", sx: { mx: 0.5 }, children: /* @__PURE__ */ o(
|
|
53
|
+
Ke,
|
|
54
|
+
{
|
|
55
|
+
onChange: async ({ response: i }) => {
|
|
56
|
+
var x;
|
|
57
|
+
const p = (x = i == null ? void 0 : i.data) == null ? void 0 : x.filename, C = F(p) || "";
|
|
58
|
+
let r = {};
|
|
59
|
+
C && (r = await z(C).catch(() => D(C)).catch(() => {
|
|
60
|
+
})), u(p, {
|
|
61
|
+
...r,
|
|
62
|
+
filename: p
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
) })
|
|
67
|
+
}), /* @__PURE__ */ o(
|
|
68
|
+
L,
|
|
69
|
+
{
|
|
70
|
+
size: "small",
|
|
71
|
+
fullWidth: !0,
|
|
72
|
+
...d,
|
|
73
|
+
label: /* @__PURE__ */ f(P, { direction: "row", spacing: 1, alignItems: "center", children: [
|
|
74
|
+
d.label,
|
|
75
|
+
g && /* @__PURE__ */ f(W, { children: [
|
|
76
|
+
" (",
|
|
77
|
+
/* @__PURE__ */ o(
|
|
78
|
+
_,
|
|
79
|
+
{
|
|
80
|
+
checked: c,
|
|
81
|
+
label: /* @__PURE__ */ o(a, { component: we, icon: "tabler:markdown", sx: { verticalAlign: "middle" } }),
|
|
82
|
+
labelPlacement: "start",
|
|
83
|
+
control: /* @__PURE__ */ o(U, { size: "small" }),
|
|
84
|
+
sx: { ml: 0.25, pr: 1 },
|
|
85
|
+
onChange: (i, p) => s == null ? void 0 : s(p)
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
")"
|
|
89
|
+
] })
|
|
90
|
+
] }),
|
|
91
|
+
InputLabelProps: { shrink: !0, ...d.InputLabelProps },
|
|
92
|
+
value: l,
|
|
93
|
+
onChange: (i) => b(i.target.value),
|
|
94
|
+
...m,
|
|
95
|
+
onKeyDown: (i) => {
|
|
96
|
+
i.keyCode !== 229 && i.key === "Enter" && k();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}), Te = te(() => import("react-best-gradient-color-picker")), M = 400, T = 270;
|
|
101
|
+
function Xe({ color: h, sx: g = {}, ...c }) {
|
|
102
|
+
H(h);
|
|
103
|
+
const s = {};
|
|
104
|
+
return B(h) ? s.backgroundImage = h : s.backgroundColor = h, /* @__PURE__ */ o(
|
|
105
|
+
a,
|
|
106
|
+
{
|
|
107
|
+
sx: {
|
|
108
|
+
...g,
|
|
109
|
+
width: "100%",
|
|
110
|
+
paddingBottom: "100%",
|
|
111
|
+
cursor: "pointer",
|
|
112
|
+
transition: "opacity 0.2s",
|
|
113
|
+
border: "1px solid #ccc",
|
|
114
|
+
borderRadius: 0.5,
|
|
115
|
+
"&:hover": {
|
|
116
|
+
opacity: 0.75
|
|
117
|
+
},
|
|
118
|
+
...s
|
|
119
|
+
},
|
|
120
|
+
...c
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
const Ne = A(function({ onSave: g, enableMuiPalette: c = !0 }, s) {
|
|
125
|
+
const e = Z({
|
|
126
|
+
value: "",
|
|
127
|
+
originalMuiKey: null
|
|
128
|
+
}), { t } = G(), [w, u] = ee("pages-kit:color-picker-active-tab", {
|
|
129
|
+
defaultValue: 0
|
|
130
|
+
}), d = E(), y = {};
|
|
131
|
+
e.value ? B(e.value) ? y.backgroundImage = e.value : y.backgroundColor = e.value : y.border = "1px solid #ccc";
|
|
132
|
+
const [l, { setFalse: b, setTrue: k }] = oe(!1), m = le(() => {
|
|
133
|
+
b();
|
|
134
|
+
}, [b]), i = c && w === 0;
|
|
135
|
+
V(s, () => ({
|
|
136
|
+
open({ value: r } = { value: "" }) {
|
|
137
|
+
if (c && d.isMuiColorKey(r)) {
|
|
138
|
+
e.originalMuiKey = r;
|
|
139
|
+
const x = d.getColorByMuiKey(r);
|
|
140
|
+
e.value = S(x || r), u(0);
|
|
141
|
+
} else
|
|
142
|
+
e.originalMuiKey = null, e.value = S(r), c || u(1);
|
|
143
|
+
k();
|
|
144
|
+
},
|
|
145
|
+
close() {
|
|
146
|
+
m();
|
|
147
|
+
}
|
|
148
|
+
}));
|
|
149
|
+
const p = () => {
|
|
150
|
+
if (c && d)
|
|
151
|
+
if (i) {
|
|
152
|
+
const r = d.getMuiKeyByColor(e.value);
|
|
153
|
+
g({ value: r || e.value }, m);
|
|
154
|
+
} else
|
|
155
|
+
g({ value: e.value }, m);
|
|
156
|
+
else
|
|
157
|
+
g({ value: e.value }, m);
|
|
158
|
+
}, { groupedMuiColors: C } = d;
|
|
159
|
+
return /* @__PURE__ */ f(N, { disableEnforceFocus: !0, open: l, onClose: m, hideBackdrop: !0, children: [
|
|
160
|
+
/* @__PURE__ */ f(O, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
161
|
+
/* @__PURE__ */ o(I, { variant: "inherit", component: "div", children: t("maker.configColor") }),
|
|
162
|
+
c && /* @__PURE__ */ f(Y, { size: "small", "aria-label": "color mode selector", children: [
|
|
163
|
+
/* @__PURE__ */ o(
|
|
164
|
+
K,
|
|
165
|
+
{
|
|
166
|
+
variant: i ? "contained" : "outlined",
|
|
167
|
+
onClick: () => u(0),
|
|
168
|
+
sx: {
|
|
169
|
+
fontWeight: 500,
|
|
170
|
+
textTransform: "none",
|
|
171
|
+
minWidth: "unset"
|
|
172
|
+
},
|
|
173
|
+
children: t("maker.configColorMuiTheme") || "Theme Color"
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
/* @__PURE__ */ o(
|
|
177
|
+
K,
|
|
178
|
+
{
|
|
179
|
+
variant: w === 1 ? "contained" : "outlined",
|
|
180
|
+
onClick: () => u(1),
|
|
181
|
+
sx: {
|
|
182
|
+
fontWeight: 500,
|
|
183
|
+
textTransform: "none",
|
|
184
|
+
minWidth: "unset"
|
|
185
|
+
},
|
|
186
|
+
children: t("maker.configColorCustomColor") || "Custom Color"
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
] })
|
|
190
|
+
] }),
|
|
191
|
+
/* @__PURE__ */ f($, { sx: { width: 600, display: "flex", flexDirection: "row", gap: 2, overflowX: "hidden" }, children: [
|
|
192
|
+
/* @__PURE__ */ f(
|
|
193
|
+
a,
|
|
194
|
+
{
|
|
195
|
+
sx: {
|
|
196
|
+
...y,
|
|
197
|
+
flex: "0 0 270px",
|
|
198
|
+
borderRadius: 1,
|
|
199
|
+
display: "flex",
|
|
200
|
+
alignItems: "center",
|
|
201
|
+
justifyContent: "center",
|
|
202
|
+
position: "sticky",
|
|
203
|
+
top: 0
|
|
204
|
+
},
|
|
205
|
+
children: [
|
|
206
|
+
!e.value && /* @__PURE__ */ o(j, { children: t("error.notConfig") }),
|
|
207
|
+
e.originalMuiKey && i && /* @__PURE__ */ o(
|
|
208
|
+
I,
|
|
209
|
+
{
|
|
210
|
+
variant: "body2",
|
|
211
|
+
sx: {
|
|
212
|
+
bgcolor: "rgba(255,255,255,0.7)",
|
|
213
|
+
px: 2,
|
|
214
|
+
py: 1,
|
|
215
|
+
borderRadius: 1,
|
|
216
|
+
color: "#000",
|
|
217
|
+
maxWidth: "90%",
|
|
218
|
+
textAlign: "center"
|
|
219
|
+
},
|
|
220
|
+
children: e.originalMuiKey
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
"color-preview"
|
|
226
|
+
),
|
|
227
|
+
/* @__PURE__ */ o(a, { sx: { flex: 1 }, children: i ? (
|
|
228
|
+
// MUI 主题色面板
|
|
229
|
+
/* @__PURE__ */ o(a, { sx: { height: M }, children: Object.entries(C).map(([r, x]) => /* @__PURE__ */ f(a, { sx: { pb: 1.5 }, children: [
|
|
230
|
+
/* @__PURE__ */ o(
|
|
231
|
+
I,
|
|
232
|
+
{
|
|
233
|
+
variant: "subtitle2",
|
|
234
|
+
gutterBottom: !0,
|
|
235
|
+
sx: { textTransform: "capitalize", mb: 0.5, lineHeight: 1 },
|
|
236
|
+
children: r
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
/* @__PURE__ */ o(a, { sx: { display: "flex", flexWrap: "wrap", gap: 1 }, children: x.map((n) => {
|
|
240
|
+
let v = "";
|
|
241
|
+
return e.originalMuiKey === n.colorKey && (n.colorValue === "transparent" ? v = "rgba(0,0,0,0.7)" : ae(n.colorValue).isDark() ? v = "rgba(255,255,255,0.8)" : v = "rgba(0,0,0,0.7)"), /* @__PURE__ */ o(q, { title: n.colorKey, children: /* @__PURE__ */ o(
|
|
242
|
+
a,
|
|
243
|
+
{
|
|
244
|
+
onClick: () => {
|
|
245
|
+
e.value = n.colorValue, e.originalMuiKey = n.colorKey;
|
|
246
|
+
},
|
|
247
|
+
sx: {
|
|
248
|
+
width: 28,
|
|
249
|
+
height: 28,
|
|
250
|
+
bgcolor: n.colorValue,
|
|
251
|
+
border: e.originalMuiKey === n.colorKey ? `2px solid ${v}` : "1px solid #ccc",
|
|
252
|
+
borderRadius: 0.5,
|
|
253
|
+
cursor: "pointer",
|
|
254
|
+
"&:hover": { opacity: 0.8 },
|
|
255
|
+
display: "flex",
|
|
256
|
+
alignItems: "center",
|
|
257
|
+
justifyContent: "center",
|
|
258
|
+
// 透明色时显示棋盘背景
|
|
259
|
+
...n.colorValue === "transparent" ? {
|
|
260
|
+
background: "repeating-conic-gradient(#CCCCCC 0% 25%, #FFFFFF 0% 50%) 50% / 10px 10px"
|
|
261
|
+
} : {}
|
|
262
|
+
},
|
|
263
|
+
children: e.originalMuiKey === n.colorKey && /* @__PURE__ */ o(
|
|
264
|
+
"i",
|
|
265
|
+
{
|
|
266
|
+
className: "i-mdi:check",
|
|
267
|
+
style: {
|
|
268
|
+
color: v,
|
|
269
|
+
fontSize: "1.2rem"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
) }, n.colorKey);
|
|
275
|
+
}) })
|
|
276
|
+
] }, r)) })
|
|
277
|
+
) : (
|
|
278
|
+
// 自定义颜色选择器
|
|
279
|
+
/* @__PURE__ */ o(a, { sx: { overflowY: "auto", overflowX: "hidden" }, children: /* @__PURE__ */ o(ne, { fallback: /* @__PURE__ */ o(J, { variant: "rectangular", width: T, height: M }), children: /* @__PURE__ */ o(
|
|
280
|
+
Te,
|
|
281
|
+
{
|
|
282
|
+
disableDarkMode: !0,
|
|
283
|
+
width: T,
|
|
284
|
+
height: T,
|
|
285
|
+
value: e.value,
|
|
286
|
+
onChange: (r) => {
|
|
287
|
+
e.value = r, e.originalMuiKey = null;
|
|
288
|
+
},
|
|
289
|
+
hidePresets: !0,
|
|
290
|
+
hideAdvancedSliders: !0,
|
|
291
|
+
hideColorGuide: !0,
|
|
292
|
+
hideInputType: !0
|
|
293
|
+
}
|
|
294
|
+
) }) })
|
|
295
|
+
) })
|
|
296
|
+
] }),
|
|
297
|
+
/* @__PURE__ */ f(Q, { children: [
|
|
298
|
+
/* @__PURE__ */ o(K, { variant: "outlined", size: "small", onClick: m, children: t("common.cancel") }),
|
|
299
|
+
/* @__PURE__ */ o(K, { variant: "contained", size: "small", onClick: p, children: t("maker.save") })
|
|
300
|
+
] })
|
|
301
|
+
] });
|
|
302
|
+
});
|
|
303
|
+
R(a)`
|
|
304
|
+
.color-item {
|
|
305
|
+
position: relative;
|
|
306
|
+
}
|
|
307
|
+
.color-item__checked {
|
|
308
|
+
position: absolute;
|
|
309
|
+
top: 0;
|
|
310
|
+
bottom: 0;
|
|
311
|
+
left: 0;
|
|
312
|
+
right: 0;
|
|
313
|
+
display: flex;
|
|
314
|
+
justify-content: center;
|
|
315
|
+
align-items: center;
|
|
316
|
+
color: rgba(255, 255, 255, 0.85);
|
|
317
|
+
}
|
|
318
|
+
.color-item__delete {
|
|
319
|
+
position: absolute;
|
|
320
|
+
top: 0;
|
|
321
|
+
right: 0;
|
|
322
|
+
}
|
|
323
|
+
`;
|
|
324
|
+
export {
|
|
325
|
+
Ue as C,
|
|
326
|
+
Xe as a,
|
|
327
|
+
Ne as b
|
|
328
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { u as o, S as a,
|
|
2
|
+
import { u as o, S as a, l as s, d as n } from "./state-DsXKwImw.js";
|
|
3
3
|
function d({ children: t }) {
|
|
4
4
|
const r = o();
|
|
5
5
|
return /* @__PURE__ */ e(a, { url: s(r ?? ""), name: "root", waitingSynced: !0, children: /* @__PURE__ */ e(i, { children: t }) });
|