type
FieldEditorDefinition
The existing field type, Svelte component, and optional settings decoder passed to defineFieldEditor.
Example
import { defineAdmin } from '@riducms/plugin/admin';
import { defineFieldEditor } from '@riducms/plugin/editor';
import { generatedAdminPlugins } from './ridu.plugins.generated';
import TitleField from './components/title-field.svelte';
export default defineAdmin({
plugins: generatedAdminPlugins,
fields: {
'app:titleCounter': defineFieldEditor({
type: 'text',
component: TitleField
})
}
});Editor options
| Property | Type | Description |
|---|---|---|
type | FieldEditorType | Required. Match the Go field type: text, textarea, email, date, code, number, checkbox, text-list, or number-list. This determines the value your component reads and writes. |
component | Component< | Required. A Svelte component receiving the matching FieldEditorProps. Use field.value for the current input and field.set(...) to change it. |
decodeConfig | (value: unknown) => Config | Optional. Check settings supplied by Go field.Component and return a typed config prop. It must return synchronously or throw. With a decoder, Go must supply a settings object; without one, omit Go settings. |
How it works
TypeScript infers Type from type and Config from the decoder’s return value. The component must accept those exact props. Do not add a config generic without a decoder: a type annotation does not check settings coming from Go.
Full signature
type FieldEditorDefinition<Type extends FieldEditorType, Config = undefined> = {
/** The existing field type to display differently, for example `"text"` or `"number"`. */
type: Type;
/** Svelte component accepting the matching `FieldEditorProps<Type, Config>`. */
component: Component<FieldEditorProps<NoInfer<Type>, NoInfer<Config>>>;
} & (0 extends 1 & Config
? { decodeConfig: (value: unknown) => Config }
: [Config] extends [never]
? { decodeConfig: (value: unknown) => Config }
: [Config] extends [undefined]
? { decodeConfig?: (value: unknown) => Config }
: { decodeConfig: (value: unknown) => Config })