kui-crm 0.0.134 → 0.0.136
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/cjs/index.js +67 -8
- package/cjs/index.js.map +1 -1
- package/index.d.ts +56 -41
- package/index.js +67 -8
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +55 -37
- package/utils/cjs/index.js +1 -1
- package/utils/cjs/index.js.map +1 -1
- package/utils/index.d.ts +29 -32
- package/utils/index.js +1 -1
- package/utils/index.js.map +1 -1
package/cjs/index.js
CHANGED
|
@@ -653,7 +653,7 @@ var getBodyForImageRequest = function (file, res) {
|
|
|
653
653
|
return res
|
|
654
654
|
? {
|
|
655
655
|
temp_file_id: res.id,
|
|
656
|
-
image_name: (_b = (file.name || ((_a = file.file) === null || _a === void 0 ? void 0 : _a.name))) === null || _b === void 0 ? void 0 : _b.replace(/\.[^/.]+$/, ""),
|
|
656
|
+
image_name: ((_b = (file.name || ((_a = file.file) === null || _a === void 0 ? void 0 : _a.name))) === null || _b === void 0 ? void 0 : _b.replace(/\.[^/.]+$/, "")) || "",
|
|
657
657
|
}
|
|
658
658
|
: null;
|
|
659
659
|
};
|
|
@@ -1073,6 +1073,34 @@ var FileStore = /** @class */ (function () {
|
|
|
1073
1073
|
function FileStore(file, filesStore) {
|
|
1074
1074
|
var _this = this;
|
|
1075
1075
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1076
|
+
this.uploadFile = function (variant) { return __awaiter(_this, void 0, void 0, function () {
|
|
1077
|
+
var loadFunc, file;
|
|
1078
|
+
return __generator(this, function (_a) {
|
|
1079
|
+
switch (_a.label) {
|
|
1080
|
+
case 0:
|
|
1081
|
+
if (!this.file) return [3 /*break*/, 2];
|
|
1082
|
+
this.updateUploadStatus("loading");
|
|
1083
|
+
loadFunc = variant === "image" ? uploadImage : uploadNewFile;
|
|
1084
|
+
return [4 /*yield*/, loadFunc(this.loader, this)];
|
|
1085
|
+
case 1:
|
|
1086
|
+
file = _a.sent();
|
|
1087
|
+
if (file) {
|
|
1088
|
+
this.updateUploadedData(file);
|
|
1089
|
+
this.updateUploadStatus("success");
|
|
1090
|
+
}
|
|
1091
|
+
else
|
|
1092
|
+
this.updateUploadStatus("failure");
|
|
1093
|
+
_a.label = 2;
|
|
1094
|
+
case 2: return [2 /*return*/];
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
}); };
|
|
1098
|
+
this.updateUploadStatus = function (status) {
|
|
1099
|
+
_this.uploadStatus = status;
|
|
1100
|
+
};
|
|
1101
|
+
this.updateUploadedData = function (data) {
|
|
1102
|
+
_this.uploadedData = data;
|
|
1103
|
+
};
|
|
1076
1104
|
this.editFile = function (data) {
|
|
1077
1105
|
var _a;
|
|
1078
1106
|
if (_this.id) {
|
|
@@ -1091,26 +1119,34 @@ var FileStore = /** @class */ (function () {
|
|
|
1091
1119
|
_this.name = name;
|
|
1092
1120
|
};
|
|
1093
1121
|
this.updateStore = function (data) { };
|
|
1122
|
+
// get extension() {
|
|
1123
|
+
// return this.name.split(".")?.pop()?.toUpperCase() || ""
|
|
1124
|
+
// }
|
|
1125
|
+
// get title() {
|
|
1126
|
+
// return this.name.split(".")[0]
|
|
1127
|
+
// }
|
|
1128
|
+
this.setIndex = function (index) {
|
|
1129
|
+
_this.index = index;
|
|
1130
|
+
};
|
|
1094
1131
|
this.id = (_a = file.id) !== null && _a !== void 0 ? _a : null;
|
|
1095
1132
|
this.name = (_b = file.name) !== null && _b !== void 0 ? _b : "";
|
|
1133
|
+
this.index = typeof file.index === "number" ? file.index : undefined;
|
|
1096
1134
|
this.url = (_c = file.url) !== null && _c !== void 0 ? _c : "";
|
|
1097
1135
|
this.date = file.date ? luxon.DateTime.fromISO(file.date) : null;
|
|
1098
1136
|
this.size = (_d = file.size) !== null && _d !== void 0 ? _d : null;
|
|
1099
1137
|
this.filesStore = filesStore || null;
|
|
1100
1138
|
this.createdBy = (_e = file.createdBy) !== null && _e !== void 0 ? _e : "";
|
|
1139
|
+
this.file = file.file || undefined;
|
|
1101
1140
|
this.visibility =
|
|
1102
1141
|
file.visibility &&
|
|
1103
1142
|
matchesVisibilityVariants[file.visibility];
|
|
1104
1143
|
this.extension = ((_g = (_f = this.name.split(".")) === null || _f === void 0 ? void 0 : _f.pop()) === null || _g === void 0 ? void 0 : _g.toUpperCase()) || "";
|
|
1144
|
+
this.uploadStatus = file.uploadStatus || "default";
|
|
1145
|
+
this.uploadedData = file.uploadedData || null;
|
|
1146
|
+
this.loader = new kuiUtils.Loader();
|
|
1105
1147
|
mobx.makeAutoObservable(this, { filesStore: false });
|
|
1106
1148
|
}
|
|
1107
1149
|
Object.defineProperty(FileStore.prototype, "title", {
|
|
1108
|
-
// get extension() {
|
|
1109
|
-
// return this.name.split(".")?.pop()?.toUpperCase() || ""
|
|
1110
|
-
// }
|
|
1111
|
-
// get title() {
|
|
1112
|
-
// return this.name.split(".")[0]
|
|
1113
|
-
// }
|
|
1114
1150
|
get: function () {
|
|
1115
1151
|
return this.name.replace(/\.[^/.]+$/, "");
|
|
1116
1152
|
},
|
|
@@ -1132,10 +1168,33 @@ var FileStore = /** @class */ (function () {
|
|
|
1132
1168
|
url: file.attachment,
|
|
1133
1169
|
size: Math.round((file.size / (1024 * 1024)) * 100) / 100,
|
|
1134
1170
|
visibility: file.visibility,
|
|
1135
|
-
createdBy: file.uploaded_by ||
|
|
1171
|
+
createdBy: file.uploaded_by || null,
|
|
1136
1172
|
date: file.created,
|
|
1137
1173
|
});
|
|
1138
1174
|
};
|
|
1175
|
+
FileStore.initFromImageModel = function (file, name) {
|
|
1176
|
+
return new FileStore({
|
|
1177
|
+
id: file.id,
|
|
1178
|
+
name: file.image_name || name || "",
|
|
1179
|
+
url: file.image_url,
|
|
1180
|
+
size: file.size ? Math.round((file.size / (1024 * 1024)) * 100) / 100 : 0,
|
|
1181
|
+
});
|
|
1182
|
+
};
|
|
1183
|
+
FileStore.initFromFile = function (file, index) {
|
|
1184
|
+
return new FileStore({
|
|
1185
|
+
name: file.name,
|
|
1186
|
+
size: Math.round((file.size / (1024 * 1024)) * 100) / 100,
|
|
1187
|
+
url: URL.createObjectURL(file),
|
|
1188
|
+
index: index,
|
|
1189
|
+
file: file,
|
|
1190
|
+
});
|
|
1191
|
+
};
|
|
1192
|
+
FileStore.initFromFileStore = function (file) {
|
|
1193
|
+
var _a;
|
|
1194
|
+
return new FileStore(__assign(__assign({}, file), { date: ((_a = file.date) === null || _a === void 0 ? void 0 : _a.toISODate()) || null, visibility: file.visibility
|
|
1195
|
+
? matchesAPIVisibilityVariants[file.visibility]
|
|
1196
|
+
: "nobody" }));
|
|
1197
|
+
};
|
|
1139
1198
|
return FileStore;
|
|
1140
1199
|
}());
|
|
1141
1200
|
|