@rulab/adminjs-components 0.0.13 → 0.1.0-alpha.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/LICENSE +21 -21
- package/dist/components/ColorStatus/ColorStatusEdit.d.ts +5 -0
- package/dist/components/ColorStatus/ColorStatusEdit.js +58 -0
- package/dist/components/ColorStatus/ColorStatusList.d.ts +4 -0
- package/dist/components/ColorStatus/ColorStatusList.js +7 -0
- package/dist/components/ColorStatus/ColorStatusShow.d.ts +4 -0
- package/dist/components/ColorStatus/ColorStatusShow.js +9 -0
- package/dist/components/ColorStatus/index.d.ts +3 -0
- package/dist/components/ColorStatus/index.js +3 -0
- package/dist/components/ColorStatus/styles.d.ts +5 -0
- package/dist/components/ColorStatus/styles.js +25 -0
- package/dist/components/ColorStatus/types.d.ts +5 -0
- package/dist/components/ColorStatus/types.js +1 -0
- package/dist/components/Editor/Editor.d.ts +11 -0
- package/dist/components/Editor/Editor.js +33 -0
- package/dist/components/Editor/EditorList.d.ts +9 -0
- package/dist/components/Editor/EditorList.js +10 -0
- package/dist/components/Editor/EditorShow.d.ts +9 -0
- package/dist/components/Editor/EditorShow.js +10 -0
- package/dist/components/Editor/config.d.ts +29 -0
- package/dist/components/Editor/config.js +26 -3
- package/dist/components/Editor/index.d.ts +3 -0
- package/dist/components/Editor/index.js +3 -1
- package/dist/components/Editor/styles.d.ts +6 -0
- package/dist/components/Editor/styles.js +140 -59
- package/dist/components/Slug/SlugEdit.d.ts +5 -0
- package/dist/components/Slug/SlugEdit.js +27 -0
- package/dist/components/Slug/SlugFeature.d.ts +7 -0
- package/dist/components/Slug/SlugFeature.js +21 -0
- package/dist/components/Slug/index.d.ts +1 -0
- package/dist/components/Slug/index.js +1 -0
- package/dist/components/Slug/styles.d.ts +4 -0
- package/dist/components/{CustomSlug → Slug}/styles.js +14 -9
- package/dist/components/StringList/SortableList/SortableList.d.ts +18 -0
- package/dist/components/StringList/SortableList/{SortableList.jsx → SortableList.js} +13 -19
- package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +7 -0
- package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.js +8 -0
- package/dist/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +8 -0
- package/dist/components/StringList/SortableList/components/SortableItem/{SortableItem.jsx → SortableItem.js} +7 -11
- package/dist/components/StringList/SortableList/components/SortableItem/styles.d.ts +2 -0
- package/dist/components/StringList/SortableList/components/SortableItem/styles.js +18 -18
- package/dist/components/StringList/SortableList/components/SortableItem/types.d.ts +6 -0
- package/dist/components/StringList/SortableList/components/index.d.ts +2 -0
- package/dist/components/StringList/SortableList/index.d.ts +1 -0
- package/dist/components/StringList/SortableList/styles.d.ts +1 -0
- package/dist/components/StringList/SortableList/styles.js +6 -6
- package/dist/components/StringList/StringList.d.ts +8 -0
- package/dist/components/StringList/StringList.js +60 -0
- package/dist/components/StringList/StringListShow.d.ts +7 -0
- package/dist/components/StringList/StringListShow.js +14 -0
- package/dist/components/StringList/constants.d.ts +1 -0
- package/dist/components/StringList/constants.js +1 -0
- package/dist/components/StringList/index.d.ts +2 -0
- package/dist/components/StringList/index.js +2 -1
- package/dist/components/StringList/styles.d.ts +8 -0
- package/dist/components/StringList/styles.js +28 -11
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +9 -2
- package/dist/index.d.ts +2 -44
- package/dist/index.js +2 -757
- package/dist/scripts/fix-import-extensions.d.ts +1 -0
- package/dist/scripts/fix-import-extensions.js +39 -0
- package/dist/utils/bundle-component.d.ts +2 -0
- package/dist/utils/bundle-component.js +8 -0
- package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/parseHtml.d.ts +1 -0
- package/dist/utils/parseHtml.js +37 -0
- package/dist/utils/slugifyImport.d.ts +3 -0
- package/dist/utils/slugifyImport.js +1 -1
- package/dist/utils/slugifyTitle.d.ts +1 -0
- package/dist/utils/slugifyTitle.js +3 -3
- package/package.json +14 -8
- package/src/components/ColorStatus/ColorStatusEdit.d.ts +5 -0
- package/src/components/ColorStatus/ColorStatusEdit.js +58 -0
- package/src/components/ColorStatus/ColorStatusEdit.tsx +94 -94
- package/src/components/ColorStatus/ColorStatusList.d.ts +4 -0
- package/src/components/ColorStatus/ColorStatusList.js +7 -0
- package/src/components/ColorStatus/ColorStatusList.tsx +20 -20
- package/src/components/ColorStatus/ColorStatusShow.d.ts +4 -0
- package/src/components/ColorStatus/ColorStatusShow.js +9 -0
- package/src/components/ColorStatus/ColorStatusShow.tsx +23 -23
- package/src/components/ColorStatus/index.d.ts +3 -0
- package/src/components/ColorStatus/index.js +3 -0
- package/src/components/ColorStatus/index.ts +3 -3
- package/src/components/ColorStatus/styles.d.ts +5 -0
- package/src/components/ColorStatus/styles.js +25 -0
- package/src/components/ColorStatus/styles.ts +30 -30
- package/src/components/ColorStatus/types.d.ts +5 -0
- package/src/components/ColorStatus/types.js +1 -0
- package/src/components/ColorStatus/types.ts +5 -5
- package/src/components/Editor/Editor.d.ts +8 -0
- package/src/components/Editor/Editor.js +36 -0
- package/src/components/Editor/Editor.jsx +49 -49
- package/src/components/Editor/EditorList.d.ts +6 -0
- package/src/components/Editor/EditorList.js +11 -0
- package/src/components/Editor/EditorList.jsx +22 -22
- package/src/components/Editor/EditorShow.d.ts +6 -0
- package/src/components/Editor/EditorShow.js +13 -0
- package/src/components/Editor/EditorShow.jsx +24 -24
- package/src/components/Editor/config.d.ts +29 -0
- package/src/components/Editor/config.js +34 -0
- package/src/components/Editor/config.ts +35 -35
- package/src/components/Editor/index.d.ts +3 -0
- package/src/components/Editor/index.js +3 -0
- package/src/components/Editor/index.ts +3 -3
- package/src/components/Editor/styles.d.ts +6 -0
- package/src/components/Editor/styles.js +145 -0
- package/src/components/Editor/styles.ts +151 -151
- package/src/components/Slug/SlugEdit.d.ts +5 -0
- package/src/components/Slug/SlugEdit.js +27 -0
- package/src/components/{CustomSlug/CustomSlug.tsx → Slug/SlugEdit.tsx} +68 -68
- package/src/components/Slug/SlugFeature.d.ts +7 -0
- package/src/components/Slug/SlugFeature.js +21 -0
- package/src/components/Slug/SlugFeature.ts +30 -0
- package/src/components/Slug/index.d.ts +1 -0
- package/src/components/Slug/index.js +1 -0
- package/src/components/Slug/index.ts +1 -0
- package/src/components/Slug/styles.d.ts +4 -0
- package/src/components/Slug/styles.js +20 -0
- package/src/components/{CustomSlug → Slug}/styles.ts +24 -24
- package/src/components/StringList/SortableList/SortableList.d.ts +18 -0
- package/src/components/StringList/SortableList/SortableList.js +37 -0
- package/src/components/StringList/SortableList/SortableList.tsx +98 -98
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +7 -0
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.js +8 -0
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx +20 -20
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +8 -0
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.js +28 -0
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx +59 -59
- package/src/components/StringList/SortableList/components/SortableItem/styles.d.ts +2 -0
- package/src/components/StringList/SortableList/components/SortableItem/styles.js +20 -0
- package/src/components/StringList/SortableList/components/SortableItem/styles.ts +22 -22
- package/src/components/StringList/SortableList/components/SortableItem/types.d.ts +6 -0
- package/src/components/StringList/SortableList/components/SortableItem/types.js +1 -0
- package/src/components/StringList/SortableList/components/SortableItem/types.ts +7 -7
- package/src/components/StringList/SortableList/components/index.d.ts +2 -0
- package/src/components/StringList/SortableList/components/index.js +2 -0
- package/src/components/StringList/SortableList/components/index.ts +2 -2
- package/src/components/StringList/SortableList/index.d.ts +1 -0
- package/src/components/StringList/SortableList/index.js +1 -0
- package/src/components/StringList/SortableList/index.ts +1 -1
- package/src/components/StringList/SortableList/styles.d.ts +1 -0
- package/src/components/StringList/SortableList/styles.js +8 -0
- package/src/components/StringList/SortableList/styles.ts +9 -9
- package/src/components/StringList/StringList.d.ts +8 -0
- package/src/components/StringList/StringList.js +60 -0
- package/src/components/StringList/StringList.tsx +136 -136
- package/src/components/StringList/StringListShow.d.ts +7 -0
- package/src/components/StringList/StringListShow.js +14 -0
- package/src/components/StringList/StringListShow.tsx +37 -37
- package/src/components/StringList/constants.d.ts +1 -0
- package/src/components/StringList/constants.js +1 -0
- package/src/components/StringList/constants.ts +1 -1
- package/src/components/StringList/index.d.ts +2 -0
- package/src/components/StringList/index.js +2 -0
- package/src/components/StringList/index.ts +2 -2
- package/src/components/StringList/styles.d.ts +8 -0
- package/src/components/StringList/styles.js +33 -0
- package/src/components/StringList/styles.ts +41 -41
- package/src/components/index.d.ts +7 -0
- package/src/components/index.js +10 -0
- 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/StringList/SortableList/components/SortableItem/DragHandle.jsx +0 -10
- package/dist/components/StringList/StringList.jsx +0 -67
- package/dist/editorFeature.js +0 -16
- package/dist/index.cjs +0 -784
- package/dist/index.d.cts +0 -44
- package/dist/index.d.mts +0 -8
- package/dist/index.mjs +0 -37
- package/src/components/CustomSlug/index.ts +0 -1
- package/src/index.ts +0 -2
- package/src/types.d.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.cjs
DELETED
|
@@ -1,784 +0,0 @@
|
|
|
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/index.ts
|
|
31
|
-
var src_exports = {};
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
ColorStatusEdit: () => ColorStatusEdit_default,
|
|
34
|
-
ColorStatusList: () => ColorStatusList_default,
|
|
35
|
-
ColorStatusShow: () => ColorStatusShow_default,
|
|
36
|
-
CustomSlug: () => CustomSlug_default,
|
|
37
|
-
Editor: () => Editor_default,
|
|
38
|
-
EditorList: () => EditorList_default,
|
|
39
|
-
EditorShow: () => EditorShow_default,
|
|
40
|
-
StringList: () => StringList_default,
|
|
41
|
-
StringListShow: () => StringListShow_default,
|
|
42
|
-
parseHtml: () => parseHtml
|
|
43
|
-
});
|
|
44
|
-
module.exports = __toCommonJS(src_exports);
|
|
45
|
-
|
|
46
|
-
// src/components/ColorStatus/ColorStatusEdit.tsx
|
|
47
|
-
var import_react = __toESM(require("react"), 1);
|
|
48
|
-
var import_react_select = __toESM(require("react-select"), 1);
|
|
49
|
-
var import_chroma_js = __toESM(require("chroma-js"), 1);
|
|
50
|
-
|
|
51
|
-
// src/components/ColorStatus/styles.ts
|
|
52
|
-
var import_styled_components = require("@adminjs/design-system/styled-components");
|
|
53
|
-
var ColorStatusWrapper = import_styled_components.styled.div`
|
|
54
|
-
margin-bottom: 24px;
|
|
55
|
-
`;
|
|
56
|
-
var Label = import_styled_components.styled.div`
|
|
57
|
-
font-size: 12px;
|
|
58
|
-
margin-bottom: 8px;
|
|
59
|
-
`;
|
|
60
|
-
var ShowLabel = import_styled_components.styled.div`
|
|
61
|
-
font-size: 12px;
|
|
62
|
-
margin-bottom: 8px;
|
|
63
|
-
color: rgb(137, 138, 154);
|
|
64
|
-
`;
|
|
65
|
-
var ColorStatusBadgeWrapper = import_styled_components.styled.div`
|
|
66
|
-
margin-bottom: 20px;
|
|
67
|
-
`;
|
|
68
|
-
var ColorStatusBadge = import_styled_components.styled.div`
|
|
69
|
-
background-color: ${(props) => props.color};
|
|
70
|
-
width: fit-content;
|
|
71
|
-
padding: 5px 10px;
|
|
72
|
-
border-radius: 20px;
|
|
73
|
-
font-size: 12px;
|
|
74
|
-
color: white;
|
|
75
|
-
white-space: nowrap;
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
// src/components/ColorStatus/ColorStatusEdit.tsx
|
|
79
|
-
var dot = (color = "transparent") => ({
|
|
80
|
-
alignItems: "center",
|
|
81
|
-
display: "flex",
|
|
82
|
-
":before": {
|
|
83
|
-
backgroundColor: color,
|
|
84
|
-
borderRadius: 10,
|
|
85
|
-
content: '" "',
|
|
86
|
-
display: "block",
|
|
87
|
-
marginRight: 8,
|
|
88
|
-
height: 10,
|
|
89
|
-
width: 10
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
var colorStyles = {
|
|
93
|
-
control: (styles) => ({ ...styles, backgroundColor: "white" }),
|
|
94
|
-
option: (styles, { data, isDisabled, isFocused, isSelected }) => {
|
|
95
|
-
const color = (0, import_chroma_js.default)(data.color);
|
|
96
|
-
return {
|
|
97
|
-
...styles,
|
|
98
|
-
backgroundColor: isSelected ? data.color : isFocused ? color.alpha(0.1).css() : void 0,
|
|
99
|
-
color: isSelected ? import_chroma_js.default.contrast(color, "white") > 2 ? "white" : "black" : data.color,
|
|
100
|
-
":active": {
|
|
101
|
-
...styles[":active"],
|
|
102
|
-
backgroundColor: isSelected ? data.color : color.alpha(0.3).css()
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
input: (styles) => ({ ...styles, ...dot() }),
|
|
107
|
-
placeholder: (styles) => ({ ...styles, ...dot("#ccc") }),
|
|
108
|
-
singleValue: (styles, { data }) => ({ ...styles, ...dot(data.color) })
|
|
109
|
-
};
|
|
110
|
-
var ColorStatus = ({ property, record, onChange }) => {
|
|
111
|
-
const availableValues = property.availableValues;
|
|
112
|
-
const currentOption = availableValues.find(
|
|
113
|
-
(item) => item.value === record.params[property.path]
|
|
114
|
-
);
|
|
115
|
-
const [selectOption, setCurrentOption] = (0, import_react.useState)(currentOption);
|
|
116
|
-
const handleSelectChange = (option) => {
|
|
117
|
-
setCurrentOption(option);
|
|
118
|
-
};
|
|
119
|
-
(0, import_react.useEffect)(() => {
|
|
120
|
-
onChange(property.path, selectOption?.value);
|
|
121
|
-
}, [selectOption]);
|
|
122
|
-
return /* @__PURE__ */ import_react.default.createElement(ColorStatusWrapper, null, /* @__PURE__ */ import_react.default.createElement(Label, null, property.path), /* @__PURE__ */ import_react.default.createElement(
|
|
123
|
-
import_react_select.default,
|
|
124
|
-
{
|
|
125
|
-
className: "basic-single",
|
|
126
|
-
classNamePrefix: "select",
|
|
127
|
-
defaultValue: selectOption ?? availableValues[0],
|
|
128
|
-
onChange: handleSelectChange,
|
|
129
|
-
isClearable: true,
|
|
130
|
-
name: "color",
|
|
131
|
-
options: availableValues,
|
|
132
|
-
styles: colorStyles
|
|
133
|
-
}
|
|
134
|
-
));
|
|
135
|
-
};
|
|
136
|
-
var ColorStatusEdit_default = ColorStatus;
|
|
137
|
-
|
|
138
|
-
// src/components/ColorStatus/ColorStatusShow.tsx
|
|
139
|
-
var import_react2 = __toESM(require("react"), 1);
|
|
140
|
-
var ColorStatusShow = ({ property, record }) => {
|
|
141
|
-
const currentOption = property.availableValues?.find(
|
|
142
|
-
(item) => item.value === record.params[property.path]
|
|
143
|
-
);
|
|
144
|
-
return /* @__PURE__ */ import_react2.default.createElement(ColorStatusBadgeWrapper, null, /* @__PURE__ */ import_react2.default.createElement(ShowLabel, null, property.path), /* @__PURE__ */ import_react2.default.createElement(ColorStatusBadge, { color: currentOption.color }, record.params[property.path]));
|
|
145
|
-
};
|
|
146
|
-
var ColorStatusShow_default = ColorStatusShow;
|
|
147
|
-
|
|
148
|
-
// src/components/ColorStatus/ColorStatusList.tsx
|
|
149
|
-
var import_react3 = __toESM(require("react"), 1);
|
|
150
|
-
var ColorStatusList = ({ property, record }) => {
|
|
151
|
-
const currentOption = property.availableValues?.find(
|
|
152
|
-
(item) => item.value === record.params[property.path]
|
|
153
|
-
);
|
|
154
|
-
return /* @__PURE__ */ import_react3.default.createElement(ColorStatusBadge, { color: currentOption.color }, record.params[property.path]);
|
|
155
|
-
};
|
|
156
|
-
var ColorStatusList_default = ColorStatusList;
|
|
157
|
-
|
|
158
|
-
// src/components/CustomSlug/CustomSlug.tsx
|
|
159
|
-
var import_react4 = __toESM(require("react"), 1);
|
|
160
|
-
var import_styled_components3 = require("styled-components");
|
|
161
|
-
var import_design_system2 = require("@adminjs/design-system");
|
|
162
|
-
|
|
163
|
-
// src/utils/parseHtml.ts
|
|
164
|
-
var import_editorjs_html = __toESM(require("editorjs-html"), 1);
|
|
165
|
-
var tableParser = (block) => {
|
|
166
|
-
const rows = block.data.content.map((row, index) => {
|
|
167
|
-
const tableHtml = [];
|
|
168
|
-
if (block.data.withHeadings && index === 0) {
|
|
169
|
-
tableHtml.push(`<tr>${row.map((cell) => `<th>${cell}</th>`)}</tr>`);
|
|
170
|
-
} else {
|
|
171
|
-
tableHtml.push(`<tr>${row.map((cell) => `<td>${cell}</td>`)}</tr>`);
|
|
172
|
-
}
|
|
173
|
-
return tableHtml;
|
|
174
|
-
});
|
|
175
|
-
if (block.data.withHeadings) {
|
|
176
|
-
const heading = rows[0];
|
|
177
|
-
const [, ...content] = rows;
|
|
178
|
-
return `<table><thead>${heading.join("")}</thead><tbody>${content.join("")}</tbody></table>`;
|
|
179
|
-
} else {
|
|
180
|
-
return `<table><tbody>${rows.join("")}</tbody></table>`;
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
var audioPlayerParser = (block) => {
|
|
184
|
-
return `<audio controls src={${block.data.src}} />`;
|
|
185
|
-
};
|
|
186
|
-
var parseHtml = (jsonData) => {
|
|
187
|
-
const edjsParser = (0, import_editorjs_html.default)({
|
|
188
|
-
table: tableParser,
|
|
189
|
-
audioPlayer: audioPlayerParser
|
|
190
|
-
});
|
|
191
|
-
try {
|
|
192
|
-
const data = edjsParser.parse(JSON.parse(jsonData));
|
|
193
|
-
return String(data).replace(/>,</g, "><");
|
|
194
|
-
} catch (e) {
|
|
195
|
-
console.log("error", e);
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// src/utils/slugifyImport.ts
|
|
200
|
-
var import_slugify = __toESM(require("slugify"), 1);
|
|
201
|
-
var slugifyImport_default = import_slugify.default;
|
|
202
|
-
|
|
203
|
-
// src/utils/slugifyTitle.ts
|
|
204
|
-
var slugifyTitle = (title) => {
|
|
205
|
-
return slugifyImport_default(title, {
|
|
206
|
-
replacement: "-",
|
|
207
|
-
remove: /[*+~.()'"!:@]/g,
|
|
208
|
-
lower: true,
|
|
209
|
-
locale: "vi",
|
|
210
|
-
trim: true
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
// src/components/CustomSlug/styles.ts
|
|
215
|
-
var import_styled_components2 = require("@adminjs/design-system/styled-components");
|
|
216
|
-
var import_design_system = require("@adminjs/design-system");
|
|
217
|
-
var StyledInputWrapper = (0, import_styled_components2.styled)(import_design_system.Box)`
|
|
218
|
-
display: flex;
|
|
219
|
-
margin-bottom: 40px;
|
|
220
|
-
`;
|
|
221
|
-
var StyledCustomInput = (0, import_styled_components2.styled)(import_design_system.Input)`
|
|
222
|
-
width: 100%;
|
|
223
|
-
margin-right: 10px;
|
|
224
|
-
`;
|
|
225
|
-
var StyledGenerateButton = (0, import_styled_components2.styled)(import_design_system.Button)`
|
|
226
|
-
white-space: nowrap;
|
|
227
|
-
`;
|
|
228
|
-
var StyledLabel = import_styled_components2.styled.div`
|
|
229
|
-
font-size: 12px;
|
|
230
|
-
margin-bottom: 8px;
|
|
231
|
-
text-transform: capitalize;
|
|
232
|
-
`;
|
|
233
|
-
|
|
234
|
-
// src/components/CustomSlug/CustomSlug.tsx
|
|
235
|
-
var CustomSlug = ({
|
|
236
|
-
property,
|
|
237
|
-
record,
|
|
238
|
-
resource,
|
|
239
|
-
onChange
|
|
240
|
-
}) => {
|
|
241
|
-
const [inputValue, setInputValue] = (0, import_react4.useState)(record.params.slug);
|
|
242
|
-
(0, import_react4.useEffect)(() => {
|
|
243
|
-
onChange(property.path, inputValue);
|
|
244
|
-
}, [inputValue]);
|
|
245
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_styled_components3.ThemeProvider, { theme: import_design_system2.theme }, /* @__PURE__ */ import_react4.default.createElement(StyledLabel, { htmlFor: "customSlug" }, property.path), /* @__PURE__ */ import_react4.default.createElement(StyledInputWrapper, null, /* @__PURE__ */ import_react4.default.createElement(
|
|
246
|
-
StyledCustomInput,
|
|
247
|
-
{
|
|
248
|
-
id: property.path,
|
|
249
|
-
name: property.path,
|
|
250
|
-
value: inputValue,
|
|
251
|
-
onChange: handleInput
|
|
252
|
-
}
|
|
253
|
-
), /* @__PURE__ */ import_react4.default.createElement(StyledGenerateButton, { variant: "outlined", onClick: generateSlug }, "Generate Slug")));
|
|
254
|
-
function handleInput(e) {
|
|
255
|
-
setInputValue(e.target.value);
|
|
256
|
-
}
|
|
257
|
-
function generateSlug(e) {
|
|
258
|
-
e.preventDefault();
|
|
259
|
-
const slugSource = record.params[property.props.sourceField ?? resource.titleProperty.name];
|
|
260
|
-
if (slugSource) {
|
|
261
|
-
setInputValue(slugifyTitle(slugSource));
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
var CustomSlug_default = CustomSlug;
|
|
266
|
-
|
|
267
|
-
// src/components/Editor/Editor.jsx
|
|
268
|
-
var import_react5 = __toESM(require("react"), 1);
|
|
269
|
-
var import_styled_components5 = require("styled-components");
|
|
270
|
-
var import_editorjs = __toESM(require("@editorjs/editorjs"), 1);
|
|
271
|
-
var import_design_system4 = require("@adminjs/design-system");
|
|
272
|
-
|
|
273
|
-
// src/components/Editor/styles.ts
|
|
274
|
-
var import_design_system3 = require("@adminjs/design-system");
|
|
275
|
-
var import_styled_components4 = require("@adminjs/design-system/styled-components");
|
|
276
|
-
var StyledLabel2 = import_styled_components4.styled.div`
|
|
277
|
-
font-size: 12px;
|
|
278
|
-
margin-bottom: 8px;
|
|
279
|
-
text-transform: capitalize;
|
|
280
|
-
`;
|
|
281
|
-
var StyledShowLabel = (0, import_styled_components4.styled)(StyledLabel2)`
|
|
282
|
-
color: rgb(137, 138, 154);
|
|
283
|
-
font-weight: 300;
|
|
284
|
-
`;
|
|
285
|
-
var StyledEditorWrapper = (0, import_styled_components4.styled)(import_design_system3.Box)`
|
|
286
|
-
padding: 12px;
|
|
287
|
-
margin-bottom: 24px;
|
|
288
|
-
border: 1px solid rgb(187, 195, 203);
|
|
289
|
-
`;
|
|
290
|
-
var StyledEditorViewWrapper = (0, import_styled_components4.styled)(import_design_system3.Box)`
|
|
291
|
-
h1,
|
|
292
|
-
h2,
|
|
293
|
-
h3 {
|
|
294
|
-
margin-bottom: 5px;
|
|
295
|
-
font-weight: bold;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
h1 {
|
|
299
|
-
font-size: 18px;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
h2 {
|
|
303
|
-
font-size: 16px;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
h3 {
|
|
307
|
-
font-size: 14px;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
p {
|
|
311
|
-
margin-bottom: 8px;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
ol,
|
|
315
|
-
ul {
|
|
316
|
-
margin-left: 20px;
|
|
317
|
-
margin-bottom: 8px;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
ol {
|
|
321
|
-
list-style: auto;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
ul {
|
|
325
|
-
list-style: inherit;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
table,
|
|
329
|
-
audio {
|
|
330
|
-
margin: 16px 0;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
table,
|
|
334
|
-
th,
|
|
335
|
-
td {
|
|
336
|
-
border: 1px solid;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
th {
|
|
340
|
-
font-weight: bold;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
th,
|
|
344
|
-
td {
|
|
345
|
-
padding: 4px;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
blockquote {
|
|
349
|
-
display: block;
|
|
350
|
-
padding: 5px 8px;
|
|
351
|
-
width: fit-content;
|
|
352
|
-
border-radius: 4px;
|
|
353
|
-
background-color: #e6e6e6;
|
|
354
|
-
}
|
|
355
|
-
`;
|
|
356
|
-
var StyledEditorShowWrapper = (0, import_styled_components4.styled)(StyledEditorViewWrapper)`
|
|
357
|
-
margin-bottom: 24px;
|
|
358
|
-
`;
|
|
359
|
-
var StyledEditor = import_styled_components4.styled.div`
|
|
360
|
-
audio,
|
|
361
|
-
.cdx-block,
|
|
362
|
-
.ce-header {
|
|
363
|
-
padding-left: 58px;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
input {
|
|
367
|
-
margin-left: 58px;
|
|
368
|
-
width: auto;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
.cdx-list {
|
|
372
|
-
padding-left: 85px;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
.ce-block__content {
|
|
376
|
-
width: 100%;
|
|
377
|
-
max-width: none;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
.ce-toolbar__content {
|
|
381
|
-
max-width: none;
|
|
382
|
-
left: 0;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
.ce-toolbar__actions {
|
|
386
|
-
left: 0;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
h1.ce-header {
|
|
390
|
-
font-size: 22px;
|
|
391
|
-
font-weight: bold;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
h2.ce-header {
|
|
395
|
-
font-size: 20px;
|
|
396
|
-
font-weight: bold;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
h3.ce-header {
|
|
400
|
-
font-size: 18px;
|
|
401
|
-
font-weight: bold;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
h4.ce-header {
|
|
405
|
-
font-size: 16px;
|
|
406
|
-
font-weight: bold;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
h5.ce-header {
|
|
410
|
-
font-size: 15px;
|
|
411
|
-
font-weight: bold;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
h6.ce-header {
|
|
415
|
-
font-size: 14px;
|
|
416
|
-
font-weight: bold;
|
|
417
|
-
}
|
|
418
|
-
`;
|
|
419
|
-
|
|
420
|
-
// src/components/Editor/config.ts
|
|
421
|
-
var import_header = __toESM(require("@editorjs/header"), 1);
|
|
422
|
-
var import_list = __toESM(require("@editorjs/list"), 1);
|
|
423
|
-
var import_paragraph = __toESM(require("@editorjs/paragraph"), 1);
|
|
424
|
-
var import_quote = __toESM(require("@editorjs/quote"), 1);
|
|
425
|
-
var import_table = __toESM(require("@editorjs/table"), 1);
|
|
426
|
-
var import_editorjs_audio_player = __toESM(require("editorjs-audio-player"), 1);
|
|
427
|
-
var EDITOR_TOOLS = {
|
|
428
|
-
paragraph: {
|
|
429
|
-
class: import_paragraph.default,
|
|
430
|
-
inlineToolbar: true
|
|
431
|
-
},
|
|
432
|
-
list: {
|
|
433
|
-
class: import_list.default,
|
|
434
|
-
inlineToolbar: true
|
|
435
|
-
},
|
|
436
|
-
header: {
|
|
437
|
-
class: import_header.default,
|
|
438
|
-
config: {
|
|
439
|
-
placeholder: "Enter a header",
|
|
440
|
-
levels: [2, 3, 4],
|
|
441
|
-
defaultLevel: 2
|
|
442
|
-
}
|
|
443
|
-
},
|
|
444
|
-
table: {
|
|
445
|
-
class: import_table.default,
|
|
446
|
-
inlineToolbar: true
|
|
447
|
-
},
|
|
448
|
-
quote: {
|
|
449
|
-
class: import_quote.default,
|
|
450
|
-
inlineToolbar: true
|
|
451
|
-
},
|
|
452
|
-
audioPlayer: import_editorjs_audio_player.default
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
// src/components/Editor/Editor.jsx
|
|
456
|
-
var Editor = ({ property, record, onChangeAdmin, editorId }) => {
|
|
457
|
-
const [jsonData, setJsonData] = (0, import_react5.useState)();
|
|
458
|
-
const isSavedData = Boolean(record.params[property.path]);
|
|
459
|
-
const ref = (0, import_react5.useRef)();
|
|
460
|
-
(0, import_react5.useEffect)(() => {
|
|
461
|
-
onChangeAdmin(property.path, jsonData);
|
|
462
|
-
}, [jsonData]);
|
|
463
|
-
(0, import_react5.useEffect)(() => {
|
|
464
|
-
if (!ref.current) {
|
|
465
|
-
const editor = new import_editorjs.default({
|
|
466
|
-
holder: editorId,
|
|
467
|
-
tools: EDITOR_TOOLS,
|
|
468
|
-
data: isSavedData ? JSON.parse(record.params[property.path]) : "",
|
|
469
|
-
async onChange(api, event) {
|
|
470
|
-
const data = await api.saver.save();
|
|
471
|
-
setJsonData(JSON.stringify(data));
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
ref.current = editor;
|
|
475
|
-
}
|
|
476
|
-
return () => {
|
|
477
|
-
ref?.current?.destroy?.();
|
|
478
|
-
};
|
|
479
|
-
}, []);
|
|
480
|
-
return /* @__PURE__ */ import_react5.default.createElement(import_styled_components5.ThemeProvider, { theme: import_design_system4.theme }, /* @__PURE__ */ import_react5.default.createElement(StyledLabel2, null, property.path), /* @__PURE__ */ import_react5.default.createElement(StyledEditorWrapper, null, /* @__PURE__ */ import_react5.default.createElement(StyledEditor, { id: editorId })));
|
|
481
|
-
};
|
|
482
|
-
var Editor_default = Editor;
|
|
483
|
-
|
|
484
|
-
// src/components/Editor/EditorList.jsx
|
|
485
|
-
var import_react6 = __toESM(require("react"), 1);
|
|
486
|
-
var import_design_system5 = require("@adminjs/design-system");
|
|
487
|
-
var import_styled_components6 = require("styled-components");
|
|
488
|
-
var EditorList = ({ property, record }) => {
|
|
489
|
-
const htmlContent = parseHtml(record.params[property.path]);
|
|
490
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_styled_components6.ThemeProvider, { theme: import_design_system5.theme }, /* @__PURE__ */ import_react6.default.createElement(StyledEditorViewWrapper, null, htmlContent && /* @__PURE__ */ import_react6.default.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })));
|
|
491
|
-
};
|
|
492
|
-
var EditorList_default = EditorList;
|
|
493
|
-
|
|
494
|
-
// src/components/Editor/EditorShow.jsx
|
|
495
|
-
var import_react7 = __toESM(require("react"), 1);
|
|
496
|
-
var import_styled_components7 = require("styled-components");
|
|
497
|
-
var import_design_system6 = require("@adminjs/design-system");
|
|
498
|
-
var EditorShow = ({ property, record }) => {
|
|
499
|
-
const htmlContent = parseHtml(record.params[property.path]);
|
|
500
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_styled_components7.ThemeProvider, { theme: import_design_system6.theme }, /* @__PURE__ */ import_react7.default.createElement(StyledEditorShowWrapper, null, /* @__PURE__ */ import_react7.default.createElement(StyledShowLabel, null, property.path), htmlContent && /* @__PURE__ */ import_react7.default.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })));
|
|
501
|
-
};
|
|
502
|
-
var EditorShow_default = EditorShow;
|
|
503
|
-
|
|
504
|
-
// src/components/StringList/StringList.tsx
|
|
505
|
-
var import_design_system9 = require("@adminjs/design-system");
|
|
506
|
-
var import_react11 = __toESM(require("react"), 1);
|
|
507
|
-
var import_styled_components11 = require("styled-components");
|
|
508
|
-
|
|
509
|
-
// src/components/StringList/styles.ts
|
|
510
|
-
var import_design_system7 = require("@adminjs/design-system");
|
|
511
|
-
var import_styled_components8 = require("@adminjs/design-system/styled-components");
|
|
512
|
-
var StyledWrapper = (0, import_styled_components8.styled)(import_design_system7.Box)`
|
|
513
|
-
display: flex;
|
|
514
|
-
flex-direction: column;
|
|
515
|
-
margin-bottom: 45px;
|
|
516
|
-
`;
|
|
517
|
-
var StyledCustomInput2 = (0, import_styled_components8.styled)(import_design_system7.Input)`
|
|
518
|
-
width: 100%;
|
|
519
|
-
margin-right: 10px;
|
|
520
|
-
`;
|
|
521
|
-
var StyledInputWrapper2 = (0, import_styled_components8.styled)(import_design_system7.Box)`
|
|
522
|
-
display: flex;
|
|
523
|
-
`;
|
|
524
|
-
var StyledListWrapper = (0, import_styled_components8.styled)(import_design_system7.Box)`
|
|
525
|
-
margin-bottom: 15px;
|
|
526
|
-
`;
|
|
527
|
-
var StyledLabel3 = import_styled_components8.styled.div`
|
|
528
|
-
font-size: 12px;
|
|
529
|
-
margin-bottom: 8px;
|
|
530
|
-
text-transform: capitalize;
|
|
531
|
-
`;
|
|
532
|
-
var StyledShowLabel2 = (0, import_styled_components8.styled)(StyledLabel3)`
|
|
533
|
-
line-height: 16px;
|
|
534
|
-
color: rgb(137, 138, 154);
|
|
535
|
-
font-weight: 300;
|
|
536
|
-
`;
|
|
537
|
-
var StyledShowWrapper = (0, import_styled_components8.styled)(import_design_system7.Box)`
|
|
538
|
-
margin-bottom: 35px;
|
|
539
|
-
`;
|
|
540
|
-
var StyledListItem = import_styled_components8.styled.li`
|
|
541
|
-
margin-bottom: 5px;
|
|
542
|
-
`;
|
|
543
|
-
|
|
544
|
-
// src/components/StringList/SortableList/SortableList.tsx
|
|
545
|
-
var import_react10 = __toESM(require("react"), 1);
|
|
546
|
-
var import_core = require("@dnd-kit/core");
|
|
547
|
-
var import_sortable2 = require("@dnd-kit/sortable");
|
|
548
|
-
|
|
549
|
-
// src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx
|
|
550
|
-
var import_react9 = __toESM(require("react"), 1);
|
|
551
|
-
var import_sortable = require("@dnd-kit/sortable");
|
|
552
|
-
var import_design_system8 = require("@adminjs/design-system");
|
|
553
|
-
|
|
554
|
-
// src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx
|
|
555
|
-
var import_react8 = __toESM(require("react"), 1);
|
|
556
|
-
|
|
557
|
-
// src/components/StringList/SortableList/components/SortableItem/styles.ts
|
|
558
|
-
var import_styled_components9 = require("@adminjs/design-system/styled-components");
|
|
559
|
-
var StyledListItem2 = import_styled_components9.styled.li`
|
|
560
|
-
display: flex;
|
|
561
|
-
justify-content: space-between;
|
|
562
|
-
align-items: center;
|
|
563
|
-
background-color: #fff;
|
|
564
|
-
padding: 10px 20px 10px 15px;
|
|
565
|
-
box-shadow:
|
|
566
|
-
0 0 0 calc(1px / var(--scale-x, 1)) rgba(63, 63, 68, 0.05),
|
|
567
|
-
0 1px calc(3px / var(--scale-x, 1)) 0 rgba(34, 33, 81, 0.15);
|
|
568
|
-
border-radius: 5px;
|
|
569
|
-
list-style: none;
|
|
570
|
-
`;
|
|
571
|
-
var StyledDragButton = import_styled_components9.styled.button`
|
|
572
|
-
padding: 3px;
|
|
573
|
-
margin-right: 15px;
|
|
574
|
-
cursor: move;
|
|
575
|
-
background: none;
|
|
576
|
-
border: none;
|
|
577
|
-
`;
|
|
578
|
-
|
|
579
|
-
// src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx
|
|
580
|
-
var DragHandle = ({ context }) => {
|
|
581
|
-
const { attributes, listeners, ref } = (0, import_react8.useContext)(context);
|
|
582
|
-
return /* @__PURE__ */ import_react8.default.createElement(StyledDragButton, { ...attributes, ...listeners, ref }, /* @__PURE__ */ import_react8.default.createElement("svg", { viewBox: "0 0 20 20", width: "13" }, /* @__PURE__ */ import_react8.default.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" })));
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
// src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx
|
|
586
|
-
var SortableItemContext = (0, import_react9.createContext)({
|
|
587
|
-
attributes: {},
|
|
588
|
-
listeners: void 0,
|
|
589
|
-
ref() {
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
function SortableItem({
|
|
593
|
-
children,
|
|
594
|
-
id,
|
|
595
|
-
onDelete
|
|
596
|
-
}) {
|
|
597
|
-
const { attributes, isDragging, listeners, setNodeRef, setActivatorNodeRef } = (0, import_sortable.useSortable)({ id });
|
|
598
|
-
const context = (0, import_react9.useMemo)(
|
|
599
|
-
() => ({
|
|
600
|
-
attributes,
|
|
601
|
-
listeners,
|
|
602
|
-
ref: setActivatorNodeRef
|
|
603
|
-
}),
|
|
604
|
-
[attributes, listeners, setActivatorNodeRef]
|
|
605
|
-
);
|
|
606
|
-
const style = {
|
|
607
|
-
opacity: isDragging ? 0.4 : void 0
|
|
608
|
-
};
|
|
609
|
-
return /* @__PURE__ */ import_react9.default.createElement(SortableItemContext.Provider, { value: context }, /* @__PURE__ */ import_react9.default.createElement(StyledListItem2, { ref: setNodeRef, style }, /* @__PURE__ */ import_react9.default.createElement("div", null, /* @__PURE__ */ import_react9.default.createElement(DragHandle, { context: SortableItemContext }), children), /* @__PURE__ */ import_react9.default.createElement(
|
|
610
|
-
import_design_system8.Button,
|
|
611
|
-
{
|
|
612
|
-
variant: "outlined",
|
|
613
|
-
color: "danger",
|
|
614
|
-
size: "icon",
|
|
615
|
-
onClick: (e) => onDelete(e, id)
|
|
616
|
-
},
|
|
617
|
-
/* @__PURE__ */ import_react9.default.createElement(import_design_system8.Icon, { icon: "X", color: "red" })
|
|
618
|
-
)));
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// src/components/StringList/SortableList/styles.ts
|
|
622
|
-
var import_styled_components10 = require("@adminjs/design-system/styled-components");
|
|
623
|
-
var StyledListWrapper2 = import_styled_components10.styled.ul`
|
|
624
|
-
display: flex;
|
|
625
|
-
flex-direction: column;
|
|
626
|
-
gap: 12px;
|
|
627
|
-
padding: 0;
|
|
628
|
-
list-style: none;
|
|
629
|
-
`;
|
|
630
|
-
|
|
631
|
-
// src/components/StringList/SortableList/SortableList.tsx
|
|
632
|
-
var dropAnimationConfig = {
|
|
633
|
-
sideEffects: (0, import_core.defaultDropAnimationSideEffects)({
|
|
634
|
-
styles: {
|
|
635
|
-
active: {
|
|
636
|
-
opacity: "0.4"
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
})
|
|
640
|
-
};
|
|
641
|
-
function SortableList({
|
|
642
|
-
items,
|
|
643
|
-
onChange,
|
|
644
|
-
renderItem
|
|
645
|
-
}) {
|
|
646
|
-
const [active, setActive] = (0, import_react10.useState)(null);
|
|
647
|
-
const activeItem = (0, import_react10.useMemo)(
|
|
648
|
-
() => items.find((item) => item.id === active?.id),
|
|
649
|
-
[active, items]
|
|
650
|
-
);
|
|
651
|
-
const sensors = (0, import_core.useSensors)(
|
|
652
|
-
(0, import_core.useSensor)(import_core.PointerSensor),
|
|
653
|
-
(0, import_core.useSensor)(import_core.KeyboardSensor, {
|
|
654
|
-
coordinateGetter: import_sortable2.sortableKeyboardCoordinates
|
|
655
|
-
})
|
|
656
|
-
);
|
|
657
|
-
return /* @__PURE__ */ import_react10.default.createElement(
|
|
658
|
-
import_core.DndContext,
|
|
659
|
-
{
|
|
660
|
-
sensors,
|
|
661
|
-
onDragStart: ({ active: active2 }) => {
|
|
662
|
-
setActive(active2);
|
|
663
|
-
},
|
|
664
|
-
onDragEnd: ({ active: active2, over }) => {
|
|
665
|
-
if (over && active2.id !== over?.id) {
|
|
666
|
-
const activeIndex = items.findIndex(({ id }) => id === active2.id);
|
|
667
|
-
const overIndex = items.findIndex(({ id }) => id === over.id);
|
|
668
|
-
onChange((0, import_sortable2.arrayMove)(items, activeIndex, overIndex));
|
|
669
|
-
}
|
|
670
|
-
setActive(null);
|
|
671
|
-
},
|
|
672
|
-
onDragCancel: () => {
|
|
673
|
-
setActive(null);
|
|
674
|
-
}
|
|
675
|
-
},
|
|
676
|
-
/* @__PURE__ */ import_react10.default.createElement(import_sortable2.SortableContext, { items, strategy: import_sortable2.verticalListSortingStrategy }, /* @__PURE__ */ import_react10.default.createElement(StyledListWrapper2, { role: "application" }, items.map((item, index) => /* @__PURE__ */ import_react10.default.createElement(import_react10.Fragment, { key: index }, renderItem(item))))),
|
|
677
|
-
/* @__PURE__ */ import_react10.default.createElement(import_core.DragOverlay, { dropAnimation: dropAnimationConfig }, activeItem ? renderItem(activeItem) : null)
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
|
-
SortableList.Item = SortableItem;
|
|
681
|
-
|
|
682
|
-
// src/components/StringList/constants.ts
|
|
683
|
-
var separator = "|";
|
|
684
|
-
|
|
685
|
-
// src/components/StringList/StringList.tsx
|
|
686
|
-
var StringList = ({
|
|
687
|
-
record,
|
|
688
|
-
onChange,
|
|
689
|
-
property,
|
|
690
|
-
stringListSeparator = separator
|
|
691
|
-
}) => {
|
|
692
|
-
const stringListValue = record.params?.[property.path] ?? property.props.value ?? "";
|
|
693
|
-
const initialList = stringListValue ? prepareDataForList(stringListValue) : [];
|
|
694
|
-
const [inputValue, setInputValue] = (0, import_react11.useState)("");
|
|
695
|
-
const [list, setList] = (0, import_react11.useState)(initialList);
|
|
696
|
-
const serializedData = prepareDataForDatabase(list);
|
|
697
|
-
(0, import_react11.useEffect)(() => {
|
|
698
|
-
onChange(property.path, serializedData);
|
|
699
|
-
}, [serializedData]);
|
|
700
|
-
return /* @__PURE__ */ import_react11.default.createElement(import_styled_components11.ThemeProvider, { theme: import_design_system9.theme }, /* @__PURE__ */ import_react11.default.createElement(StyledLabel3, { htmlFor: "custom" }, property.path), /* @__PURE__ */ import_react11.default.createElement(StyledWrapper, null, /* @__PURE__ */ import_react11.default.createElement(StyledListWrapper, null, /* @__PURE__ */ import_react11.default.createElement(
|
|
701
|
-
SortableList,
|
|
702
|
-
{
|
|
703
|
-
items: list,
|
|
704
|
-
onChange: setList,
|
|
705
|
-
renderItem: (item) => /* @__PURE__ */ import_react11.default.createElement(SortableList.Item, { id: item.id, onDelete: handleDeleteButton }, item.value)
|
|
706
|
-
}
|
|
707
|
-
)), /* @__PURE__ */ import_react11.default.createElement(StyledInputWrapper2, null, /* @__PURE__ */ import_react11.default.createElement(
|
|
708
|
-
import_design_system9.Input,
|
|
709
|
-
{
|
|
710
|
-
id: "stringList",
|
|
711
|
-
name: property.path,
|
|
712
|
-
value: serializedData,
|
|
713
|
-
hidden: true
|
|
714
|
-
}
|
|
715
|
-
), /* @__PURE__ */ import_react11.default.createElement(
|
|
716
|
-
StyledCustomInput2,
|
|
717
|
-
{
|
|
718
|
-
id: "custom",
|
|
719
|
-
name: "customInput",
|
|
720
|
-
value: inputValue,
|
|
721
|
-
onChange: handleInput,
|
|
722
|
-
onKeyPress: handleEnterPress
|
|
723
|
-
}
|
|
724
|
-
), /* @__PURE__ */ import_react11.default.createElement(import_design_system9.Button, { variant: "outlined", onClick: handleAddButton }, "Add"))));
|
|
725
|
-
function handleInput(e) {
|
|
726
|
-
setInputValue(e.target.value);
|
|
727
|
-
}
|
|
728
|
-
function handleEnterPress(e) {
|
|
729
|
-
if (e.key === "Enter") {
|
|
730
|
-
handleAddButton(e);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
function handleAddButton(e) {
|
|
734
|
-
e.preventDefault();
|
|
735
|
-
if (Boolean(inputValue)) {
|
|
736
|
-
setList([...list, createListObject(inputValue)]);
|
|
737
|
-
setInputValue("");
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
function handleDeleteButton(e, id) {
|
|
741
|
-
e.preventDefault();
|
|
742
|
-
const newData = list.filter((item) => item.id !== id);
|
|
743
|
-
setList(newData);
|
|
744
|
-
}
|
|
745
|
-
function prepareDataForDatabase(list2) {
|
|
746
|
-
return list2.map(({ value }) => value).join(stringListSeparator);
|
|
747
|
-
}
|
|
748
|
-
function prepareDataForList(str) {
|
|
749
|
-
return str.split(stringListSeparator).map((item) => createListObject(item));
|
|
750
|
-
}
|
|
751
|
-
function createListObject(value) {
|
|
752
|
-
return {
|
|
753
|
-
id: `${Date.now()}-${Math.floor(Math.random() * 1e3)}`,
|
|
754
|
-
value
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
};
|
|
758
|
-
var StringList_default = StringList;
|
|
759
|
-
|
|
760
|
-
// src/components/StringList/StringListShow.tsx
|
|
761
|
-
var import_react12 = __toESM(require("react"), 1);
|
|
762
|
-
var import_styled_components12 = require("styled-components");
|
|
763
|
-
var import_design_system10 = require("@adminjs/design-system");
|
|
764
|
-
var StringListShow = ({
|
|
765
|
-
property,
|
|
766
|
-
record,
|
|
767
|
-
stringListSeparator = separator
|
|
768
|
-
}) => {
|
|
769
|
-
return /* @__PURE__ */ import_react12.default.createElement(import_styled_components12.ThemeProvider, { theme: import_design_system10.theme }, /* @__PURE__ */ import_react12.default.createElement(StyledShowWrapper, null, /* @__PURE__ */ import_react12.default.createElement(StyledShowLabel2, null, property.path), record.params.facts && /* @__PURE__ */ import_react12.default.createElement("ul", null, record.params.facts.split(stringListSeparator).map((item, index) => /* @__PURE__ */ import_react12.default.createElement(StyledListItem, { key: index }, `- ${item}`)))));
|
|
770
|
-
};
|
|
771
|
-
var StringListShow_default = StringListShow;
|
|
772
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
773
|
-
0 && (module.exports = {
|
|
774
|
-
ColorStatusEdit,
|
|
775
|
-
ColorStatusList,
|
|
776
|
-
ColorStatusShow,
|
|
777
|
-
CustomSlug,
|
|
778
|
-
Editor,
|
|
779
|
-
EditorList,
|
|
780
|
-
EditorShow,
|
|
781
|
-
StringList,
|
|
782
|
-
StringListShow,
|
|
783
|
-
parseHtml
|
|
784
|
-
});
|