@rulab/adminjs-components 0.0.8 → 0.0.10
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/index.cjs +372 -252
- package/dist/index.d.cts +22 -15
- package/dist/index.d.ts +22 -15
- package/dist/index.js +366 -249
- package/package.json +4 -1
- package/src/components/ColorStatus/ColorStatusEdit.tsx +94 -0
- package/src/components/ColorStatus/ColorStatusList.tsx +20 -0
- package/src/components/ColorStatus/ColorStatusShow.tsx +23 -0
- package/src/components/ColorStatus/index.ts +3 -0
- package/src/components/ColorStatus/styles.ts +30 -0
- package/src/components/ColorStatus/types.ts +5 -0
- package/src/components/index.ts +6 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,121 @@
|
|
|
1
|
+
// src/components/ColorStatus/ColorStatusEdit.tsx
|
|
2
|
+
import React, { useState, useEffect } from "react";
|
|
3
|
+
import Select from "react-select";
|
|
4
|
+
import chroma from "chroma-js";
|
|
5
|
+
|
|
6
|
+
// src/components/ColorStatus/styles.ts
|
|
7
|
+
import { styled } from "@adminjs/design-system/styled-components";
|
|
8
|
+
var ColorStatusWrapper = styled.div`
|
|
9
|
+
margin-bottom: 24px;
|
|
10
|
+
`;
|
|
11
|
+
var Label = styled.div`
|
|
12
|
+
font-size: 12px;
|
|
13
|
+
margin-bottom: 8px;
|
|
14
|
+
`;
|
|
15
|
+
var ShowLabel = styled.div`
|
|
16
|
+
font-size: 12px;
|
|
17
|
+
margin-bottom: 8px;
|
|
18
|
+
color: rgb(137, 138, 154);
|
|
19
|
+
`;
|
|
20
|
+
var ColorStatusBadgeWrapper = styled.div`
|
|
21
|
+
margin-bottom: 20px;
|
|
22
|
+
`;
|
|
23
|
+
var ColorStatusBadge = styled.div`
|
|
24
|
+
background-color: ${(props) => props.color};
|
|
25
|
+
width: fit-content;
|
|
26
|
+
padding: 5px 10px;
|
|
27
|
+
border-radius: 20px;
|
|
28
|
+
font-size: 12px;
|
|
29
|
+
color: white;
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
// src/components/ColorStatus/ColorStatusEdit.tsx
|
|
34
|
+
var dot = (color = "transparent") => ({
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
display: "flex",
|
|
37
|
+
":before": {
|
|
38
|
+
backgroundColor: color,
|
|
39
|
+
borderRadius: 10,
|
|
40
|
+
content: '" "',
|
|
41
|
+
display: "block",
|
|
42
|
+
marginRight: 8,
|
|
43
|
+
height: 10,
|
|
44
|
+
width: 10
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
var colorStyles = {
|
|
48
|
+
control: (styles) => ({ ...styles, backgroundColor: "white" }),
|
|
49
|
+
option: (styles, { data, isDisabled, isFocused, isSelected }) => {
|
|
50
|
+
const color = chroma(data.color);
|
|
51
|
+
return {
|
|
52
|
+
...styles,
|
|
53
|
+
backgroundColor: isSelected ? data.color : isFocused ? color.alpha(0.1).css() : void 0,
|
|
54
|
+
color: isSelected ? chroma.contrast(color, "white") > 2 ? "white" : "black" : data.color,
|
|
55
|
+
":active": {
|
|
56
|
+
...styles[":active"],
|
|
57
|
+
backgroundColor: isSelected ? data.color : color.alpha(0.3).css()
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
input: (styles) => ({ ...styles, ...dot() }),
|
|
62
|
+
placeholder: (styles) => ({ ...styles, ...dot("#ccc") }),
|
|
63
|
+
singleValue: (styles, { data }) => ({ ...styles, ...dot(data.color) })
|
|
64
|
+
};
|
|
65
|
+
var ColorStatus = ({ property, record, onChange }) => {
|
|
66
|
+
const availableValues = property.availableValues;
|
|
67
|
+
const currentOption = availableValues.find(
|
|
68
|
+
(item) => item.value === record.params[property.path]
|
|
69
|
+
);
|
|
70
|
+
const [selectOption, setCurrentOption] = useState(currentOption);
|
|
71
|
+
const handleSelectChange = (option) => {
|
|
72
|
+
setCurrentOption(option);
|
|
73
|
+
};
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
onChange(property.path, selectOption?.value);
|
|
76
|
+
}, [selectOption]);
|
|
77
|
+
return /* @__PURE__ */ React.createElement(ColorStatusWrapper, null, /* @__PURE__ */ React.createElement(Label, null, property.path), /* @__PURE__ */ React.createElement(
|
|
78
|
+
Select,
|
|
79
|
+
{
|
|
80
|
+
className: "basic-single",
|
|
81
|
+
classNamePrefix: "select",
|
|
82
|
+
defaultValue: selectOption ?? availableValues[0],
|
|
83
|
+
onChange: handleSelectChange,
|
|
84
|
+
isClearable: true,
|
|
85
|
+
name: "color",
|
|
86
|
+
options: availableValues,
|
|
87
|
+
styles: colorStyles
|
|
88
|
+
}
|
|
89
|
+
));
|
|
90
|
+
};
|
|
91
|
+
var ColorStatusEdit_default = ColorStatus;
|
|
92
|
+
|
|
93
|
+
// src/components/ColorStatus/ColorStatusShow.tsx
|
|
94
|
+
import React2 from "react";
|
|
95
|
+
var ColorStatusShow = ({ property, record }) => {
|
|
96
|
+
const currentOption = property.availableValues?.find(
|
|
97
|
+
(item) => item.value === record.params[property.path]
|
|
98
|
+
);
|
|
99
|
+
return /* @__PURE__ */ React2.createElement(ColorStatusBadgeWrapper, null, /* @__PURE__ */ React2.createElement(ShowLabel, null, property.path), /* @__PURE__ */ React2.createElement(ColorStatusBadge, { color: currentOption.color }, record.params[property.path]));
|
|
100
|
+
};
|
|
101
|
+
var ColorStatusShow_default = ColorStatusShow;
|
|
102
|
+
|
|
103
|
+
// src/components/ColorStatus/ColorStatusList.tsx
|
|
104
|
+
import React3 from "react";
|
|
105
|
+
var ColorStatusList = ({ property, record }) => {
|
|
106
|
+
const currentOption = property.availableValues?.find(
|
|
107
|
+
(item) => item.value === record.params[property.path]
|
|
108
|
+
);
|
|
109
|
+
console.log(record, "record");
|
|
110
|
+
console.log(record.params[property.path], "record.params[property.path]");
|
|
111
|
+
return /* @__PURE__ */ React3.createElement(ColorStatusBadge, { color: currentOption.color }, record.params[property.path]);
|
|
112
|
+
};
|
|
113
|
+
var ColorStatusList_default = ColorStatusList;
|
|
114
|
+
|
|
1
115
|
// src/components/CustomSlug/CustomSlug.tsx
|
|
2
|
-
import
|
|
3
|
-
useEffect,
|
|
4
|
-
useState
|
|
116
|
+
import React4, {
|
|
117
|
+
useEffect as useEffect2,
|
|
118
|
+
useState as useState2
|
|
5
119
|
} from "react";
|
|
6
120
|
import { ThemeProvider } from "styled-components";
|
|
7
121
|
import { theme } from "@adminjs/design-system";
|
|
@@ -22,20 +136,20 @@ var slugifyTitle = (title) => {
|
|
|
22
136
|
};
|
|
23
137
|
|
|
24
138
|
// src/components/CustomSlug/styles.ts
|
|
25
|
-
import { styled } from "@adminjs/design-system/styled-components";
|
|
139
|
+
import { styled as styled2 } from "@adminjs/design-system/styled-components";
|
|
26
140
|
import { Box, Button, Input } from "@adminjs/design-system";
|
|
27
|
-
var StyledInputWrapper =
|
|
141
|
+
var StyledInputWrapper = styled2(Box)`
|
|
28
142
|
display: flex;
|
|
29
143
|
margin-bottom: 40px;
|
|
30
144
|
`;
|
|
31
|
-
var StyledCustomInput =
|
|
145
|
+
var StyledCustomInput = styled2(Input)`
|
|
32
146
|
width: 100%;
|
|
33
147
|
margin-right: 10px;
|
|
34
148
|
`;
|
|
35
|
-
var StyledGenerateButton =
|
|
149
|
+
var StyledGenerateButton = styled2(Button)`
|
|
36
150
|
white-space: nowrap;
|
|
37
151
|
`;
|
|
38
|
-
var StyledLabel =
|
|
152
|
+
var StyledLabel = styled2.div`
|
|
39
153
|
font-size: 12px;
|
|
40
154
|
margin-bottom: 8px;
|
|
41
155
|
text-transform: capitalize;
|
|
@@ -43,11 +157,11 @@ var StyledLabel = styled.div`
|
|
|
43
157
|
|
|
44
158
|
// src/components/CustomSlug/CustomSlug.tsx
|
|
45
159
|
var CustomSlug = ({ property, record, onChange }) => {
|
|
46
|
-
const [inputValue, setInputValue] =
|
|
47
|
-
|
|
160
|
+
const [inputValue, setInputValue] = useState2(record.params.slug);
|
|
161
|
+
useEffect2(() => {
|
|
48
162
|
onChange(property.path, inputValue);
|
|
49
163
|
}, [inputValue]);
|
|
50
|
-
return /* @__PURE__ */
|
|
164
|
+
return /* @__PURE__ */ React4.createElement(ThemeProvider, { theme }, /* @__PURE__ */ React4.createElement(StyledLabel, { htmlFor: "customSlug" }, property.path), /* @__PURE__ */ React4.createElement(StyledInputWrapper, null, /* @__PURE__ */ React4.createElement(
|
|
51
165
|
StyledCustomInput,
|
|
52
166
|
{
|
|
53
167
|
id: property.path,
|
|
@@ -55,7 +169,7 @@ var CustomSlug = ({ property, record, onChange }) => {
|
|
|
55
169
|
value: inputValue,
|
|
56
170
|
onChange: handleInput
|
|
57
171
|
}
|
|
58
|
-
), /* @__PURE__ */
|
|
172
|
+
), /* @__PURE__ */ React4.createElement(StyledGenerateButton, { variant: "outlined", onClick: generateSlug }, "Generate Slug")));
|
|
59
173
|
function handleInput(e) {
|
|
60
174
|
setInputValue(e.target.value);
|
|
61
175
|
}
|
|
@@ -69,51 +183,246 @@ var CustomSlug = ({ property, record, onChange }) => {
|
|
|
69
183
|
};
|
|
70
184
|
var CustomSlug_default = CustomSlug;
|
|
71
185
|
|
|
186
|
+
// src/components/Editor/Editor.jsx
|
|
187
|
+
import React5, { memo, useState as useState3, useEffect as useEffect3, useRef } from "react";
|
|
188
|
+
import { ThemeProvider as ThemeProvider2 } from "styled-components";
|
|
189
|
+
import EditorJS from "@editorjs/editorjs";
|
|
190
|
+
import { theme as theme2 } from "@adminjs/design-system";
|
|
191
|
+
|
|
192
|
+
// src/components/Editor/styles.ts
|
|
193
|
+
import { Box as Box2 } from "@adminjs/design-system";
|
|
194
|
+
import { styled as styled3 } from "@adminjs/design-system/styled-components";
|
|
195
|
+
var StyledLabel2 = styled3.div`
|
|
196
|
+
font-size: 12px;
|
|
197
|
+
margin-bottom: 8px;
|
|
198
|
+
text-transform: capitalize;
|
|
199
|
+
`;
|
|
200
|
+
var StyledShowLabel = styled3(StyledLabel2)`
|
|
201
|
+
color: rgb(137, 138, 154);
|
|
202
|
+
font-weight: 300;
|
|
203
|
+
`;
|
|
204
|
+
var StyledEditorWrapper = styled3(Box2)`
|
|
205
|
+
padding: 12px;
|
|
206
|
+
margin-bottom: 24px;
|
|
207
|
+
border: 1px solid rgb(187, 195, 203);
|
|
208
|
+
`;
|
|
209
|
+
var StyledEditorViewWrapper = styled3(Box2)`
|
|
210
|
+
h1,
|
|
211
|
+
h2,
|
|
212
|
+
h3 {
|
|
213
|
+
margin-bottom: 5px;
|
|
214
|
+
font-weight: bold;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
h1 {
|
|
218
|
+
font-size: 18px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
h2 {
|
|
222
|
+
font-size: 16px;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
h3 {
|
|
226
|
+
font-size: 14px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
p {
|
|
230
|
+
margin-bottom: 8px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
ol,
|
|
234
|
+
ul {
|
|
235
|
+
margin-left: 20px;
|
|
236
|
+
margin-bottom: 8px;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
ol {
|
|
240
|
+
list-style: auto;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
ul {
|
|
244
|
+
list-style: inherit;
|
|
245
|
+
}
|
|
246
|
+
`;
|
|
247
|
+
var StyledEditorShowWrapper = styled3(StyledEditorViewWrapper)`
|
|
248
|
+
margin-bottom: 24px;
|
|
249
|
+
`;
|
|
250
|
+
var StyledEditor = styled3.div`
|
|
251
|
+
.cdx-block,
|
|
252
|
+
.ce-header {
|
|
253
|
+
padding-left: 58px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.cdx-list {
|
|
257
|
+
padding-left: 85px;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.ce-block__content {
|
|
261
|
+
width: 100%;
|
|
262
|
+
max-width: none;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.ce-toolbar__content {
|
|
266
|
+
max-width: none;
|
|
267
|
+
left: 0;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.ce-toolbar__actions {
|
|
271
|
+
left: 0;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
h1.ce-header {
|
|
275
|
+
font-size: 22px;
|
|
276
|
+
font-weight: bold;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
h2.ce-header {
|
|
280
|
+
font-size: 20px;
|
|
281
|
+
font-weight: bold;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
h3.ce-header {
|
|
285
|
+
font-size: 18px;
|
|
286
|
+
font-weight: bold;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
h4.ce-header {
|
|
290
|
+
font-size: 16px;
|
|
291
|
+
font-weight: bold;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
h5.ce-header {
|
|
295
|
+
font-size: 15px;
|
|
296
|
+
font-weight: bold;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
h6.ce-header {
|
|
300
|
+
font-size: 14px;
|
|
301
|
+
font-weight: bold;
|
|
302
|
+
}
|
|
303
|
+
`;
|
|
304
|
+
|
|
305
|
+
// src/components/Editor/config.ts
|
|
306
|
+
import Header from "@editorjs/header";
|
|
307
|
+
import Paragraph from "@editorjs/paragraph";
|
|
308
|
+
import List from "@editorjs/list";
|
|
309
|
+
var EDITOR_TOOLS = {
|
|
310
|
+
paragraph: {
|
|
311
|
+
class: Paragraph,
|
|
312
|
+
inlineToolbar: true
|
|
313
|
+
},
|
|
314
|
+
list: List,
|
|
315
|
+
header: Header
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
// src/components/Editor/Editor.jsx
|
|
319
|
+
var Editor = ({ property, record, onChangeAdmin, editorId }) => {
|
|
320
|
+
const [jsonData, setJsonData] = useState3();
|
|
321
|
+
const isSavedData = Boolean(record.params[property.path]);
|
|
322
|
+
const ref = useRef();
|
|
323
|
+
useEffect3(() => {
|
|
324
|
+
onChangeAdmin(property.path, jsonData);
|
|
325
|
+
}, [jsonData]);
|
|
326
|
+
useEffect3(() => {
|
|
327
|
+
if (!ref.current) {
|
|
328
|
+
const editor = new EditorJS({
|
|
329
|
+
holder: editorId,
|
|
330
|
+
tools: EDITOR_TOOLS,
|
|
331
|
+
data: isSavedData ? JSON.parse(record.params[property.path]) : "",
|
|
332
|
+
async onChange(api, event) {
|
|
333
|
+
const data = await api.saver.save();
|
|
334
|
+
setJsonData(JSON.stringify(data));
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
ref.current = editor;
|
|
338
|
+
}
|
|
339
|
+
return () => {
|
|
340
|
+
ref?.current?.destroy?.();
|
|
341
|
+
};
|
|
342
|
+
}, []);
|
|
343
|
+
return /* @__PURE__ */ React5.createElement(ThemeProvider2, { theme: theme2 }, /* @__PURE__ */ React5.createElement(StyledLabel2, null, property.path), /* @__PURE__ */ React5.createElement(StyledEditorWrapper, null, /* @__PURE__ */ React5.createElement(StyledEditor, { id: editorId })));
|
|
344
|
+
};
|
|
345
|
+
var Editor_default = Editor;
|
|
346
|
+
|
|
347
|
+
// src/components/Editor/EditorList.jsx
|
|
348
|
+
import React6 from "react";
|
|
349
|
+
import { ThemeProvider as ThemeProvider3 } from "styled-components";
|
|
350
|
+
import { theme as theme3 } from "@adminjs/design-system";
|
|
351
|
+
|
|
352
|
+
// src/utils/parseHtml.ts
|
|
353
|
+
import edjsHTML from "editorjs-html";
|
|
354
|
+
var parseHtml = (jsonData) => {
|
|
355
|
+
const edjsParser = edjsHTML();
|
|
356
|
+
try {
|
|
357
|
+
const data = edjsParser.parse(JSON.parse(String(jsonData)));
|
|
358
|
+
return String(data).replace(/>,</g, "><");
|
|
359
|
+
} catch (e) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// src/components/Editor/EditorList.jsx
|
|
365
|
+
var EditorList = ({ property, record }) => {
|
|
366
|
+
const htmlContent = parseHtml(record.params[property.path]);
|
|
367
|
+
return /* @__PURE__ */ React6.createElement(ThemeProvider3, { theme: theme3 }, /* @__PURE__ */ React6.createElement(StyledEditorViewWrapper, null, htmlContent && /* @__PURE__ */ React6.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })));
|
|
368
|
+
};
|
|
369
|
+
var EditorList_default = EditorList;
|
|
370
|
+
|
|
371
|
+
// src/components/Editor/EditorShow.jsx
|
|
372
|
+
import React7 from "react";
|
|
373
|
+
import { ThemeProvider as ThemeProvider4 } from "styled-components";
|
|
374
|
+
import { theme as theme4 } from "@adminjs/design-system";
|
|
375
|
+
var EditorShow = ({ property, record }) => {
|
|
376
|
+
const htmlContent = parseHtml(record.params[property.path]);
|
|
377
|
+
return /* @__PURE__ */ React7.createElement(ThemeProvider4, { theme: theme4 }, /* @__PURE__ */ React7.createElement(StyledEditorShowWrapper, null, /* @__PURE__ */ React7.createElement(StyledShowLabel, null, property.path), htmlContent && /* @__PURE__ */ React7.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })));
|
|
378
|
+
};
|
|
379
|
+
var EditorShow_default = EditorShow;
|
|
380
|
+
|
|
72
381
|
// src/components/StringList/StringList.tsx
|
|
73
|
-
import { Button as Button3, Input as Input3, theme as
|
|
74
|
-
import
|
|
75
|
-
useEffect as
|
|
76
|
-
useState as
|
|
382
|
+
import { Button as Button3, Input as Input3, theme as theme5 } from "@adminjs/design-system";
|
|
383
|
+
import React11, {
|
|
384
|
+
useEffect as useEffect4,
|
|
385
|
+
useState as useState5
|
|
77
386
|
} from "react";
|
|
78
|
-
import { ThemeProvider as
|
|
387
|
+
import { ThemeProvider as ThemeProvider5 } from "styled-components";
|
|
79
388
|
|
|
80
389
|
// src/components/StringList/styles.ts
|
|
81
|
-
import { Box as
|
|
82
|
-
import { styled as
|
|
83
|
-
var StyledWrapper =
|
|
390
|
+
import { Box as Box3, Input as Input2 } from "@adminjs/design-system";
|
|
391
|
+
import { styled as styled4 } from "@adminjs/design-system/styled-components";
|
|
392
|
+
var StyledWrapper = styled4(Box3)`
|
|
84
393
|
display: flex;
|
|
85
394
|
flex-direction: column;
|
|
86
395
|
margin-bottom: 45px;
|
|
87
396
|
`;
|
|
88
|
-
var StyledCustomInput2 =
|
|
397
|
+
var StyledCustomInput2 = styled4(Input2)`
|
|
89
398
|
width: 100%;
|
|
90
399
|
margin-right: 10px;
|
|
91
400
|
`;
|
|
92
|
-
var StyledInputWrapper2 =
|
|
401
|
+
var StyledInputWrapper2 = styled4(Box3)`
|
|
93
402
|
display: flex;
|
|
94
403
|
`;
|
|
95
|
-
var StyledListWrapper =
|
|
404
|
+
var StyledListWrapper = styled4(Box3)`
|
|
96
405
|
margin-bottom: 15px;
|
|
97
406
|
`;
|
|
98
|
-
var
|
|
407
|
+
var StyledLabel3 = styled4.div`
|
|
99
408
|
font-size: 12px;
|
|
100
409
|
margin-bottom: 8px;
|
|
101
410
|
text-transform: capitalize;
|
|
102
411
|
`;
|
|
103
|
-
var
|
|
412
|
+
var StyledShowLabel2 = styled4(StyledLabel3)`
|
|
104
413
|
line-height: 16px;
|
|
105
414
|
color: rgb(137, 138, 154);
|
|
106
415
|
font-weight: 300;
|
|
107
416
|
`;
|
|
108
|
-
var StyledShowWrapper =
|
|
417
|
+
var StyledShowWrapper = styled4(Box3)`
|
|
109
418
|
margin-bottom: 35px;
|
|
110
419
|
`;
|
|
111
|
-
var StyledListItem =
|
|
420
|
+
var StyledListItem = styled4.li`
|
|
112
421
|
margin-bottom: 5px;
|
|
113
422
|
`;
|
|
114
423
|
|
|
115
424
|
// src/components/StringList/SortableList/SortableList.tsx
|
|
116
|
-
import
|
|
425
|
+
import React10, { Fragment, useMemo as useMemo2, useState as useState4 } from "react";
|
|
117
426
|
import {
|
|
118
427
|
DndContext,
|
|
119
428
|
KeyboardSensor,
|
|
@@ -131,16 +440,16 @@ import {
|
|
|
131
440
|
} from "@dnd-kit/sortable";
|
|
132
441
|
|
|
133
442
|
// src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx
|
|
134
|
-
import
|
|
443
|
+
import React9, { createContext, useMemo } from "react";
|
|
135
444
|
import { useSortable } from "@dnd-kit/sortable";
|
|
136
445
|
import { Button as Button2, Icon } from "@adminjs/design-system";
|
|
137
446
|
|
|
138
447
|
// src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx
|
|
139
|
-
import
|
|
448
|
+
import React8, { useContext } from "react";
|
|
140
449
|
|
|
141
450
|
// src/components/StringList/SortableList/components/SortableItem/styles.ts
|
|
142
|
-
import { styled as
|
|
143
|
-
var StyledListItem2 =
|
|
451
|
+
import { styled as styled5 } from "@adminjs/design-system/styled-components";
|
|
452
|
+
var StyledListItem2 = styled5.li`
|
|
144
453
|
display: flex;
|
|
145
454
|
justify-content: space-between;
|
|
146
455
|
align-items: center;
|
|
@@ -152,7 +461,7 @@ var StyledListItem2 = styled3.li`
|
|
|
152
461
|
border-radius: 5px;
|
|
153
462
|
list-style: none;
|
|
154
463
|
`;
|
|
155
|
-
var StyledDragButton =
|
|
464
|
+
var StyledDragButton = styled5.button`
|
|
156
465
|
padding: 3px;
|
|
157
466
|
margin-right: 15px;
|
|
158
467
|
cursor: move;
|
|
@@ -163,7 +472,7 @@ var StyledDragButton = styled3.button`
|
|
|
163
472
|
// src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx
|
|
164
473
|
var DragHandle = ({ context }) => {
|
|
165
474
|
const { attributes, listeners, ref } = useContext(context);
|
|
166
|
-
return /* @__PURE__ */
|
|
475
|
+
return /* @__PURE__ */ React8.createElement(StyledDragButton, { ...attributes, ...listeners, ref }, /* @__PURE__ */ React8.createElement("svg", { viewBox: "0 0 20 20", width: "13" }, /* @__PURE__ */ React8.createElement("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" })));
|
|
167
476
|
};
|
|
168
477
|
|
|
169
478
|
// src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx
|
|
@@ -190,7 +499,7 @@ function SortableItem({
|
|
|
190
499
|
const style = {
|
|
191
500
|
opacity: isDragging ? 0.4 : void 0
|
|
192
501
|
};
|
|
193
|
-
return /* @__PURE__ */
|
|
502
|
+
return /* @__PURE__ */ React9.createElement(SortableItemContext.Provider, { value: context }, /* @__PURE__ */ React9.createElement(StyledListItem2, { ref: setNodeRef, style }, /* @__PURE__ */ React9.createElement("div", null, /* @__PURE__ */ React9.createElement(DragHandle, { context: SortableItemContext }), children), /* @__PURE__ */ React9.createElement(
|
|
194
503
|
Button2,
|
|
195
504
|
{
|
|
196
505
|
variant: "outlined",
|
|
@@ -198,13 +507,13 @@ function SortableItem({
|
|
|
198
507
|
size: "icon",
|
|
199
508
|
onClick: (e) => onDelete(e, id)
|
|
200
509
|
},
|
|
201
|
-
/* @__PURE__ */
|
|
510
|
+
/* @__PURE__ */ React9.createElement(Icon, { icon: "X", color: "red" })
|
|
202
511
|
)));
|
|
203
512
|
}
|
|
204
513
|
|
|
205
514
|
// src/components/StringList/SortableList/styles.ts
|
|
206
|
-
import { styled as
|
|
207
|
-
var StyledListWrapper2 =
|
|
515
|
+
import { styled as styled6 } from "@adminjs/design-system/styled-components";
|
|
516
|
+
var StyledListWrapper2 = styled6.ul`
|
|
208
517
|
display: flex;
|
|
209
518
|
flex-direction: column;
|
|
210
519
|
gap: 12px;
|
|
@@ -227,7 +536,7 @@ function SortableList({
|
|
|
227
536
|
onChange,
|
|
228
537
|
renderItem
|
|
229
538
|
}) {
|
|
230
|
-
const [active, setActive] =
|
|
539
|
+
const [active, setActive] = useState4(null);
|
|
231
540
|
const activeItem = useMemo2(
|
|
232
541
|
() => items.find((item) => item.id === active?.id),
|
|
233
542
|
[active, items]
|
|
@@ -238,7 +547,7 @@ function SortableList({
|
|
|
238
547
|
coordinateGetter: sortableKeyboardCoordinates
|
|
239
548
|
})
|
|
240
549
|
);
|
|
241
|
-
return /* @__PURE__ */
|
|
550
|
+
return /* @__PURE__ */ React10.createElement(
|
|
242
551
|
DndContext,
|
|
243
552
|
{
|
|
244
553
|
sensors,
|
|
@@ -257,8 +566,8 @@ function SortableList({
|
|
|
257
566
|
setActive(null);
|
|
258
567
|
}
|
|
259
568
|
},
|
|
260
|
-
/* @__PURE__ */
|
|
261
|
-
/* @__PURE__ */
|
|
569
|
+
/* @__PURE__ */ React10.createElement(SortableContext, { items, strategy: verticalListSortingStrategy }, /* @__PURE__ */ React10.createElement(StyledListWrapper2, { role: "application" }, items.map((item, index) => /* @__PURE__ */ React10.createElement(Fragment, { key: index }, renderItem(item))))),
|
|
570
|
+
/* @__PURE__ */ React10.createElement(DragOverlay, { dropAnimation: dropAnimationConfig }, activeItem ? renderItem(activeItem) : null)
|
|
262
571
|
);
|
|
263
572
|
}
|
|
264
573
|
SortableList.Item = SortableItem;
|
|
@@ -275,20 +584,20 @@ var StringList = ({
|
|
|
275
584
|
}) => {
|
|
276
585
|
const stringListValue = record.params?.[property.path] ?? property.props.value ?? "";
|
|
277
586
|
const initialList = stringListValue ? prepareDataForList(stringListValue) : [];
|
|
278
|
-
const [inputValue, setInputValue] =
|
|
279
|
-
const [list, setList] =
|
|
587
|
+
const [inputValue, setInputValue] = useState5("");
|
|
588
|
+
const [list, setList] = useState5(initialList);
|
|
280
589
|
const serializedData = prepareDataForDatabase(list);
|
|
281
|
-
|
|
590
|
+
useEffect4(() => {
|
|
282
591
|
onChange(property.path, serializedData);
|
|
283
592
|
}, [serializedData]);
|
|
284
|
-
return /* @__PURE__ */
|
|
593
|
+
return /* @__PURE__ */ React11.createElement(ThemeProvider5, { theme: theme5 }, /* @__PURE__ */ React11.createElement(StyledLabel3, { htmlFor: "custom" }, property.path), /* @__PURE__ */ React11.createElement(StyledWrapper, null, /* @__PURE__ */ React11.createElement(StyledListWrapper, null, /* @__PURE__ */ React11.createElement(
|
|
285
594
|
SortableList,
|
|
286
595
|
{
|
|
287
596
|
items: list,
|
|
288
597
|
onChange: setList,
|
|
289
|
-
renderItem: (item) => /* @__PURE__ */
|
|
598
|
+
renderItem: (item) => /* @__PURE__ */ React11.createElement(SortableList.Item, { id: item.id, onDelete: handleDeleteButton }, item.value)
|
|
290
599
|
}
|
|
291
|
-
)), /* @__PURE__ */
|
|
600
|
+
)), /* @__PURE__ */ React11.createElement(StyledInputWrapper2, null, /* @__PURE__ */ React11.createElement(
|
|
292
601
|
Input3,
|
|
293
602
|
{
|
|
294
603
|
id: "stringList",
|
|
@@ -296,7 +605,7 @@ var StringList = ({
|
|
|
296
605
|
value: serializedData,
|
|
297
606
|
hidden: true
|
|
298
607
|
}
|
|
299
|
-
), /* @__PURE__ */
|
|
608
|
+
), /* @__PURE__ */ React11.createElement(
|
|
300
609
|
StyledCustomInput2,
|
|
301
610
|
{
|
|
302
611
|
id: "custom",
|
|
@@ -305,7 +614,7 @@ var StringList = ({
|
|
|
305
614
|
onChange: handleInput,
|
|
306
615
|
onKeyPress: handleEnterPress
|
|
307
616
|
}
|
|
308
|
-
), /* @__PURE__ */
|
|
617
|
+
), /* @__PURE__ */ React11.createElement(Button3, { variant: "outlined", onClick: handleAddButton }, "Add"))));
|
|
309
618
|
function handleInput(e) {
|
|
310
619
|
setInputValue(e.target.value);
|
|
311
620
|
}
|
|
@@ -342,213 +651,21 @@ var StringList = ({
|
|
|
342
651
|
var StringList_default = StringList;
|
|
343
652
|
|
|
344
653
|
// src/components/StringList/StringListShow.tsx
|
|
345
|
-
import
|
|
346
|
-
import { ThemeProvider as
|
|
347
|
-
import { theme as
|
|
654
|
+
import React12 from "react";
|
|
655
|
+
import { ThemeProvider as ThemeProvider6 } from "styled-components";
|
|
656
|
+
import { theme as theme6 } from "@adminjs/design-system";
|
|
348
657
|
var StringListShow = ({
|
|
349
658
|
property,
|
|
350
659
|
record,
|
|
351
660
|
stringListSeparator = separator
|
|
352
661
|
}) => {
|
|
353
|
-
return /* @__PURE__ */
|
|
662
|
+
return /* @__PURE__ */ React12.createElement(ThemeProvider6, { theme: theme6 }, /* @__PURE__ */ React12.createElement(StyledShowWrapper, null, /* @__PURE__ */ React12.createElement(StyledShowLabel2, null, property.path), record.params.facts && /* @__PURE__ */ React12.createElement("ul", null, record.params.facts.split(stringListSeparator).map((item, index) => /* @__PURE__ */ React12.createElement(StyledListItem, { key: index }, `- ${item}`)))));
|
|
354
663
|
};
|
|
355
664
|
var StringListShow_default = StringListShow;
|
|
356
|
-
|
|
357
|
-
// src/components/Editor/Editor.jsx
|
|
358
|
-
import React7, { memo as memo2, useState as useState5, useEffect as useEffect4, useRef as useRef2 } from "react";
|
|
359
|
-
import { ThemeProvider as ThemeProvider4 } from "styled-components";
|
|
360
|
-
import EditorJS from "@editorjs/editorjs";
|
|
361
|
-
import { theme as theme4 } from "@adminjs/design-system";
|
|
362
|
-
|
|
363
|
-
// src/components/Editor/styles.ts
|
|
364
|
-
import { Box as Box3 } from "@adminjs/design-system";
|
|
365
|
-
import { styled as styled5 } from "@adminjs/design-system/styled-components";
|
|
366
|
-
var StyledLabel3 = styled5.div`
|
|
367
|
-
font-size: 12px;
|
|
368
|
-
margin-bottom: 8px;
|
|
369
|
-
text-transform: capitalize;
|
|
370
|
-
`;
|
|
371
|
-
var StyledShowLabel2 = styled5(StyledLabel3)`
|
|
372
|
-
color: rgb(137, 138, 154);
|
|
373
|
-
font-weight: 300;
|
|
374
|
-
`;
|
|
375
|
-
var StyledEditorWrapper = styled5(Box3)`
|
|
376
|
-
padding: 12px;
|
|
377
|
-
margin-bottom: 24px;
|
|
378
|
-
border: 1px solid rgb(187, 195, 203);
|
|
379
|
-
`;
|
|
380
|
-
var StyledEditorViewWrapper = styled5(Box3)`
|
|
381
|
-
h1,
|
|
382
|
-
h2,
|
|
383
|
-
h3 {
|
|
384
|
-
margin-bottom: 5px;
|
|
385
|
-
font-weight: bold;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
h1 {
|
|
389
|
-
font-size: 18px;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
h2 {
|
|
393
|
-
font-size: 16px;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
h3 {
|
|
397
|
-
font-size: 14px;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
p {
|
|
401
|
-
margin-bottom: 8px;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
ol,
|
|
405
|
-
ul {
|
|
406
|
-
margin-left: 20px;
|
|
407
|
-
margin-bottom: 8px;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
ol {
|
|
411
|
-
list-style: auto;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
ul {
|
|
415
|
-
list-style: inherit;
|
|
416
|
-
}
|
|
417
|
-
`;
|
|
418
|
-
var StyledEditorShowWrapper = styled5(StyledEditorViewWrapper)`
|
|
419
|
-
margin-bottom: 24px;
|
|
420
|
-
`;
|
|
421
|
-
var StyledEditor = styled5.div`
|
|
422
|
-
.cdx-block,
|
|
423
|
-
.ce-header {
|
|
424
|
-
padding-left: 58px;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
.cdx-list {
|
|
428
|
-
padding-left: 85px;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
.ce-block__content {
|
|
432
|
-
width: 100%;
|
|
433
|
-
max-width: none;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
.ce-toolbar__content {
|
|
437
|
-
max-width: none;
|
|
438
|
-
left: 0;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
.ce-toolbar__actions {
|
|
442
|
-
left: 0;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
h1.ce-header {
|
|
446
|
-
font-size: 22px;
|
|
447
|
-
font-weight: bold;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
h2.ce-header {
|
|
451
|
-
font-size: 20px;
|
|
452
|
-
font-weight: bold;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
h3.ce-header {
|
|
456
|
-
font-size: 18px;
|
|
457
|
-
font-weight: bold;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
h4.ce-header {
|
|
461
|
-
font-size: 16px;
|
|
462
|
-
font-weight: bold;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
h5.ce-header {
|
|
466
|
-
font-size: 15px;
|
|
467
|
-
font-weight: bold;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
h6.ce-header {
|
|
471
|
-
font-size: 14px;
|
|
472
|
-
font-weight: bold;
|
|
473
|
-
}
|
|
474
|
-
`;
|
|
475
|
-
|
|
476
|
-
// src/components/Editor/config.ts
|
|
477
|
-
import Header from "@editorjs/header";
|
|
478
|
-
import Paragraph from "@editorjs/paragraph";
|
|
479
|
-
import List from "@editorjs/list";
|
|
480
|
-
var EDITOR_TOOLS = {
|
|
481
|
-
paragraph: {
|
|
482
|
-
class: Paragraph,
|
|
483
|
-
inlineToolbar: true
|
|
484
|
-
},
|
|
485
|
-
list: List,
|
|
486
|
-
header: Header
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
// src/components/Editor/Editor.jsx
|
|
490
|
-
var Editor = ({ property, record, onChangeAdmin, editorId }) => {
|
|
491
|
-
const [jsonData, setJsonData] = useState5();
|
|
492
|
-
const isSavedData = Boolean(record.params[property.path]);
|
|
493
|
-
const ref = useRef2();
|
|
494
|
-
useEffect4(() => {
|
|
495
|
-
onChangeAdmin(property.path, jsonData);
|
|
496
|
-
}, [jsonData]);
|
|
497
|
-
useEffect4(() => {
|
|
498
|
-
if (!ref.current) {
|
|
499
|
-
const editor = new EditorJS({
|
|
500
|
-
holder: editorId,
|
|
501
|
-
tools: EDITOR_TOOLS,
|
|
502
|
-
data: isSavedData ? JSON.parse(record.params[property.path]) : "",
|
|
503
|
-
async onChange(api, event) {
|
|
504
|
-
const data = await api.saver.save();
|
|
505
|
-
setJsonData(JSON.stringify(data));
|
|
506
|
-
}
|
|
507
|
-
});
|
|
508
|
-
ref.current = editor;
|
|
509
|
-
}
|
|
510
|
-
return () => {
|
|
511
|
-
ref?.current?.destroy?.();
|
|
512
|
-
};
|
|
513
|
-
}, []);
|
|
514
|
-
return /* @__PURE__ */ React7.createElement(ThemeProvider4, { theme: theme4 }, /* @__PURE__ */ React7.createElement(StyledLabel3, null, property.path), /* @__PURE__ */ React7.createElement(StyledEditorWrapper, null, /* @__PURE__ */ React7.createElement(StyledEditor, { id: editorId })));
|
|
515
|
-
};
|
|
516
|
-
var Editor_default = Editor;
|
|
517
|
-
|
|
518
|
-
// src/components/Editor/EditorShow.jsx
|
|
519
|
-
import React8 from "react";
|
|
520
|
-
import { ThemeProvider as ThemeProvider5 } from "styled-components";
|
|
521
|
-
import { theme as theme5 } from "@adminjs/design-system";
|
|
522
|
-
|
|
523
|
-
// src/utils/parseHtml.ts
|
|
524
|
-
import edjsHTML from "editorjs-html";
|
|
525
|
-
var parseHtml = (jsonData) => {
|
|
526
|
-
const edjsParser = edjsHTML();
|
|
527
|
-
try {
|
|
528
|
-
const data = edjsParser.parse(JSON.parse(String(jsonData)));
|
|
529
|
-
return String(data).replace(/>,</g, "><");
|
|
530
|
-
} catch (e) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
// src/components/Editor/EditorShow.jsx
|
|
536
|
-
var EditorShow = ({ property, record }) => {
|
|
537
|
-
const htmlContent = parseHtml(record.params[property.path]);
|
|
538
|
-
return /* @__PURE__ */ React8.createElement(ThemeProvider5, { theme: theme5 }, /* @__PURE__ */ React8.createElement(StyledEditorShowWrapper, null, /* @__PURE__ */ React8.createElement(StyledShowLabel2, null, property.path), htmlContent && /* @__PURE__ */ React8.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })));
|
|
539
|
-
};
|
|
540
|
-
var EditorShow_default = EditorShow;
|
|
541
|
-
|
|
542
|
-
// src/components/Editor/EditorList.jsx
|
|
543
|
-
import React9 from "react";
|
|
544
|
-
import { ThemeProvider as ThemeProvider6 } from "styled-components";
|
|
545
|
-
import { theme as theme6 } from "@adminjs/design-system";
|
|
546
|
-
var EditorList = ({ property, record }) => {
|
|
547
|
-
const htmlContent = parseHtml(record.params[property.path]);
|
|
548
|
-
return /* @__PURE__ */ React9.createElement(ThemeProvider6, { theme: theme6 }, /* @__PURE__ */ React9.createElement(StyledEditorViewWrapper, null, htmlContent && /* @__PURE__ */ React9.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })));
|
|
549
|
-
};
|
|
550
|
-
var EditorList_default = EditorList;
|
|
551
665
|
export {
|
|
666
|
+
ColorStatusEdit_default as ColorStatusEdit,
|
|
667
|
+
ColorStatusList_default as ColorStatusList,
|
|
668
|
+
ColorStatusShow_default as ColorStatusShow,
|
|
552
669
|
CustomSlug_default as CustomSlug,
|
|
553
670
|
Editor_default as Editor,
|
|
554
671
|
EditorList_default as EditorList,
|