tycho-components 0.21.3 → 0.21.5
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { SelectItem } from 'tycho-storybook';
|
|
2
3
|
import { AppFormField } from './AppFormField';
|
|
3
4
|
import './style.scss';
|
|
4
5
|
type Props = {
|
|
@@ -8,7 +9,8 @@ type Props = {
|
|
|
8
9
|
onChangeFunctions?: Record<string, (v: string | number | boolean) => void>;
|
|
9
10
|
onBlurFunctions?: Record<string, () => void>;
|
|
10
11
|
runtimeOptions?: Record<string, any[]>;
|
|
12
|
+
runtimeLoadOptions?: Record<string, (query: string) => Promise<SelectItem[]>>;
|
|
11
13
|
twoColumns?: boolean;
|
|
12
14
|
};
|
|
13
|
-
export default function AppForm({ fields, form, prefix, onChangeFunctions, onBlurFunctions, runtimeOptions, twoColumns, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default function AppForm({ fields, form, prefix, onChangeFunctions, onBlurFunctions, runtimeOptions, runtimeLoadOptions, twoColumns, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
14
16
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { CheckboxField, DatePickerField, SelectField, SwitchField, TextField, } from 'tycho-storybook';
|
|
2
|
+
import { AsyncSelectField, CheckboxField, DatePickerField, SelectField, SwitchField, TextField, } from 'tycho-storybook';
|
|
3
3
|
import './style.scss';
|
|
4
4
|
const convertList = (values, labelAttr, valueAttr) => {
|
|
5
5
|
if (!values)
|
|
@@ -10,7 +10,7 @@ const convertList = (values, labelAttr, valueAttr) => {
|
|
|
10
10
|
});
|
|
11
11
|
return fields;
|
|
12
12
|
};
|
|
13
|
-
export default function AppForm({ fields, form, prefix, onChangeFunctions = {}, onBlurFunctions = {}, runtimeOptions = {}, twoColumns = false, }) {
|
|
13
|
+
export default function AppForm({ fields, form, prefix, onChangeFunctions = {}, onBlurFunctions = {}, runtimeOptions = {}, runtimeLoadOptions = {}, twoColumns = false, }) {
|
|
14
14
|
const getOnChangeFn = (attr) => onChangeFunctions[attr];
|
|
15
15
|
const getOnBlurFn = (attr) => onBlurFunctions[attr];
|
|
16
16
|
const getOptions = (attr) => {
|
|
@@ -21,6 +21,12 @@ export default function AppForm({ fields, form, prefix, onChangeFunctions = {},
|
|
|
21
21
|
return (_jsx("div", { className: `app-form-container ${twoColumns ? 'two-columns' : ''}`, children: fields.map((field) => {
|
|
22
22
|
const name = prefix ? `${prefix}.${field.attr}` : field.attr;
|
|
23
23
|
const handleChange = getOnChangeFn(field.attr);
|
|
24
|
+
if (field.type === 'autocomplete') {
|
|
25
|
+
const loadOptions = runtimeLoadOptions[field.attr];
|
|
26
|
+
if (!loadOptions)
|
|
27
|
+
return null;
|
|
28
|
+
return (_jsx(AsyncSelectField, { attr: name, label: field.name, createdForm: form, disabled: field.disabled, required: field.required, multiple: field.multiple, freeSolo: field.freeSolo, loadOptions: loadOptions, placeholder: field.title, noOptionsText: field.translation, onChange: (_attr, value) => handleChange?.(value) }, name));
|
|
29
|
+
}
|
|
24
30
|
if (field.type === 'select') {
|
|
25
31
|
const selectOptions = getOptions(field.attr) || field.options || [];
|
|
26
32
|
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));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycho-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.21.
|
|
4
|
+
"version": "0.21.5",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -51,10 +51,14 @@
|
|
|
51
51
|
"classnames": "^2.5.1",
|
|
52
52
|
"cytoscape": "^3.28.1",
|
|
53
53
|
"cytoscape-node-html-label": "^1.2.2",
|
|
54
|
+
"date-fns": "^4.1.0",
|
|
55
|
+
"date-fns-tz": "^3.2.0",
|
|
54
56
|
"file-saver": "^2.0.5",
|
|
55
57
|
"html2canvas": "^1.4.1",
|
|
56
58
|
"js-cookie": "^3.0.5",
|
|
57
59
|
"react-colorful": "^5.6.1",
|
|
60
|
+
"react-draggable": "^4.4.6",
|
|
61
|
+
"react-dropzone": "^14.3.5",
|
|
58
62
|
"react-easy-edit": "^2.0.0",
|
|
59
63
|
"react-loading": "^2.0.3",
|
|
60
64
|
"react-simple-keyboard": "^3.8.66",
|
|
@@ -74,7 +78,7 @@
|
|
|
74
78
|
"react-i18next": "^13.0.2",
|
|
75
79
|
"react-router-dom": "^6.14.2",
|
|
76
80
|
"react-toastify": "^9.1.3",
|
|
77
|
-
"tycho-storybook": "0.
|
|
81
|
+
"tycho-storybook": "0.8.1",
|
|
78
82
|
"wavesurfer-react": "^2.2.2",
|
|
79
83
|
"wavesurfer.js": "^6.6.3",
|
|
80
84
|
"yup": "^1.2.0"
|