decord/alpha/source/modules/interaction_components/validateComponent.tsx

179 lines
6.9 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 06:59:38 +00:00
// Module ID: 8253
// Function ID: 8254
2026-07-29 08:29:29 +00:00
// Name: validateComponent
2026-10-10 08:08:14 +00:00
// Dependencies: [1998, 5436, 1126, 38, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-10-12 06:59:38 +00:00
// Module 8253 (validateComponent)
2026-08-24 06:08:38 +00:00
import _modDef38 from "module_38" /* 38 */;
2026-10-09 10:00:15 +00:00
import Server from "Server" /* 1998 */;
2026-10-10 08:08:14 +00:00
import InteractionComponentUtils from "InteractionComponentUtils" /* 5436 */;
import size from "module_2" /* 2 */;
2026-08-24 06:08:38 +00:00
const result = size.fileFinishedImporting("modules/interaction_components/validateComponent.tsx");
2026-07-20 16:05:17 +00:00
2026-10-03 08:58:59 +00:00
export default function validateComponent(type, type2, modal) {
let maxLength;
let maxValues;
let maxValues2;
let maxValues3;
let minLength;
let minValues;
let minValues2;
let minValues3;
let required3;
if (null != type2) {
_modDef38(type2.type === type.type, "component type matches state");
2026-07-20 16:05:17 +00:00
}
type = type.type;
if (Server.ComponentType.BUTTON === type) {
2026-07-20 16:05:17 +00:00
return null;
} else {
2026-10-03 08:58:59 +00:00
let formatToPlainStringResult3;
if (Server.ComponentType.STRING_SELECT !== type) {
if (Server.ComponentType.USER_SELECT !== type) {
if (Server.ComponentType.ROLE_SELECT !== type) {
if (Server.ComponentType.MENTIONABLE_SELECT !== type) {
if (Server.ComponentType.CHANNEL_SELECT !== type) {
if (Server.ComponentType.TEXT_INPUT === type) {
({ minLength, maxLength, required: required3 } = type);
if (null != type2) {
let formatToPlainStringResult;
if (0 !== type2.value.length) {
if (type2.value.length < minLength) {
const intl8 = tmp4(1126).intl;
const range = { min: minLength, max: maxLength };
2026-10-03 08:58:59 +00:00
formatToPlainStringResult = intl8.formatToPlainString(tmp4(1126).t.ONSqYd, range);
2026-07-20 16:05:17 +00:00
} else {
formatToPlainStringResult = null;
}
}
return formatToPlainStringResult;
}
let stringResult = null;
2026-10-03 08:58:59 +00:00
if (required3) {
const intl9 = tmp4(1126).intl;
stringResult = intl9.string(tmp4(1126).t.eJEUvD);
2026-07-20 16:05:17 +00:00
}
formatToPlainStringResult = stringResult;
2026-10-03 08:58:59 +00:00
} else if (Server.ComponentType.FILE_UPLOAD === type) {
let formatToPlainStringResult1;
2026-07-20 16:05:17 +00:00
({ minValues: minValues2, maxValues: maxValues2 } = type);
2026-07-29 08:29:29 +00:00
let num3;
2026-10-03 08:58:59 +00:00
const required2 = type.required;
if (type2 != null) {
num3 = type2.uploadIds.length;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num3 == null) {
num3 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (0 === num3) {
2026-07-20 16:05:17 +00:00
let stringResult1 = null;
2026-10-03 08:58:59 +00:00
if (required2) {
const intl7 = tmp4(1126).intl;
stringResult1 = intl7.string(tmp4(1126).t.eJEUvD);
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
formatToPlainStringResult1 = stringResult1;
2026-07-29 08:29:29 +00:00
} else if (num3 < minValues2) {
2026-10-03 08:58:59 +00:00
const intl6 = tmp4(1126).intl;
const obj2 = { minValues: minValues2 };
2026-10-03 08:58:59 +00:00
formatToPlainStringResult1 = intl6.formatToPlainString(tmp4(1126).t.pmAt62, obj2);
2026-07-20 16:05:17 +00:00
} else {
formatToPlainStringResult1 = null;
2026-07-29 08:29:29 +00:00
if (num3 > maxValues2) {
2026-10-03 08:58:59 +00:00
const intl5 = tmp4(1126).intl;
const obj3 = { maxValues: maxValues2 };
2026-10-03 08:58:59 +00:00
formatToPlainStringResult1 = intl5.formatToPlainString(tmp4(1126).t.dy6viJ, obj3);
2026-07-20 16:05:17 +00:00
}
}
return formatToPlainStringResult1;
2026-10-03 08:58:59 +00:00
} else if (Server.ComponentType.RADIO_GROUP === type) {
let stringResult2;
if (null == type2) {
stringResult2 = null;
2026-07-29 08:29:29 +00:00
if (tmp10) {
2026-10-03 08:58:59 +00:00
const intl4 = tmp4(1126).intl;
stringResult2 = intl4.string(tmp4(1126).t.eJEUvD);
2026-07-20 16:05:17 +00:00
}
} else {
stringResult2 = null;
}
return stringResult2;
2026-10-03 08:58:59 +00:00
} else if (Server.ComponentType.CHECKBOX_GROUP === type) {
let formatToPlainStringResult2;
2026-07-20 16:05:17 +00:00
({ minValues, maxValues } = type);
2026-07-29 08:29:29 +00:00
let num;
2026-10-03 08:58:59 +00:00
const required = type.required;
if (type2 != null) {
num = type2.values.length;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (0 === num) {
2026-07-20 16:05:17 +00:00
let stringResult3 = null;
2026-10-03 08:58:59 +00:00
if (required) {
const intl3 = tmp4(1126).intl;
stringResult3 = intl3.string(tmp4(1126).t.eJEUvD);
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
formatToPlainStringResult2 = stringResult3;
2026-07-29 08:29:29 +00:00
} else if (num < minValues) {
2026-10-03 08:58:59 +00:00
const intl2 = tmp4(1126).intl;
const obj4 = { count: minValues };
2026-10-03 08:58:59 +00:00
formatToPlainStringResult2 = intl2.formatToPlainString(tmp4(1126).t.Jmwzdx, obj4);
2026-07-20 16:05:17 +00:00
} else {
formatToPlainStringResult2 = null;
2026-07-29 08:29:29 +00:00
if (num > maxValues) {
2026-10-03 08:58:59 +00:00
const intl = tmp4(1126).intl;
const obj = { count: maxValues };
2026-10-03 08:58:59 +00:00
formatToPlainStringResult2 = intl.formatToPlainString(tmp4(1126).t.LDvfRP, obj);
2026-07-20 16:05:17 +00:00
}
}
return formatToPlainStringResult2;
2026-10-03 08:58:59 +00:00
} else if (Server.ComponentType.CHECKBOX === type) {
2026-07-20 16:05:17 +00:00
return null;
} else {
2026-08-24 06:08:38 +00:00
_modDef38(false, "missing validator for this component");
2026-07-20 16:05:17 +00:00
}
}
}
}
}
}
2026-07-29 08:29:29 +00:00
({ minValues: minValues3, maxValues: maxValues3 } = type);
2026-10-03 08:58:59 +00:00
let num7 = 0;
const required4 = type.required;
if (null != type2) {
let length;
if (type2.type === Server.ComponentType.STRING_SELECT) {
length = type2.values.length;
} else {
length = type2.selectedOptions.length;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
num7 = length;
}
if (0 === num7) {
let stringResult4 = null;
const obj5 = { minValues: minValues3, required: required4 };
const tmp4Result = InteractionComponentUtils;
if (!tmp4Result.canSelectBeEmpty(obj5, modal)) {
const intl12 = tmp4(1126).intl;
stringResult4 = intl12.string(tmp4(1126).t.eJEUvD);
}
formatToPlainStringResult3 = stringResult4;
} else if (num7 < minValues3) {
const intl11 = tmp4(1126).intl;
const obj6 = { count: minValues3 };
formatToPlainStringResult3 = intl11.formatToPlainString(tmp4(1126).t.Jmwzdx, obj6);
2026-07-29 08:29:29 +00:00
} else {
2026-10-03 08:58:59 +00:00
formatToPlainStringResult3 = null;
if (num7 > maxValues3) {
const intl10 = tmp4(1126).intl;
const obj7 = { count: maxValues3 };
formatToPlainStringResult3 = intl10.formatToPlainString(tmp4(1126).t.LDvfRP, obj7);
}
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
return formatToPlainStringResult3;
2026-07-20 16:05:17 +00:00
}
};