mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
Changes for the Signature Check Plugin
This PR contains new Radiobutton components that are needed for the signature-check-plugin. Additionally the ref passing for ControlledChipInputs was also fixed. The current styling of the Radio Buttons need to be discussed with Philipp again. The Signature Check Plugin provides an example use of it. Co-authored-by: Konstantin Schaper<konstantin.schaper@cloudogu.com>
This commit is contained in:
@@ -26,7 +26,7 @@ import React, { ComponentProps } from "react";
|
||||
import { Controller, ControllerRenderProps, Path } from "react-hook-form";
|
||||
import { useScmFormContext } from "../ScmFormContext";
|
||||
import { useScmFormPathContext } from "../FormPathContext";
|
||||
import { defaultOptionFactory, prefixWithoutIndices } from "../helpers";
|
||||
import { defaultOptionFactory, prefixWithoutIndices, withForwardRef } from "../helpers";
|
||||
import classNames from "classnames";
|
||||
import ChipInputField from "./ChipInputField";
|
||||
import { Option } from "@scm-manager/ui-types";
|
||||
@@ -41,27 +41,31 @@ type Props<T extends Record<string, unknown>> = Omit<
|
||||
defaultValue?: string[];
|
||||
createDeleteText?: (value: string) => string;
|
||||
optionFactory?: (val: any) => Option<unknown>;
|
||||
ref?: React.ForwardedRef<HTMLInputElement>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @beta
|
||||
* @since 2.44.0
|
||||
*/
|
||||
function ControlledChipInputField<T extends Record<string, unknown>>({
|
||||
name,
|
||||
label,
|
||||
helpText,
|
||||
rules,
|
||||
testId,
|
||||
defaultValue,
|
||||
readOnly,
|
||||
placeholder,
|
||||
className,
|
||||
createDeleteText,
|
||||
children,
|
||||
optionFactory = defaultOptionFactory,
|
||||
...props
|
||||
}: Props<T>) {
|
||||
function ControlledChipInputField<T extends Record<string, unknown>>(
|
||||
{
|
||||
name,
|
||||
label,
|
||||
helpText,
|
||||
rules,
|
||||
testId,
|
||||
defaultValue,
|
||||
readOnly,
|
||||
placeholder,
|
||||
className,
|
||||
createDeleteText,
|
||||
children,
|
||||
optionFactory = defaultOptionFactory,
|
||||
...props
|
||||
}: Props<T>,
|
||||
ref: React.ForwardedRef<HTMLInputElement>
|
||||
) {
|
||||
const { control, t, readOnly: formReadonly } = useScmFormContext();
|
||||
const formPathPrefix = useScmFormPathContext();
|
||||
|
||||
@@ -95,6 +99,7 @@ function ControlledChipInputField<T extends Record<string, unknown>>({
|
||||
: undefined
|
||||
}
|
||||
testId={testId ?? `input-${nameWithPrefix}`}
|
||||
ref={ref}
|
||||
>
|
||||
{children}
|
||||
</ChipInputField>
|
||||
@@ -103,4 +108,4 @@ function ControlledChipInputField<T extends Record<string, unknown>>({
|
||||
);
|
||||
}
|
||||
|
||||
export default ControlledChipInputField;
|
||||
export default withForwardRef(ControlledChipInputField);
|
||||
|
||||
Reference in New Issue
Block a user