Files
oneuptime/Common/UI/Components/Dictionary/DictionaryOfStrings.tsx
Simon Larsen ebd14dd497 Refactor import paths in Workflow components to use relative paths from Types directory
- Updated import statements in ComponentSettingsModal, ComponentValuePickerModal, ComponentsModal, DocumentationViewer, RunForm, RunModal, Utils, VariableModal, Workflow, WorkflowStatus, Config, EntityFieldType, and various API utility files to reflect the new directory structure.
- Ensured all imports from "Common/Types" are now sourced from "../../../Types" to maintain consistency and improve module resolution.
2025-05-21 14:02:32 +01:00

41 lines
1.1 KiB
TypeScript

import DictionaryForm, { ValueType } from "./Dictionary";
import Dictionary from "../../../Types/Dictionary";
import React, { FunctionComponent, ReactElement } from "react";
export interface ComponentProps {
onChange?: undefined | ((value: Dictionary<string>) => void);
initialValue?: Dictionary<string>;
keyPlaceholder?: string;
valuePlaceholder?: string;
addButtonSuffix?: string;
}
const DictionaryOfStrings: FunctionComponent<ComponentProps> = (
props: ComponentProps,
): ReactElement => {
return (
// only allow text values
<DictionaryForm
{...props}
valueTypes={[ValueType.Text]}
onChange={(value: Dictionary<string | number | boolean>) => {
const stringDict: Dictionary<string> = value as Dictionary<string>;
// convert all values to strings
for (const key in stringDict) {
if (stringDict[key]) {
stringDict[key] = stringDict[key]?.toString() || "";
}
}
if (props.onChange) {
props.onChange(stringDict);
}
}}
/>
);
};
export default DictionaryOfStrings;