tycho-components 0.12.2 → 0.12.4
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.
package/dist/AppForm/AppForm.js
CHANGED
|
@@ -23,7 +23,7 @@ export default function AppForm({ fields, form, prefix, onChangeFunctions = {},
|
|
|
23
23
|
const handleChange = getOnChangeFn(field.attr);
|
|
24
24
|
if (field.type === 'select') {
|
|
25
25
|
const selectOptions = getOptions(field.attr) || field.options || [];
|
|
26
|
-
return (_jsx(SelectField, { attr: name, label: field.name, createdForm: form, options: selectOptions, disabled: field.disabled, required: field.required, onChange: (value) => handleChange?.(value), multiple: field.multiple }, name));
|
|
26
|
+
return (_jsx(SelectField, { attr: name, label: field.name, createdForm: form, options: selectOptions, disabled: field.disabled, required: field.required, onChange: (value) => handleChange?.(value), multiple: field.multiple, showEndAdornment: false }, name));
|
|
27
27
|
}
|
|
28
28
|
if (field.type === 'check') {
|
|
29
29
|
return (_jsx(CheckboxField, { attr: name, label: field.name, createdForm: form, disabled: field.disabled }, name));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
2
|
import { SelectItem } from 'tycho-storybook/dist/SelectField/SelectField';
|
|
3
|
+
import { AppFormField } from '../AppForm/AppFormField';
|
|
3
4
|
declare const FormUtils: {
|
|
4
5
|
convertEnum: (values: Record<string, string>, t?: TFunction, prefix?: string) => SelectItem[];
|
|
5
6
|
convertList: (values: any, labelAttr: string, valueAttr: string) => SelectItem[];
|
|
@@ -7,5 +8,6 @@ declare const FormUtils: {
|
|
|
7
8
|
booleanOptions: (t: TFunction) => SelectItem[];
|
|
8
9
|
convertMap: (values: Record<string, any> | undefined) => SelectItem[];
|
|
9
10
|
sortByLabel: (items: SelectItem[]) => SelectItem[];
|
|
11
|
+
filterFieldsByUserRole: (fields: AppFormField[], hasRole: (role: string) => boolean) => AppFormField[];
|
|
10
12
|
};
|
|
11
13
|
export default FormUtils;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const filterFieldsByUserRole = (fields, hasRole) => fields.filter((field) => !field.role || hasRole(field.role));
|
|
1
2
|
const convertEnum = (values, t, prefix) => {
|
|
2
3
|
if (!t)
|
|
3
4
|
return Object.entries(values).map(([key, label]) => ({
|
|
@@ -52,5 +53,6 @@ const FormUtils = {
|
|
|
52
53
|
booleanOptions,
|
|
53
54
|
convertMap,
|
|
54
55
|
sortByLabel,
|
|
56
|
+
filterFieldsByUserRole,
|
|
55
57
|
};
|
|
56
58
|
export default FormUtils;
|