Resolve api modal type errors
This commit is contained in:
parent
bdc100d188
commit
fb733d3207
2 changed files with 16 additions and 10 deletions
|
|
@ -25,7 +25,7 @@ import {
|
||||||
getWidgetCode,
|
getWidgetCode,
|
||||||
} from "../../utils/utils";
|
} from "../../utils/utils";
|
||||||
import BaseModal from "../baseModal";
|
import BaseModal from "../baseModal";
|
||||||
import { tweakType } from "../../types/components";
|
import { tweakType, uniqueTweakType } from "../../types/components";
|
||||||
import { APITemplateType, TemplateVariableType } from "../../types/api";
|
import { APITemplateType, TemplateVariableType } from "../../types/api";
|
||||||
|
|
||||||
const ApiModal = forwardRef(
|
const ApiModal = forwardRef(
|
||||||
|
|
@ -207,11 +207,11 @@ const ApiModal = forwardRef(
|
||||||
return self.indexOf(value) === index;
|
return self.indexOf(value) === index;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function buildTweakObject(tw: string | string[], changes: string | string[] | boolean, template: TemplateVariableType) {
|
function buildTweakObject(tw: string, changes: string | string[] | boolean | number, template: TemplateVariableType) {
|
||||||
if (template.type === "float") {
|
if (typeof changes === "string" && template.type === "float") {
|
||||||
changes = parseFloat(changes);
|
changes = parseFloat(changes);
|
||||||
}
|
}
|
||||||
if (template.type === "int") {
|
if (typeof changes === "string" && template.type === "int") {
|
||||||
changes = parseInt(changes);
|
changes = parseInt(changes);
|
||||||
}
|
}
|
||||||
if (template.list === true && Array.isArray(changes)) {
|
if (template.list === true && Array.isArray(changes)) {
|
||||||
|
|
@ -223,7 +223,7 @@ const ApiModal = forwardRef(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (existingTweak) {
|
if (existingTweak) {
|
||||||
existingTweak[tw][template["name"]] = changes;
|
existingTweak[tw][template["name"]] = changes as string;
|
||||||
|
|
||||||
if (existingTweak[tw][template["name"]] == template.value) {
|
if (existingTweak[tw][template["name"]] == template.value) {
|
||||||
tweak.current.forEach((element) => {
|
tweak.current.forEach((element) => {
|
||||||
|
|
@ -240,7 +240,7 @@ const ApiModal = forwardRef(
|
||||||
[tw]: {
|
[tw]: {
|
||||||
[template["name"]]: changes,
|
[template["name"]]: changes,
|
||||||
},
|
},
|
||||||
};
|
} as uniqueTweakType;
|
||||||
tweak.current.push(newTweak);
|
tweak.current.push(newTweak);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,7 +266,7 @@ const ApiModal = forwardRef(
|
||||||
return htmlContent;
|
return htmlContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValue(value: string, node: NodeType, template: APITemplateType) {
|
function getValue(value: string, node: NodeType, template: TemplateVariableType) {
|
||||||
let returnValue = value ?? "";
|
let returnValue = value ?? "";
|
||||||
|
|
||||||
if (getTweak.length > 0) {
|
if (getTweak.length > 0) {
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,12 @@ export type tweakType = Array<{
|
||||||
} & FlowStyleType;
|
} & FlowStyleType;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
export type uniqueTweakType = {
|
||||||
|
[key: string]: {
|
||||||
|
[char: string]: string;
|
||||||
|
} & FlowStyleType;
|
||||||
|
}
|
||||||
|
|
||||||
export type apiModalTweakType = {
|
export type apiModalTweakType = {
|
||||||
current: Array<{
|
current: Array<{
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
|
|
@ -425,11 +431,11 @@ export type codeTabsPropsType = {
|
||||||
getValue?: (
|
getValue?: (
|
||||||
value: string,
|
value: string,
|
||||||
node: NodeType,
|
node: NodeType,
|
||||||
template: APITemplateType
|
template: TemplateVariableType
|
||||||
) => string;
|
) => string;
|
||||||
buildTweakObject?: (
|
buildTweakObject?: (
|
||||||
tw: string | string[],
|
tw: string,
|
||||||
changes: string | string[] | boolean,
|
changes: string | string[] | boolean | number,
|
||||||
template: TemplateVariableType
|
template: TemplateVariableType
|
||||||
) => string | void;
|
) => string | void;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue