@rulab/adminjs-components 0.0.12 → 0.1.0-alpha.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/LICENSE +21 -21
- package/dist/index.cjs +139 -327
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +11 -22
- package/dist/index.d.ts +11 -22
- package/dist/index.js +126 -316
- package/dist/index.js.map +1 -0
- package/package.json +12 -8
- package/src/components/ColorStatus/ColorStatusEdit.tsx +94 -94
- package/src/components/ColorStatus/ColorStatusList.tsx +20 -20
- package/src/components/ColorStatus/ColorStatusShow.tsx +23 -23
- package/src/components/ColorStatus/index.ts +3 -3
- package/src/components/ColorStatus/styles.ts +30 -30
- package/src/components/ColorStatus/types.ts +5 -5
- package/src/components/Editor/Editor.jsx +49 -49
- package/src/components/Editor/EditorList.jsx +22 -22
- package/src/components/Editor/EditorShow.jsx +24 -24
- package/src/components/Editor/config.ts +35 -26
- package/src/components/Editor/index.ts +3 -3
- package/src/components/Editor/styles.ts +151 -151
- package/src/components/{CustomSlug/CustomSlug.tsx → Slug/SlugEdit.tsx} +68 -68
- package/src/components/Slug/SlugFeature.ts +30 -0
- package/src/components/Slug/index.ts +1 -0
- package/src/components/{CustomSlug → Slug}/styles.ts +24 -24
- package/src/components/StringList/SortableList/SortableList.tsx +98 -98
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx +20 -20
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx +59 -59
- package/src/components/StringList/SortableList/components/SortableItem/styles.ts +22 -22
- package/src/components/StringList/SortableList/components/SortableItem/types.ts +7 -7
- package/src/components/StringList/SortableList/components/index.ts +2 -2
- package/src/components/StringList/SortableList/index.ts +1 -1
- package/src/components/StringList/SortableList/styles.ts +9 -9
- package/src/components/StringList/StringList.tsx +136 -136
- package/src/components/StringList/StringListShow.tsx +37 -37
- package/src/components/StringList/constants.ts +1 -1
- package/src/components/StringList/index.ts +2 -2
- package/src/components/StringList/styles.ts +41 -41
- package/src/components/index.ts +10 -9
- package/dist/bundle.js +0 -8
- package/dist/components/CustomSlug/CustomSlug.jsx +0 -29
- package/dist/components/CustomSlug/index.js +0 -1
- package/dist/components/CustomSlug/styles.js +0 -15
- package/dist/components/Editor/config.js +0 -11
- package/dist/components/Editor/index.js +0 -1
- package/dist/components/Editor/styles.js +0 -64
- package/dist/components/StringList/SortableList/SortableList.jsx +0 -43
- package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.jsx +0 -10
- package/dist/components/StringList/SortableList/components/SortableItem/SortableItem.jsx +0 -32
- package/dist/components/StringList/SortableList/components/SortableItem/styles.js +0 -20
- package/dist/components/StringList/SortableList/components/SortableItem/types.js +0 -1
- package/dist/components/StringList/SortableList/components/index.js +0 -2
- package/dist/components/StringList/SortableList/index.js +0 -1
- package/dist/components/StringList/SortableList/styles.js +0 -8
- package/dist/components/StringList/StringList.jsx +0 -67
- package/dist/components/StringList/index.js +0 -1
- package/dist/components/StringList/styles.js +0 -16
- package/dist/components/index.js +0 -3
- package/dist/editorFeature.js +0 -16
- package/dist/index.d.mts +0 -8
- package/dist/index.mjs +0 -37
- package/dist/utils/index.js +0 -1
- package/dist/utils/slugifyImport.js +0 -3
- package/dist/utils/slugifyTitle.js +0 -10
- package/src/components/CustomSlug/index.ts +0 -1
- package/src/index.ts +0 -2
- package/src/types.d.ts +0 -3
- package/src/utils/index.ts +0 -3
- package/src/utils/parseHtml.ts +0 -56
- package/src/utils/slugifyImport.ts +0 -4
- package/src/utils/slugifyTitle.ts +0 -11
- package/tsconfig.json +0 -17
package/dist/index.js
CHANGED
|
@@ -110,7 +110,7 @@ var ColorStatusList = ({ property, record }) => {
|
|
|
110
110
|
};
|
|
111
111
|
var ColorStatusList_default = ColorStatusList;
|
|
112
112
|
|
|
113
|
-
// src/components/
|
|
113
|
+
// src/components/Slug/SlugEdit.tsx
|
|
114
114
|
import React4, {
|
|
115
115
|
useEffect as useEffect2,
|
|
116
116
|
useState as useState2
|
|
@@ -118,45 +118,30 @@ import React4, {
|
|
|
118
118
|
import { ThemeProvider } from "styled-components";
|
|
119
119
|
import { theme } from "@adminjs/design-system";
|
|
120
120
|
|
|
121
|
-
// src/utils/slugifyImport.ts
|
|
122
|
-
import slugify from "slugify";
|
|
123
|
-
var slugifyImport_default = slugify;
|
|
124
|
-
|
|
125
|
-
// src/utils/slugifyTitle.ts
|
|
126
|
-
var slugifyTitle = (title) => {
|
|
127
|
-
return slugifyImport_default(title, {
|
|
128
|
-
replacement: "-",
|
|
129
|
-
remove: /[*+~.()'"!:@]/g,
|
|
130
|
-
lower: true,
|
|
131
|
-
locale: "vi",
|
|
132
|
-
trim: true
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
|
|
136
121
|
// src/utils/parseHtml.ts
|
|
137
122
|
import edjsHTML from "editorjs-html";
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
tableHtml.push(`<tr>${row.map((cell) => `<th>${cell}</th>`)}</tr>`);
|
|
144
|
-
} else {
|
|
145
|
-
tableHtml.push(`<tr>${row.map((cell) => `<td>${cell}</td>`)}</tr>`);
|
|
146
|
-
}
|
|
147
|
-
return tableHtml;
|
|
148
|
-
});
|
|
149
|
-
if (block.data.withHeadings) {
|
|
150
|
-
const heading = rows[0];
|
|
151
|
-
const [, ...content] = rows;
|
|
152
|
-
return `<table><thead>${heading.join("")}</thead><tbody>${content.join("")}</tbody></table>`;
|
|
123
|
+
var tableParser = (block) => {
|
|
124
|
+
const rows = block.data.content.map((row, index) => {
|
|
125
|
+
const tableHtml = [];
|
|
126
|
+
if (block.data.withHeadings && index === 0) {
|
|
127
|
+
tableHtml.push(`<tr>${row.map((cell) => `<th>${cell}</th>`)}</tr>`);
|
|
153
128
|
} else {
|
|
154
|
-
|
|
129
|
+
tableHtml.push(`<tr>${row.map((cell) => `<td>${cell}</td>`)}</tr>`);
|
|
155
130
|
}
|
|
131
|
+
return tableHtml;
|
|
132
|
+
});
|
|
133
|
+
if (block.data.withHeadings) {
|
|
134
|
+
const heading = rows[0];
|
|
135
|
+
const [, ...content] = rows;
|
|
136
|
+
return `<table><thead>${heading.join("")}</thead><tbody>${content.join("")}</tbody></table>`;
|
|
137
|
+
} else {
|
|
138
|
+
return `<table><tbody>${rows.join("")}</tbody></table>`;
|
|
156
139
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
140
|
+
};
|
|
141
|
+
var audioPlayerParser = (block) => {
|
|
142
|
+
return `<audio controls src={${block.data.src}} />`;
|
|
143
|
+
};
|
|
144
|
+
var parseHtml = (jsonData) => {
|
|
160
145
|
const edjsParser = edjsHTML({
|
|
161
146
|
table: tableParser,
|
|
162
147
|
audioPlayer: audioPlayerParser
|
|
@@ -169,7 +154,22 @@ var parseHtml = (jsonData) => {
|
|
|
169
154
|
}
|
|
170
155
|
};
|
|
171
156
|
|
|
172
|
-
// src/
|
|
157
|
+
// src/utils/slugifyImport.ts
|
|
158
|
+
import slugify from "slugify";
|
|
159
|
+
var slugifyImport_default = slugify;
|
|
160
|
+
|
|
161
|
+
// src/utils/slugifyTitle.ts
|
|
162
|
+
var slugifyTitle = (title) => {
|
|
163
|
+
return slugifyImport_default(title, {
|
|
164
|
+
replacement: "-",
|
|
165
|
+
remove: /[*+~.()'"!:@]/g,
|
|
166
|
+
lower: true,
|
|
167
|
+
locale: "vi",
|
|
168
|
+
trim: true
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/components/Slug/styles.ts
|
|
173
173
|
import { styled as styled2 } from "@adminjs/design-system/styled-components";
|
|
174
174
|
import { Box, Button, Input } from "@adminjs/design-system";
|
|
175
175
|
var StyledInputWrapper = styled2(Box)`
|
|
@@ -189,8 +189,13 @@ var StyledLabel = styled2.div`
|
|
|
189
189
|
text-transform: capitalize;
|
|
190
190
|
`;
|
|
191
191
|
|
|
192
|
-
// src/components/
|
|
193
|
-
var
|
|
192
|
+
// src/components/Slug/SlugEdit.tsx
|
|
193
|
+
var SlugEdit = ({
|
|
194
|
+
property,
|
|
195
|
+
record,
|
|
196
|
+
resource,
|
|
197
|
+
onChange
|
|
198
|
+
}) => {
|
|
194
199
|
const [inputValue, setInputValue] = useState2(record.params.slug);
|
|
195
200
|
useEffect2(() => {
|
|
196
201
|
onChange(property.path, inputValue);
|
|
@@ -209,287 +214,59 @@ var CustomSlug = ({ property, record, onChange }) => {
|
|
|
209
214
|
}
|
|
210
215
|
function generateSlug(e) {
|
|
211
216
|
e.preventDefault();
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
setInputValue(slugifyTitle(
|
|
217
|
+
const slugSource = record.params[property.props.sourceField ?? resource.titleProperty.name];
|
|
218
|
+
if (slugSource) {
|
|
219
|
+
setInputValue(slugifyTitle(slugSource));
|
|
215
220
|
}
|
|
216
221
|
}
|
|
217
222
|
};
|
|
218
|
-
var
|
|
219
|
-
|
|
220
|
-
// src/components/Editor/Editor.jsx
|
|
221
|
-
import React5, { memo, useState as useState3, useEffect as useEffect3, useRef } from "react";
|
|
222
|
-
import { ThemeProvider as ThemeProvider2 } from "styled-components";
|
|
223
|
-
import EditorJS from "@editorjs/editorjs";
|
|
224
|
-
import { theme as theme2 } from "@adminjs/design-system";
|
|
225
|
-
|
|
226
|
-
// src/components/Editor/styles.ts
|
|
227
|
-
import { Box as Box2 } from "@adminjs/design-system";
|
|
228
|
-
import { styled as styled3 } from "@adminjs/design-system/styled-components";
|
|
229
|
-
var StyledLabel2 = styled3.div`
|
|
230
|
-
font-size: 12px;
|
|
231
|
-
margin-bottom: 8px;
|
|
232
|
-
text-transform: capitalize;
|
|
233
|
-
`;
|
|
234
|
-
var StyledShowLabel = styled3(StyledLabel2)`
|
|
235
|
-
color: rgb(137, 138, 154);
|
|
236
|
-
font-weight: 300;
|
|
237
|
-
`;
|
|
238
|
-
var StyledEditorWrapper = styled3(Box2)`
|
|
239
|
-
padding: 12px;
|
|
240
|
-
margin-bottom: 24px;
|
|
241
|
-
border: 1px solid rgb(187, 195, 203);
|
|
242
|
-
`;
|
|
243
|
-
var StyledEditorViewWrapper = styled3(Box2)`
|
|
244
|
-
h1,
|
|
245
|
-
h2,
|
|
246
|
-
h3 {
|
|
247
|
-
margin-bottom: 5px;
|
|
248
|
-
font-weight: bold;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
h1 {
|
|
252
|
-
font-size: 18px;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
h2 {
|
|
256
|
-
font-size: 16px;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
h3 {
|
|
260
|
-
font-size: 14px;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
p {
|
|
264
|
-
margin-bottom: 8px;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
ol,
|
|
268
|
-
ul {
|
|
269
|
-
margin-left: 20px;
|
|
270
|
-
margin-bottom: 8px;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
ol {
|
|
274
|
-
list-style: auto;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
ul {
|
|
278
|
-
list-style: inherit;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
table,
|
|
282
|
-
audio {
|
|
283
|
-
margin: 16px 0;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
table,
|
|
287
|
-
th,
|
|
288
|
-
td {
|
|
289
|
-
border: 1px solid;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
th {
|
|
293
|
-
font-weight: bold;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
th,
|
|
297
|
-
td {
|
|
298
|
-
padding: 4px;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
blockquote {
|
|
302
|
-
display: block;
|
|
303
|
-
padding: 5px 8px;
|
|
304
|
-
width: fit-content;
|
|
305
|
-
border-radius: 10px;
|
|
306
|
-
background-color: #e6e6e6;
|
|
307
|
-
}
|
|
308
|
-
`;
|
|
309
|
-
var StyledEditorShowWrapper = styled3(StyledEditorViewWrapper)`
|
|
310
|
-
margin-bottom: 24px;
|
|
311
|
-
`;
|
|
312
|
-
var StyledEditor = styled3.div`
|
|
313
|
-
audio,
|
|
314
|
-
.cdx-block,
|
|
315
|
-
.ce-header {
|
|
316
|
-
padding-left: 58px;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
input {
|
|
320
|
-
margin-left: 58px;
|
|
321
|
-
width: auto;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.cdx-list {
|
|
325
|
-
padding-left: 85px;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.ce-block__content {
|
|
329
|
-
width: 100%;
|
|
330
|
-
max-width: none;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
.ce-toolbar__content {
|
|
334
|
-
max-width: none;
|
|
335
|
-
left: 0;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.ce-toolbar__actions {
|
|
339
|
-
left: 0;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
h1.ce-header {
|
|
343
|
-
font-size: 22px;
|
|
344
|
-
font-weight: bold;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
h2.ce-header {
|
|
348
|
-
font-size: 20px;
|
|
349
|
-
font-weight: bold;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
h3.ce-header {
|
|
353
|
-
font-size: 18px;
|
|
354
|
-
font-weight: bold;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
h4.ce-header {
|
|
358
|
-
font-size: 16px;
|
|
359
|
-
font-weight: bold;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
h5.ce-header {
|
|
363
|
-
font-size: 15px;
|
|
364
|
-
font-weight: bold;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
h6.ce-header {
|
|
368
|
-
font-size: 14px;
|
|
369
|
-
font-weight: bold;
|
|
370
|
-
}
|
|
371
|
-
`;
|
|
372
|
-
|
|
373
|
-
// src/components/Editor/config.ts
|
|
374
|
-
import Header from "@editorjs/header";
|
|
375
|
-
import Paragraph from "@editorjs/paragraph";
|
|
376
|
-
import List from "@editorjs/list";
|
|
377
|
-
import Table from "@editorjs/table";
|
|
378
|
-
import Quote from "@editorjs/quote";
|
|
379
|
-
import AudioPlayer from "editorjs-audio-player";
|
|
380
|
-
var EDITOR_TOOLS = {
|
|
381
|
-
paragraph: {
|
|
382
|
-
class: Paragraph,
|
|
383
|
-
inlineToolbar: true
|
|
384
|
-
},
|
|
385
|
-
list: List,
|
|
386
|
-
header: {
|
|
387
|
-
class: Header,
|
|
388
|
-
config: {
|
|
389
|
-
placeholder: "Enter a header",
|
|
390
|
-
levels: [2, 3, 4],
|
|
391
|
-
defaultLevel: 2
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
|
-
table: Table,
|
|
395
|
-
quote: Quote,
|
|
396
|
-
audioPlayer: AudioPlayer
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
// src/components/Editor/Editor.jsx
|
|
400
|
-
var Editor = ({ property, record, onChangeAdmin, editorId }) => {
|
|
401
|
-
const [jsonData, setJsonData] = useState3();
|
|
402
|
-
const isSavedData = Boolean(record.params[property.path]);
|
|
403
|
-
const ref = useRef();
|
|
404
|
-
useEffect3(() => {
|
|
405
|
-
onChangeAdmin(property.path, jsonData);
|
|
406
|
-
}, [jsonData]);
|
|
407
|
-
useEffect3(() => {
|
|
408
|
-
if (!ref.current) {
|
|
409
|
-
const editor = new EditorJS({
|
|
410
|
-
holder: editorId,
|
|
411
|
-
tools: EDITOR_TOOLS,
|
|
412
|
-
data: isSavedData ? JSON.parse(record.params[property.path]) : "",
|
|
413
|
-
async onChange(api, event) {
|
|
414
|
-
const data = await api.saver.save();
|
|
415
|
-
setJsonData(JSON.stringify(data));
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
ref.current = editor;
|
|
419
|
-
}
|
|
420
|
-
return () => {
|
|
421
|
-
ref?.current?.destroy?.();
|
|
422
|
-
};
|
|
423
|
-
}, []);
|
|
424
|
-
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 })));
|
|
425
|
-
};
|
|
426
|
-
var Editor_default = Editor;
|
|
427
|
-
|
|
428
|
-
// src/components/Editor/EditorList.jsx
|
|
429
|
-
import { theme as theme3 } from "@adminjs/design-system";
|
|
430
|
-
import React6 from "react";
|
|
431
|
-
import { ThemeProvider as ThemeProvider3 } from "styled-components";
|
|
432
|
-
var EditorList = ({ property, record }) => {
|
|
433
|
-
const htmlContent = parseHtml(record.params[property.path]);
|
|
434
|
-
return /* @__PURE__ */ React6.createElement(ThemeProvider3, { theme: theme3 }, /* @__PURE__ */ React6.createElement(StyledEditorViewWrapper, null, htmlContent && /* @__PURE__ */ React6.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })));
|
|
435
|
-
};
|
|
436
|
-
var EditorList_default = EditorList;
|
|
437
|
-
|
|
438
|
-
// src/components/Editor/EditorShow.jsx
|
|
439
|
-
import React7 from "react";
|
|
440
|
-
import { ThemeProvider as ThemeProvider4 } from "styled-components";
|
|
441
|
-
import { theme as theme4 } from "@adminjs/design-system";
|
|
442
|
-
var EditorShow = ({ property, record }) => {
|
|
443
|
-
const htmlContent = parseHtml(record.params[property.path]);
|
|
444
|
-
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 } })));
|
|
445
|
-
};
|
|
446
|
-
var EditorShow_default = EditorShow;
|
|
223
|
+
var SlugEdit_default = SlugEdit;
|
|
447
224
|
|
|
448
225
|
// src/components/StringList/StringList.tsx
|
|
449
|
-
import { Button as Button3, Input as Input3, theme as
|
|
450
|
-
import
|
|
451
|
-
useEffect as
|
|
452
|
-
useState as
|
|
226
|
+
import { Button as Button3, Input as Input3, theme as theme2 } from "@adminjs/design-system";
|
|
227
|
+
import React8, {
|
|
228
|
+
useEffect as useEffect3,
|
|
229
|
+
useState as useState4
|
|
453
230
|
} from "react";
|
|
454
|
-
import { ThemeProvider as
|
|
231
|
+
import { ThemeProvider as ThemeProvider2 } from "styled-components";
|
|
455
232
|
|
|
456
233
|
// src/components/StringList/styles.ts
|
|
457
|
-
import { Box as
|
|
458
|
-
import { styled as
|
|
459
|
-
var StyledWrapper =
|
|
234
|
+
import { Box as Box2, Input as Input2 } from "@adminjs/design-system";
|
|
235
|
+
import { styled as styled3 } from "@adminjs/design-system/styled-components";
|
|
236
|
+
var StyledWrapper = styled3(Box2)`
|
|
460
237
|
display: flex;
|
|
461
238
|
flex-direction: column;
|
|
462
239
|
margin-bottom: 45px;
|
|
463
240
|
`;
|
|
464
|
-
var StyledCustomInput2 =
|
|
241
|
+
var StyledCustomInput2 = styled3(Input2)`
|
|
465
242
|
width: 100%;
|
|
466
243
|
margin-right: 10px;
|
|
467
244
|
`;
|
|
468
|
-
var StyledInputWrapper2 =
|
|
245
|
+
var StyledInputWrapper2 = styled3(Box2)`
|
|
469
246
|
display: flex;
|
|
470
247
|
`;
|
|
471
|
-
var StyledListWrapper =
|
|
248
|
+
var StyledListWrapper = styled3(Box2)`
|
|
472
249
|
margin-bottom: 15px;
|
|
473
250
|
`;
|
|
474
|
-
var
|
|
251
|
+
var StyledLabel2 = styled3.div`
|
|
475
252
|
font-size: 12px;
|
|
476
253
|
margin-bottom: 8px;
|
|
477
254
|
text-transform: capitalize;
|
|
478
255
|
`;
|
|
479
|
-
var
|
|
256
|
+
var StyledShowLabel = styled3(StyledLabel2)`
|
|
480
257
|
line-height: 16px;
|
|
481
258
|
color: rgb(137, 138, 154);
|
|
482
259
|
font-weight: 300;
|
|
483
260
|
`;
|
|
484
|
-
var StyledShowWrapper =
|
|
261
|
+
var StyledShowWrapper = styled3(Box2)`
|
|
485
262
|
margin-bottom: 35px;
|
|
486
263
|
`;
|
|
487
|
-
var StyledListItem =
|
|
264
|
+
var StyledListItem = styled3.li`
|
|
488
265
|
margin-bottom: 5px;
|
|
489
266
|
`;
|
|
490
267
|
|
|
491
268
|
// src/components/StringList/SortableList/SortableList.tsx
|
|
492
|
-
import
|
|
269
|
+
import React7, { Fragment, useMemo as useMemo2, useState as useState3 } from "react";
|
|
493
270
|
import {
|
|
494
271
|
DndContext,
|
|
495
272
|
KeyboardSensor,
|
|
@@ -507,16 +284,16 @@ import {
|
|
|
507
284
|
} from "@dnd-kit/sortable";
|
|
508
285
|
|
|
509
286
|
// src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx
|
|
510
|
-
import
|
|
287
|
+
import React6, { createContext, useMemo } from "react";
|
|
511
288
|
import { useSortable } from "@dnd-kit/sortable";
|
|
512
289
|
import { Button as Button2, Icon } from "@adminjs/design-system";
|
|
513
290
|
|
|
514
291
|
// src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx
|
|
515
|
-
import
|
|
292
|
+
import React5, { useContext } from "react";
|
|
516
293
|
|
|
517
294
|
// src/components/StringList/SortableList/components/SortableItem/styles.ts
|
|
518
|
-
import { styled as
|
|
519
|
-
var StyledListItem2 =
|
|
295
|
+
import { styled as styled4 } from "@adminjs/design-system/styled-components";
|
|
296
|
+
var StyledListItem2 = styled4.li`
|
|
520
297
|
display: flex;
|
|
521
298
|
justify-content: space-between;
|
|
522
299
|
align-items: center;
|
|
@@ -528,7 +305,7 @@ var StyledListItem2 = styled5.li`
|
|
|
528
305
|
border-radius: 5px;
|
|
529
306
|
list-style: none;
|
|
530
307
|
`;
|
|
531
|
-
var StyledDragButton =
|
|
308
|
+
var StyledDragButton = styled4.button`
|
|
532
309
|
padding: 3px;
|
|
533
310
|
margin-right: 15px;
|
|
534
311
|
cursor: move;
|
|
@@ -539,7 +316,7 @@ var StyledDragButton = styled5.button`
|
|
|
539
316
|
// src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx
|
|
540
317
|
var DragHandle = ({ context }) => {
|
|
541
318
|
const { attributes, listeners, ref } = useContext(context);
|
|
542
|
-
return /* @__PURE__ */
|
|
319
|
+
return /* @__PURE__ */ React5.createElement(StyledDragButton, { ...attributes, ...listeners, ref }, /* @__PURE__ */ React5.createElement("svg", { viewBox: "0 0 20 20", width: "13" }, /* @__PURE__ */ React5.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" })));
|
|
543
320
|
};
|
|
544
321
|
|
|
545
322
|
// src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx
|
|
@@ -566,7 +343,7 @@ function SortableItem({
|
|
|
566
343
|
const style = {
|
|
567
344
|
opacity: isDragging ? 0.4 : void 0
|
|
568
345
|
};
|
|
569
|
-
return /* @__PURE__ */
|
|
346
|
+
return /* @__PURE__ */ React6.createElement(SortableItemContext.Provider, { value: context }, /* @__PURE__ */ React6.createElement(StyledListItem2, { ref: setNodeRef, style }, /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement(DragHandle, { context: SortableItemContext }), children), /* @__PURE__ */ React6.createElement(
|
|
570
347
|
Button2,
|
|
571
348
|
{
|
|
572
349
|
variant: "outlined",
|
|
@@ -574,13 +351,13 @@ function SortableItem({
|
|
|
574
351
|
size: "icon",
|
|
575
352
|
onClick: (e) => onDelete(e, id)
|
|
576
353
|
},
|
|
577
|
-
/* @__PURE__ */
|
|
354
|
+
/* @__PURE__ */ React6.createElement(Icon, { icon: "X", color: "red" })
|
|
578
355
|
)));
|
|
579
356
|
}
|
|
580
357
|
|
|
581
358
|
// src/components/StringList/SortableList/styles.ts
|
|
582
|
-
import { styled as
|
|
583
|
-
var StyledListWrapper2 =
|
|
359
|
+
import { styled as styled5 } from "@adminjs/design-system/styled-components";
|
|
360
|
+
var StyledListWrapper2 = styled5.ul`
|
|
584
361
|
display: flex;
|
|
585
362
|
flex-direction: column;
|
|
586
363
|
gap: 12px;
|
|
@@ -603,7 +380,7 @@ function SortableList({
|
|
|
603
380
|
onChange,
|
|
604
381
|
renderItem
|
|
605
382
|
}) {
|
|
606
|
-
const [active, setActive] =
|
|
383
|
+
const [active, setActive] = useState3(null);
|
|
607
384
|
const activeItem = useMemo2(
|
|
608
385
|
() => items.find((item) => item.id === active?.id),
|
|
609
386
|
[active, items]
|
|
@@ -614,7 +391,7 @@ function SortableList({
|
|
|
614
391
|
coordinateGetter: sortableKeyboardCoordinates
|
|
615
392
|
})
|
|
616
393
|
);
|
|
617
|
-
return /* @__PURE__ */
|
|
394
|
+
return /* @__PURE__ */ React7.createElement(
|
|
618
395
|
DndContext,
|
|
619
396
|
{
|
|
620
397
|
sensors,
|
|
@@ -633,8 +410,8 @@ function SortableList({
|
|
|
633
410
|
setActive(null);
|
|
634
411
|
}
|
|
635
412
|
},
|
|
636
|
-
/* @__PURE__ */
|
|
637
|
-
/* @__PURE__ */
|
|
413
|
+
/* @__PURE__ */ React7.createElement(SortableContext, { items, strategy: verticalListSortingStrategy }, /* @__PURE__ */ React7.createElement(StyledListWrapper2, { role: "application" }, items.map((item, index) => /* @__PURE__ */ React7.createElement(Fragment, { key: index }, renderItem(item))))),
|
|
414
|
+
/* @__PURE__ */ React7.createElement(DragOverlay, { dropAnimation: dropAnimationConfig }, activeItem ? renderItem(activeItem) : null)
|
|
638
415
|
);
|
|
639
416
|
}
|
|
640
417
|
SortableList.Item = SortableItem;
|
|
@@ -651,20 +428,20 @@ var StringList = ({
|
|
|
651
428
|
}) => {
|
|
652
429
|
const stringListValue = record.params?.[property.path] ?? property.props.value ?? "";
|
|
653
430
|
const initialList = stringListValue ? prepareDataForList(stringListValue) : [];
|
|
654
|
-
const [inputValue, setInputValue] =
|
|
655
|
-
const [list, setList] =
|
|
431
|
+
const [inputValue, setInputValue] = useState4("");
|
|
432
|
+
const [list, setList] = useState4(initialList);
|
|
656
433
|
const serializedData = prepareDataForDatabase(list);
|
|
657
|
-
|
|
434
|
+
useEffect3(() => {
|
|
658
435
|
onChange(property.path, serializedData);
|
|
659
436
|
}, [serializedData]);
|
|
660
|
-
return /* @__PURE__ */
|
|
437
|
+
return /* @__PURE__ */ React8.createElement(ThemeProvider2, { theme: theme2 }, /* @__PURE__ */ React8.createElement(StyledLabel2, { htmlFor: "custom" }, property.path), /* @__PURE__ */ React8.createElement(StyledWrapper, null, /* @__PURE__ */ React8.createElement(StyledListWrapper, null, /* @__PURE__ */ React8.createElement(
|
|
661
438
|
SortableList,
|
|
662
439
|
{
|
|
663
440
|
items: list,
|
|
664
441
|
onChange: setList,
|
|
665
|
-
renderItem: (item) => /* @__PURE__ */
|
|
442
|
+
renderItem: (item) => /* @__PURE__ */ React8.createElement(SortableList.Item, { id: item.id, onDelete: handleDeleteButton }, item.value)
|
|
666
443
|
}
|
|
667
|
-
)), /* @__PURE__ */
|
|
444
|
+
)), /* @__PURE__ */ React8.createElement(StyledInputWrapper2, null, /* @__PURE__ */ React8.createElement(
|
|
668
445
|
Input3,
|
|
669
446
|
{
|
|
670
447
|
id: "stringList",
|
|
@@ -672,7 +449,7 @@ var StringList = ({
|
|
|
672
449
|
value: serializedData,
|
|
673
450
|
hidden: true
|
|
674
451
|
}
|
|
675
|
-
), /* @__PURE__ */
|
|
452
|
+
), /* @__PURE__ */ React8.createElement(
|
|
676
453
|
StyledCustomInput2,
|
|
677
454
|
{
|
|
678
455
|
id: "custom",
|
|
@@ -681,7 +458,7 @@ var StringList = ({
|
|
|
681
458
|
onChange: handleInput,
|
|
682
459
|
onKeyPress: handleEnterPress
|
|
683
460
|
}
|
|
684
|
-
), /* @__PURE__ */
|
|
461
|
+
), /* @__PURE__ */ React8.createElement(Button3, { variant: "outlined", onClick: handleAddButton }, "Add"))));
|
|
685
462
|
function handleInput(e) {
|
|
686
463
|
setInputValue(e.target.value);
|
|
687
464
|
}
|
|
@@ -718,26 +495,59 @@ var StringList = ({
|
|
|
718
495
|
var StringList_default = StringList;
|
|
719
496
|
|
|
720
497
|
// src/components/StringList/StringListShow.tsx
|
|
721
|
-
import
|
|
722
|
-
import { ThemeProvider as
|
|
723
|
-
import { theme as
|
|
498
|
+
import React9 from "react";
|
|
499
|
+
import { ThemeProvider as ThemeProvider3 } from "styled-components";
|
|
500
|
+
import { theme as theme3 } from "@adminjs/design-system";
|
|
724
501
|
var StringListShow = ({
|
|
725
502
|
property,
|
|
726
503
|
record,
|
|
727
504
|
stringListSeparator = separator
|
|
728
505
|
}) => {
|
|
729
|
-
return /* @__PURE__ */
|
|
506
|
+
return /* @__PURE__ */ React9.createElement(ThemeProvider3, { theme: theme3 }, /* @__PURE__ */ React9.createElement(StyledShowWrapper, null, /* @__PURE__ */ React9.createElement(StyledShowLabel, null, property.path), record.params.facts && /* @__PURE__ */ React9.createElement("ul", null, record.params.facts.split(stringListSeparator).map((item, index) => /* @__PURE__ */ React9.createElement(StyledListItem, { key: index }, `- ${item}`)))));
|
|
730
507
|
};
|
|
731
508
|
var StringListShow_default = StringListShow;
|
|
509
|
+
|
|
510
|
+
// src/components/Slug/SlugFeature.ts
|
|
511
|
+
import { buildFeature } from "adminjs";
|
|
512
|
+
|
|
513
|
+
// src/utils/bundle-component.ts
|
|
514
|
+
import path from "path";
|
|
515
|
+
import * as url from "url";
|
|
516
|
+
var dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
517
|
+
var bundleComponent = (loader, componentName, componentFile) => {
|
|
518
|
+
const componentPath = path.join(dirname, "../src/components", componentName, componentFile);
|
|
519
|
+
console.log("[bundleComponent] Registering:", componentPath);
|
|
520
|
+
return loader.add(componentName, componentPath);
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
// src/components/Slug/SlugFeature.ts
|
|
524
|
+
var COMPONENT_NAME = "Slug";
|
|
525
|
+
var SlugFeature = (config) => {
|
|
526
|
+
const { componentLoader, key } = config;
|
|
527
|
+
const uploadFeature = () => {
|
|
528
|
+
const editComponent = bundleComponent(componentLoader, COMPONENT_NAME, "SlugEdit.tsx");
|
|
529
|
+
return buildFeature({
|
|
530
|
+
properties: {
|
|
531
|
+
[key]: {
|
|
532
|
+
isVisible: { show: false, edit: true, list: false, filter: false },
|
|
533
|
+
components: {
|
|
534
|
+
edit: editComponent
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
};
|
|
540
|
+
return uploadFeature();
|
|
541
|
+
};
|
|
542
|
+
var SlugFeature_default = SlugFeature;
|
|
732
543
|
export {
|
|
733
544
|
ColorStatusEdit_default as ColorStatusEdit,
|
|
734
545
|
ColorStatusList_default as ColorStatusList,
|
|
735
546
|
ColorStatusShow_default as ColorStatusShow,
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
EditorList_default as EditorList,
|
|
739
|
-
EditorShow_default as EditorShow,
|
|
547
|
+
SlugEdit_default as SlugEdit,
|
|
548
|
+
SlugFeature_default as SlugFeature,
|
|
740
549
|
StringList_default as StringList,
|
|
741
550
|
StringListShow_default as StringListShow,
|
|
742
551
|
parseHtml
|
|
743
552
|
};
|
|
553
|
+
//# sourceMappingURL=index.js.map
|