tycho-components 0.0.10-SNAPSHOT-2 → 0.0.10-SNAPSHOT-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.
@@ -85,6 +85,8 @@ export default function AppEditable({ translation, fields, item, save, group, cl
85
85
  return (_jsx(EasyEdit, { type: "password", onSave: (v) => handleSave(v, field), value: value, ...sharedEditProps }));
86
86
  case 'color':
87
87
  return (_jsx(AppColorpicker, { item: item, field: field, handleSave: handleSave }));
88
+ case 'function':
89
+ return _jsx("span", { children: field.fn ? field.fn(getValue(field)) : '' });
88
90
  default:
89
91
  return null;
90
92
  }
@@ -10,5 +10,6 @@ export default interface FormField {
10
10
  tooltip?: string;
11
11
  default?: string | boolean | number;
12
12
  role?: string;
13
+ fn?: (value: any) => string;
13
14
  }
14
15
  export declare const validateFormField: (entity: Record<string, unknown>, fields: FormField[]) => FormField[];
@@ -1,7 +1,8 @@
1
1
  export type FieldValue = string | number | boolean | Date | null;
2
- export default interface FormFieldOption {
2
+ type FormFieldOption = {
3
3
  label: string;
4
4
  value: FieldValue;
5
- }
6
- export declare const convertEnum: (values: Record<string, string | number | boolean>) => FormFieldOption[];
5
+ };
6
+ export declare const convertEnum: (values: any, skipEmpty?: boolean) => FormFieldOption[];
7
7
  export declare const convertList: (values: Array<Record<string, unknown>>, keyAttr: string, valueAttr: string) => FormFieldOption[];
8
+ export default FormFieldOption;
@@ -1,7 +1,10 @@
1
- export const convertEnum = (values) => {
2
- let fields = [{ label: '', value: '' }];
3
- Object.keys(values).forEach((key) => {
4
- fields = [...fields, { label: String(values[key]), value: key }];
1
+ export const convertEnum = (values, skipEmpty) => {
2
+ const fields = [];
3
+ if (!skipEmpty) {
4
+ fields.push({ label: '', value: '' });
5
+ }
6
+ Object.keys(values).map((key, idx) => {
7
+ fields.push({ label: values[key], value: key });
5
8
  });
6
9
  return fields;
7
10
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.0.10-SNAPSHOT-2",
4
+ "version": "0.0.10-SNAPSHOT-4",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {