nurseitaly-components 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,6 +16,8 @@ type Props<TFieldValues extends FieldValues = FieldValues, TContext = any, TTran
|
|
|
16
16
|
placeholder?: string;
|
|
17
17
|
options: SelectItem[];
|
|
18
18
|
required?: boolean;
|
|
19
|
+
/** When false, the empty/placeholder option is not rendered. Defaults to true. */
|
|
20
|
+
allowEmpty?: boolean;
|
|
19
21
|
showEndAdornment?: boolean;
|
|
20
22
|
endAdornment?: ReactNode[];
|
|
21
23
|
defaultEndAdornments?: DefaultEndAdornmentType[];
|
|
@@ -23,5 +25,5 @@ type Props<TFieldValues extends FieldValues = FieldValues, TContext = any, TTran
|
|
|
23
25
|
onChange?: (attr: string, value: any) => void;
|
|
24
26
|
infoText?: string;
|
|
25
27
|
};
|
|
26
|
-
export default function SelectField<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>({ className, attr, label, createdForm, disabled, title, placeholder, options, required, endAdornment, defaultEndAdornments, showEndAdornment, onRemove, onChange, infoText, }: Props<TFieldValues, TContext, TTransformedValues>): import("react").JSX.Element;
|
|
28
|
+
export default function SelectField<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>({ className, attr, label, createdForm, disabled, title, placeholder, options, required, allowEmpty, endAdornment, defaultEndAdornments, showEndAdornment, onRemove, onChange, infoText, }: Props<TFieldValues, TContext, TTransformedValues>): import("react").JSX.Element;
|
|
27
29
|
export {};
|
|
@@ -9,7 +9,7 @@ import Icon from '../Icon';
|
|
|
9
9
|
import Tooltip from '../Tooltip';
|
|
10
10
|
import { selectFieldTheme } from './SelectFieldTheme';
|
|
11
11
|
import './styles.scss';
|
|
12
|
-
export default function SelectField({ className, attr, label, createdForm, disabled, title, placeholder, options = [], required, endAdornment, defaultEndAdornments = ['close'], showEndAdornment = true, onRemove, onChange, infoText, }) {
|
|
12
|
+
export default function SelectField({ className, attr, label, createdForm, disabled, title, placeholder, options = [], required, allowEmpty = true, endAdornment, defaultEndAdornments = ['close'], showEndAdornment = true, onRemove, onChange, infoText, }) {
|
|
13
13
|
const fieldName = attr;
|
|
14
14
|
const outerTheme = useTheme();
|
|
15
15
|
const [active, setActive] = useState(false);
|
|
@@ -77,5 +77,5 @@ export default function SelectField({ className, attr, label, createdForm, disab
|
|
|
77
77
|
backgroundColor: disabled
|
|
78
78
|
? '#BEBFC1!important'
|
|
79
79
|
: '#FFFFFF!important',
|
|
80
|
-
} }), children: [_jsx("option", { value: "", children: placeholder || '\u00a0' }), options.map((option, idx) => (_jsx("option", { value: option.value, children: option.label }, idx.valueOf())))] })] }), title && !hasError() && _jsx("div", { className: "helper", children: title }), hasError() && (_jsx("div", { className: "helper error", children: String(createdForm.formState.errors[attr]?.message) }))] })) }) }));
|
|
80
|
+
} }), children: [allowEmpty && (_jsx("option", { value: "", children: placeholder || '\u00a0' })), options.map((option, idx) => (_jsx("option", { value: option.value, children: option.label }, idx.valueOf())))] })] }), title && !hasError() && _jsx("div", { className: "helper", children: title }), hasError() && (_jsx("div", { className: "helper error", children: String(createdForm.formState.errors[attr]?.message) }))] })) }) }));
|
|
81
81
|
}
|
|
@@ -44,7 +44,7 @@ export default function AppForm({ fields, form, prefix, onChangeFunctions = {},
|
|
|
44
44
|
if (field.multiple) {
|
|
45
45
|
return _jsx(SelectMultipleField, { ...selectProps }, name);
|
|
46
46
|
}
|
|
47
|
-
return _jsx(SelectField, { ...selectProps }, name);
|
|
47
|
+
return (_jsx(SelectField, { ...selectProps, allowEmpty: field.allowEmpty }, name));
|
|
48
48
|
}
|
|
49
49
|
if (field.type === "check") {
|
|
50
50
|
return (_jsx(CheckboxField, { attr: name, label: field.name, createdForm: form, disabled: field.disabled }, name));
|
|
@@ -34,6 +34,7 @@ export type AppFormField = {
|
|
|
34
34
|
display?: DisplayFunction;
|
|
35
35
|
copyToClipboard?: boolean;
|
|
36
36
|
truncate?: number;
|
|
37
|
+
allowEmpty?: boolean;
|
|
37
38
|
/** Flex-grow weight when sharing a row with adjacent flex fields. Omit for full-width. */
|
|
38
39
|
flexGrow?: number;
|
|
39
40
|
/** Optional flex-basis (default: 0 for even ratio distribution). */
|