@uxf/form 11.74.0 → 11.74.1
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/_code-generator/form-code-generator.d.ts +16 -0
- package/_code-generator/form-code-generator.js +69 -0
- package/avatar-file-input/avatar-file-input.d.ts +14 -0
- package/avatar-file-input/avatar-file-input.js +42 -0
- package/avatar-file-input/avatar-file-input.stories.d.ts +8 -0
- package/avatar-file-input/avatar-file-input.stories.js +23 -0
- package/avatar-file-input/index.d.ts +1 -0
- package/avatar-file-input/index.js +17 -0
- package/avatar-file-input/translations.d.ts +13 -0
- package/avatar-file-input/translations.js +14 -0
- package/bin/form-code-generator.d.ts +2 -0
- package/bin/form-code-generator.js +55 -0
- package/checkbox-button/checkbox-button.d.ts +14 -0
- package/checkbox-button/checkbox-button.js +42 -0
- package/checkbox-button/checkbox-button.stories.d.ts +8 -0
- package/checkbox-button/checkbox-button.stories.js +24 -0
- package/checkbox-button/index.d.ts +1 -0
- package/checkbox-button/index.js +17 -0
- package/checkbox-button/translations.d.ts +13 -0
- package/checkbox-button/translations.js +14 -0
- package/checkbox-input/checkbox-input.d.ts +14 -0
- package/checkbox-input/checkbox-input.js +42 -0
- package/checkbox-input/checkbox-input.stories.d.ts +8 -0
- package/checkbox-input/checkbox-input.stories.js +24 -0
- package/checkbox-input/index.d.ts +1 -0
- package/checkbox-input/index.js +17 -0
- package/checkbox-input/translations.d.ts +13 -0
- package/checkbox-input/translations.js +14 -0
- package/checkbox-list/checkbox-list.d.ts +19 -0
- package/checkbox-list/checkbox-list.js +40 -0
- package/checkbox-list/checkbox-list.stories.d.ts +2 -0
- package/checkbox-list/checkbox-list.stories.js +22 -0
- package/checkbox-list/index.d.ts +1 -0
- package/checkbox-list/index.js +17 -0
- package/checkbox-list/translations.d.ts +13 -0
- package/checkbox-list/translations.js +14 -0
- package/color-radio-group/color-radio-group.d.ts +13 -0
- package/color-radio-group/color-radio-group.js +42 -0
- package/color-radio-group/color-radio-group.stories.d.ts +8 -0
- package/color-radio-group/color-radio-group.stories.js +62 -0
- package/color-radio-group/index.d.ts +1 -0
- package/color-radio-group/index.js +17 -0
- package/color-radio-group/translations.d.ts +13 -0
- package/color-radio-group/translations.js +14 -0
- package/combobox/combobox.d.ts +13 -0
- package/combobox/combobox.js +48 -0
- package/combobox/combobox.stories.d.ts +8 -0
- package/combobox/combobox.stories.js +30 -0
- package/combobox/index.d.ts +1 -0
- package/combobox/index.js +17 -0
- package/combobox/translations.d.ts +13 -0
- package/combobox/translations.js +14 -0
- package/components.d.ts +127 -0
- package/components.js +154 -0
- package/date-picker-input/date-picker-input.d.ts +15 -0
- package/date-picker-input/date-picker-input.js +102 -0
- package/date-picker-input/date-picker-input.stories.d.ts +8 -0
- package/date-picker-input/date-picker-input.stories.js +31 -0
- package/date-picker-input/index.d.ts +1 -0
- package/date-picker-input/index.js +17 -0
- package/date-picker-input/translations.d.ts +31 -0
- package/date-picker-input/translations.js +32 -0
- package/date-range-picker-input/date-range-picker-input.d.ts +12 -0
- package/date-range-picker-input/date-range-picker-input.js +115 -0
- package/date-range-picker-input/date-range-picker-input.stories.d.ts +8 -0
- package/date-range-picker-input/date-range-picker-input.stories.js +25 -0
- package/date-range-picker-input/index.d.ts +1 -0
- package/date-range-picker-input/index.js +17 -0
- package/date-range-picker-input/translations.d.ts +25 -0
- package/date-range-picker-input/translations.js +26 -0
- package/datetime-picker-input/datetime-picker-input.d.ts +15 -0
- package/datetime-picker-input/datetime-picker-input.js +103 -0
- package/datetime-picker-input/datetime-picker-input.stories.d.ts +2 -0
- package/datetime-picker-input/datetime-picker-input.stories.js +28 -0
- package/datetime-picker-input/index.d.ts +1 -0
- package/datetime-picker-input/index.js +17 -0
- package/datetime-picker-input/translations.d.ts +31 -0
- package/datetime-picker-input/translations.js +32 -0
- package/dropzone/dropzone-input.d.ts +13 -0
- package/dropzone/dropzone-input.js +67 -0
- package/dropzone/dropzone-list.d.ts +11 -0
- package/dropzone/dropzone-list.js +23 -0
- package/dropzone/dropzone.stories.d.ts +2 -0
- package/dropzone/dropzone.stories.js +50 -0
- package/dropzone/index.d.ts +9 -0
- package/dropzone/index.js +6 -0
- package/dropzone/translations.d.ts +31 -0
- package/dropzone/translations.js +32 -0
- package/file-input/file-input.d.ts +14 -0
- package/file-input/file-input.js +42 -0
- package/file-input/file-input.stories.d.ts +8 -0
- package/file-input/file-input.stories.js +31 -0
- package/file-input/index.d.ts +1 -0
- package/file-input/index.js +17 -0
- package/file-input/translations.d.ts +13 -0
- package/file-input/translations.js +14 -0
- package/form/form.d.ts +19 -0
- package/form/form.js +25 -0
- package/form/form.stories.d.ts +8 -0
- package/form/form.stories.js +24 -0
- package/form/index.d.ts +1 -0
- package/form/index.js +17 -0
- package/form-id-context/form-context.d.ts +7 -0
- package/form-id-context/form-context.js +12 -0
- package/form-id-context/form-id-context.d.ts +2 -0
- package/form-id-context/form-id-context.js +7 -0
- package/form-id-context/index.d.ts +1 -0
- package/form-id-context/index.js +17 -0
- package/form-renderer/big-test-schema.d.ts +33 -0
- package/form-renderer/big-test-schema.js +295 -0
- package/form-renderer/field/base-field.d.ts +4 -0
- package/form-renderer/field/base-field.js +72 -0
- package/form-renderer/field/embedded.d.ts +4 -0
- package/form-renderer/field/embedded.js +19 -0
- package/form-renderer/field/one-to-many.d.ts +4 -0
- package/form-renderer/field/one-to-many.js +52 -0
- package/form-renderer/form-renderer.d.ts +16 -0
- package/form-renderer/form-renderer.js +28 -0
- package/form-renderer/form-renderer.stories.d.ts +2 -0
- package/form-renderer/form-renderer.stories.js +23 -0
- package/form-renderer/index.d.ts +2 -0
- package/form-renderer/index.js +18 -0
- package/form-renderer/mapper.d.ts +2 -0
- package/form-renderer/mapper.js +30 -0
- package/form-renderer/translations.d.ts +33 -0
- package/form-renderer/translations.js +34 -0
- package/form-renderer/types.d.ts +39 -0
- package/form-renderer/types.js +2 -0
- package/gps-input/gps-input.d.ts +20 -0
- package/gps-input/gps-input.js +156 -0
- package/gps-input/gps-input.stories.d.ts +8 -0
- package/gps-input/gps-input.stories.js +22 -0
- package/gps-input/index.d.ts +1 -0
- package/gps-input/index.js +17 -0
- package/gps-input/translations.d.ts +31 -0
- package/gps-input/translations.js +32 -0
- package/money-input/index.d.ts +1 -0
- package/money-input/index.js +17 -0
- package/money-input/money-input.d.ts +24 -0
- package/money-input/money-input.js +112 -0
- package/money-input/money-input.stories.d.ts +2 -0
- package/money-input/money-input.stories.js +15 -0
- package/money-input/translations.d.ts +13 -0
- package/money-input/translations.js +14 -0
- package/multi-combobox/index.d.ts +1 -0
- package/multi-combobox/index.js +17 -0
- package/multi-combobox/multi-combobox.d.ts +13 -0
- package/multi-combobox/multi-combobox.js +48 -0
- package/multi-combobox/multi-combobox.stories.d.ts +8 -0
- package/multi-combobox/multi-combobox.stories.js +54 -0
- package/multi-combobox/translations.d.ts +13 -0
- package/multi-combobox/translations.js +14 -0
- package/multi-select/index.d.ts +1 -0
- package/multi-select/index.js +17 -0
- package/multi-select/multi-select.d.ts +13 -0
- package/multi-select/multi-select.js +43 -0
- package/multi-select/multi-select.stories.d.ts +8 -0
- package/multi-select/multi-select.stories.js +47 -0
- package/multi-select/translations.d.ts +13 -0
- package/multi-select/translations.js +14 -0
- package/number-input/index.d.ts +1 -0
- package/number-input/index.js +17 -0
- package/number-input/number-input.d.ts +17 -0
- package/number-input/number-input.js +87 -0
- package/number-input/number-input.stories.d.ts +8 -0
- package/number-input/number-input.stories.js +24 -0
- package/number-input/translations.d.ts +25 -0
- package/number-input/translations.js +26 -0
- package/package.json +3 -3
- package/password-input/index.d.ts +1 -0
- package/password-input/index.js +17 -0
- package/password-input/password-input.d.ts +15 -0
- package/password-input/password-input.js +108 -0
- package/password-input/password-input.stories.d.ts +8 -0
- package/password-input/password-input.stories.js +23 -0
- package/password-input/translations.d.ts +19 -0
- package/password-input/translations.js +20 -0
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.js +17 -0
- package/radio-group/radio-group.d.ts +13 -0
- package/radio-group/radio-group.js +42 -0
- package/radio-group/radio-group.stories.d.ts +8 -0
- package/radio-group/radio-group.stories.js +38 -0
- package/radio-group/translations.d.ts +13 -0
- package/radio-group/translations.js +14 -0
- package/readmes.d.ts +28 -0
- package/readmes.js +59 -0
- package/select/index.d.ts +1 -0
- package/select/index.js +17 -0
- package/select/select.d.ts +13 -0
- package/select/select.js +41 -0
- package/select/select.stories.d.ts +8 -0
- package/select/select.stories.js +44 -0
- package/select/translations.d.ts +13 -0
- package/select/translations.js +14 -0
- package/storybook/form-data-printer.d.ts +6 -0
- package/storybook/form-data-printer.js +12 -0
- package/storybook/storybook-form.d.ts +8 -0
- package/storybook/storybook-form.js +42 -0
- package/text-input/index.d.ts +1 -0
- package/text-input/index.js +17 -0
- package/text-input/text-input.d.ts +33 -0
- package/text-input/text-input.js +75 -0
- package/text-input/text-input.stories.d.ts +8 -0
- package/text-input/text-input.stories.js +26 -0
- package/text-input/translations.d.ts +31 -0
- package/text-input/translations.js +32 -0
- package/textarea/index.d.ts +1 -0
- package/textarea/index.js +17 -0
- package/textarea/textarea.d.ts +13 -0
- package/textarea/textarea.js +62 -0
- package/textarea/textarea.stories.d.ts +8 -0
- package/textarea/textarea.stories.js +22 -0
- package/textarea/translations.d.ts +13 -0
- package/textarea/translations.js +14 -0
- package/time-picker-input/index.d.ts +1 -0
- package/time-picker-input/index.js +17 -0
- package/time-picker-input/time-picker-input.d.ts +14 -0
- package/time-picker-input/time-picker-input.js +84 -0
- package/time-picker-input/time-picker-input.stories.d.ts +8 -0
- package/time-picker-input/time-picker-input.stories.js +25 -0
- package/time-picker-input/translations.d.ts +19 -0
- package/time-picker-input/translations.js +20 -0
- package/toggle/index.d.ts +1 -0
- package/toggle/index.js +17 -0
- package/toggle/toggle.d.ts +14 -0
- package/toggle/toggle.js +40 -0
- package/toggle/toggle.stories.d.ts +8 -0
- package/toggle/toggle.stories.js +23 -0
- package/toggle/translations.d.ts +13 -0
- package/toggle/translations.js +14 -0
- package/types.d.ts +4 -0
- package/types.js +2 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
"uxf-form-file-input": {
|
|
5
|
+
validation: {
|
|
6
|
+
required: {
|
|
7
|
+
cs: "Toto pole je povinné",
|
|
8
|
+
en: "This field is required",
|
|
9
|
+
sk: "Toto pole je povinné",
|
|
10
|
+
de: "Dieses Feld ist erforderlich",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
package/form/form.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { ReactNode, Ref } from "react";
|
|
2
|
+
import { FieldValues, SubmitErrorHandler, SubmitHandler, UseFormReturn } from "react-hook-form";
|
|
3
|
+
export type FormProps<TFieldValues extends FieldValues> = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
formApi: UseFormReturn<TFieldValues>;
|
|
7
|
+
forwardRef?: Ref<HTMLFormElement> | undefined;
|
|
8
|
+
id: string;
|
|
9
|
+
method?: "get" | "post";
|
|
10
|
+
onError?: SubmitErrorHandler<TFieldValues>;
|
|
11
|
+
onSubmit: SubmitHandler<TFieldValues>;
|
|
12
|
+
shouldOmitSubmitInput?: boolean;
|
|
13
|
+
isDisabled?: boolean;
|
|
14
|
+
isReadOnly?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function Form<TFieldValues extends FieldValues = FieldValues>(props: FormProps<TFieldValues>): React.JSX.Element;
|
|
17
|
+
export declare namespace Form {
|
|
18
|
+
var displayName: string;
|
|
19
|
+
}
|
package/form/form.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Form = Form;
|
|
8
|
+
const sr_only_1 = require("@uxf/styles/mixins/sr-only");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
11
|
+
const form_context_1 = require("../form-id-context/form-context");
|
|
12
|
+
function Form(props) {
|
|
13
|
+
var _a;
|
|
14
|
+
const context = {
|
|
15
|
+
formId: props.id,
|
|
16
|
+
isFormDisabled: Boolean(props.isDisabled),
|
|
17
|
+
isFormReadOnly: Boolean(props.isReadOnly),
|
|
18
|
+
};
|
|
19
|
+
return (react_1.default.createElement(form_context_1.FormContextProvider, { value: context },
|
|
20
|
+
react_1.default.createElement(react_hook_form_1.FormProvider, { ...props.formApi },
|
|
21
|
+
react_1.default.createElement("form", { className: props.className, id: props.id, method: (_a = props.method) !== null && _a !== void 0 ? _a : "post", noValidate: true, onSubmit: props.formApi.handleSubmit(props.onSubmit, props.onError), ref: props.forwardRef },
|
|
22
|
+
props.children,
|
|
23
|
+
!props.shouldOmitSubmitInput && react_1.default.createElement("input", { style: sr_only_1.srOnly, type: "submit" })))));
|
|
24
|
+
}
|
|
25
|
+
Form.displayName = "UxfForm";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Default = Default;
|
|
7
|
+
const button_1 = require("@uxf/ui/button");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
+
const text_input_1 = require("../text-input");
|
|
11
|
+
const form_1 = require("./form");
|
|
12
|
+
exports.default = {
|
|
13
|
+
title: "Form/Form",
|
|
14
|
+
component: form_1.Form,
|
|
15
|
+
};
|
|
16
|
+
function Default() {
|
|
17
|
+
const formApi = (0, react_hook_form_1.useForm)();
|
|
18
|
+
return (
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
react_1.default.createElement(form_1.Form, { formApi: formApi, id: "form", onSubmit: console.log },
|
|
21
|
+
react_1.default.createElement("div", { className: "mb-4 space-y-4 p-4" },
|
|
22
|
+
react_1.default.createElement(text_input_1.TextInput, { control: formApi.control, isRequired: true, label: "Default input", name: "default" }),
|
|
23
|
+
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit"))));
|
|
24
|
+
}
|
package/form/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./form";
|
package/form/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./form"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormContext = exports.FormContextProvider = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const FormContext = (0, react_1.createContext)({
|
|
6
|
+
formId: "",
|
|
7
|
+
isFormDisabled: false,
|
|
8
|
+
isFormReadOnly: false,
|
|
9
|
+
});
|
|
10
|
+
exports.FormContextProvider = FormContext.Provider;
|
|
11
|
+
const useFormContext = () => (0, react_1.useContext)(FormContext);
|
|
12
|
+
exports.useFormContext = useFormContext;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormIdContext = void 0;
|
|
4
|
+
const form_context_1 = require("./form-context");
|
|
5
|
+
/** @deprecated use useFormContext().formId */
|
|
6
|
+
const useFormIdContext = () => (0, form_context_1.useFormContext)().formId;
|
|
7
|
+
exports.useFormIdContext = useFormIdContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./form-id-context";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./form-id-context"), exports);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const schema: {
|
|
2
|
+
fields: ({
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
label: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
readOnly: boolean;
|
|
8
|
+
editable: boolean;
|
|
9
|
+
autocomplete: string;
|
|
10
|
+
options: null;
|
|
11
|
+
fields: never[];
|
|
12
|
+
} | {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
label: string;
|
|
16
|
+
required: boolean;
|
|
17
|
+
readOnly: boolean;
|
|
18
|
+
editable: boolean;
|
|
19
|
+
autocomplete: null;
|
|
20
|
+
options: null;
|
|
21
|
+
fields: {
|
|
22
|
+
name: string;
|
|
23
|
+
type: string;
|
|
24
|
+
label: string;
|
|
25
|
+
required: boolean;
|
|
26
|
+
readOnly: boolean;
|
|
27
|
+
editable: boolean;
|
|
28
|
+
autocomplete: null;
|
|
29
|
+
options: null;
|
|
30
|
+
fields: never[];
|
|
31
|
+
}[];
|
|
32
|
+
})[];
|
|
33
|
+
};
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = void 0;
|
|
4
|
+
exports.schema = {
|
|
5
|
+
fields: [
|
|
6
|
+
{
|
|
7
|
+
name: "id",
|
|
8
|
+
type: "integer",
|
|
9
|
+
label: "Id",
|
|
10
|
+
required: true,
|
|
11
|
+
readOnly: true,
|
|
12
|
+
editable: true,
|
|
13
|
+
autocomplete: null,
|
|
14
|
+
options: null,
|
|
15
|
+
fields: [],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "textRequired",
|
|
19
|
+
type: "string",
|
|
20
|
+
label: "Text required",
|
|
21
|
+
required: true,
|
|
22
|
+
readOnly: false,
|
|
23
|
+
editable: true,
|
|
24
|
+
autocomplete: null,
|
|
25
|
+
options: null,
|
|
26
|
+
fields: [],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "textNotRequired",
|
|
30
|
+
type: "string",
|
|
31
|
+
label: "Text optional",
|
|
32
|
+
required: false,
|
|
33
|
+
readOnly: false,
|
|
34
|
+
editable: true,
|
|
35
|
+
autocomplete: null,
|
|
36
|
+
options: null,
|
|
37
|
+
fields: [],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "longTextRequired",
|
|
41
|
+
type: "text",
|
|
42
|
+
label: "LongText required",
|
|
43
|
+
required: true,
|
|
44
|
+
readOnly: false,
|
|
45
|
+
editable: true,
|
|
46
|
+
autocomplete: null,
|
|
47
|
+
options: null,
|
|
48
|
+
fields: [],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "longTextNotRequired",
|
|
52
|
+
type: "text",
|
|
53
|
+
label: "LongText optional",
|
|
54
|
+
required: false,
|
|
55
|
+
readOnly: false,
|
|
56
|
+
editable: true,
|
|
57
|
+
autocomplete: null,
|
|
58
|
+
options: null,
|
|
59
|
+
fields: [],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "imageNotRequired",
|
|
63
|
+
type: "image",
|
|
64
|
+
label: "Image optional",
|
|
65
|
+
required: false,
|
|
66
|
+
readOnly: false,
|
|
67
|
+
editable: true,
|
|
68
|
+
autocomplete: null,
|
|
69
|
+
options: null,
|
|
70
|
+
fields: [],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "fileNotRequired",
|
|
74
|
+
type: "file",
|
|
75
|
+
label: "File optional",
|
|
76
|
+
required: false,
|
|
77
|
+
readOnly: false,
|
|
78
|
+
editable: true,
|
|
79
|
+
autocomplete: null,
|
|
80
|
+
options: null,
|
|
81
|
+
fields: [],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "images",
|
|
85
|
+
type: "images",
|
|
86
|
+
label: "Images",
|
|
87
|
+
required: false,
|
|
88
|
+
readOnly: false,
|
|
89
|
+
editable: true,
|
|
90
|
+
autocomplete: null,
|
|
91
|
+
options: null,
|
|
92
|
+
fields: [],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "dateRequired",
|
|
96
|
+
type: "date",
|
|
97
|
+
label: "Date required",
|
|
98
|
+
required: true,
|
|
99
|
+
readOnly: false,
|
|
100
|
+
editable: true,
|
|
101
|
+
autocomplete: null,
|
|
102
|
+
options: null,
|
|
103
|
+
fields: [],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "dateNotRequired",
|
|
107
|
+
type: "date",
|
|
108
|
+
label: "Date optional",
|
|
109
|
+
required: false,
|
|
110
|
+
readOnly: false,
|
|
111
|
+
editable: true,
|
|
112
|
+
autocomplete: null,
|
|
113
|
+
options: null,
|
|
114
|
+
fields: [],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "dateTimeRequired",
|
|
118
|
+
type: "datetime",
|
|
119
|
+
label: "DateTime required",
|
|
120
|
+
required: true,
|
|
121
|
+
readOnly: false,
|
|
122
|
+
editable: true,
|
|
123
|
+
autocomplete: null,
|
|
124
|
+
options: null,
|
|
125
|
+
fields: [],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "dateTimeNotRequired",
|
|
129
|
+
type: "datetime",
|
|
130
|
+
label: "DateTime optional",
|
|
131
|
+
required: false,
|
|
132
|
+
readOnly: false,
|
|
133
|
+
editable: true,
|
|
134
|
+
autocomplete: null,
|
|
135
|
+
options: null,
|
|
136
|
+
fields: [],
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "timeRequired",
|
|
140
|
+
type: "time",
|
|
141
|
+
label: "Time required",
|
|
142
|
+
required: true,
|
|
143
|
+
readOnly: false,
|
|
144
|
+
editable: true,
|
|
145
|
+
autocomplete: null,
|
|
146
|
+
options: null,
|
|
147
|
+
fields: [],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "timeNotRequired",
|
|
151
|
+
type: "time",
|
|
152
|
+
label: "Time optional",
|
|
153
|
+
required: false,
|
|
154
|
+
readOnly: false,
|
|
155
|
+
editable: true,
|
|
156
|
+
autocomplete: null,
|
|
157
|
+
options: null,
|
|
158
|
+
fields: [],
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "integerRequired",
|
|
162
|
+
type: "integer",
|
|
163
|
+
label: "Integer required",
|
|
164
|
+
required: true,
|
|
165
|
+
readOnly: false,
|
|
166
|
+
editable: true,
|
|
167
|
+
autocomplete: null,
|
|
168
|
+
options: null,
|
|
169
|
+
fields: [],
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "integerNotRequired",
|
|
173
|
+
type: "integer",
|
|
174
|
+
label: "Integer optional",
|
|
175
|
+
required: false,
|
|
176
|
+
readOnly: false,
|
|
177
|
+
editable: true,
|
|
178
|
+
autocomplete: null,
|
|
179
|
+
options: null,
|
|
180
|
+
fields: [],
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "isBooleanNotRequired",
|
|
184
|
+
type: "boolean",
|
|
185
|
+
label: "Boolean optional",
|
|
186
|
+
required: false,
|
|
187
|
+
readOnly: false,
|
|
188
|
+
editable: true,
|
|
189
|
+
autocomplete: null,
|
|
190
|
+
options: null,
|
|
191
|
+
fields: [],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "manyToManyBigTest",
|
|
195
|
+
type: "manyToMany",
|
|
196
|
+
label: "ManyToMany",
|
|
197
|
+
required: false,
|
|
198
|
+
readOnly: false,
|
|
199
|
+
editable: true,
|
|
200
|
+
autocomplete: "big-test",
|
|
201
|
+
options: null,
|
|
202
|
+
fields: [],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "manyToOneBigTest",
|
|
206
|
+
type: "manyToOne",
|
|
207
|
+
label: "ManyToOne",
|
|
208
|
+
required: false,
|
|
209
|
+
readOnly: false,
|
|
210
|
+
editable: true,
|
|
211
|
+
autocomplete: "big-test",
|
|
212
|
+
options: null,
|
|
213
|
+
fields: [],
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: "embedded",
|
|
217
|
+
type: "embedded",
|
|
218
|
+
label: "Embedded",
|
|
219
|
+
required: true,
|
|
220
|
+
readOnly: false,
|
|
221
|
+
editable: true,
|
|
222
|
+
autocomplete: null,
|
|
223
|
+
options: null,
|
|
224
|
+
fields: [
|
|
225
|
+
{
|
|
226
|
+
name: "value",
|
|
227
|
+
type: "integer",
|
|
228
|
+
label: "value",
|
|
229
|
+
required: true,
|
|
230
|
+
readOnly: false,
|
|
231
|
+
editable: true,
|
|
232
|
+
autocomplete: null,
|
|
233
|
+
options: null,
|
|
234
|
+
fields: [],
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "label",
|
|
238
|
+
type: "string",
|
|
239
|
+
label: "label",
|
|
240
|
+
required: true,
|
|
241
|
+
readOnly: false,
|
|
242
|
+
editable: true,
|
|
243
|
+
autocomplete: null,
|
|
244
|
+
options: null,
|
|
245
|
+
fields: [],
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "oneToMany",
|
|
251
|
+
type: "oneToMany",
|
|
252
|
+
label: "OneToMany",
|
|
253
|
+
required: true,
|
|
254
|
+
readOnly: false,
|
|
255
|
+
editable: true,
|
|
256
|
+
autocomplete: null,
|
|
257
|
+
options: null,
|
|
258
|
+
fields: [
|
|
259
|
+
{
|
|
260
|
+
name: "id",
|
|
261
|
+
type: "integer",
|
|
262
|
+
label: "Id",
|
|
263
|
+
required: true,
|
|
264
|
+
readOnly: true,
|
|
265
|
+
editable: true,
|
|
266
|
+
autocomplete: null,
|
|
267
|
+
options: null,
|
|
268
|
+
fields: [],
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "value",
|
|
272
|
+
type: "integer",
|
|
273
|
+
label: "Big test one to many value",
|
|
274
|
+
required: true,
|
|
275
|
+
readOnly: false,
|
|
276
|
+
editable: true,
|
|
277
|
+
autocomplete: null,
|
|
278
|
+
options: null,
|
|
279
|
+
fields: [],
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: "label",
|
|
283
|
+
type: "string",
|
|
284
|
+
label: "Big test one to many label",
|
|
285
|
+
required: true,
|
|
286
|
+
readOnly: false,
|
|
287
|
+
editable: true,
|
|
288
|
+
autocomplete: null,
|
|
289
|
+
options: null,
|
|
290
|
+
fields: [],
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BaseField = BaseField;
|
|
7
|
+
const translations_1 = require("@uxf/core-react/translations");
|
|
8
|
+
const autocomplete_1 = require("@uxf/core/api/autocomplete");
|
|
9
|
+
const upload_file_1 = require("@uxf/core/api/upload-file");
|
|
10
|
+
const empty_array_1 = require("@uxf/core/constants/empty-array");
|
|
11
|
+
const checkbox_input_1 = require("@uxf/form/checkbox-input");
|
|
12
|
+
const combobox_1 = require("@uxf/form/combobox");
|
|
13
|
+
const date_picker_input_1 = require("@uxf/form/date-picker-input");
|
|
14
|
+
const datetime_picker_input_1 = require("@uxf/form/datetime-picker-input");
|
|
15
|
+
const dropzone_input_1 = require("@uxf/form/dropzone/dropzone-input");
|
|
16
|
+
const dropzone_list_1 = require("@uxf/form/dropzone/dropzone-list");
|
|
17
|
+
const file_input_1 = require("@uxf/form/file-input");
|
|
18
|
+
const multi_combobox_1 = require("@uxf/form/multi-combobox");
|
|
19
|
+
const number_input_1 = require("@uxf/form/number-input");
|
|
20
|
+
const select_1 = require("@uxf/form/select");
|
|
21
|
+
const text_input_1 = require("@uxf/form/text-input");
|
|
22
|
+
const textarea_1 = require("@uxf/form/textarea");
|
|
23
|
+
const time_picker_input_1 = require("@uxf/form/time-picker-input");
|
|
24
|
+
const label_1 = require("@uxf/ui/label");
|
|
25
|
+
const react_1 = __importDefault(require("react"));
|
|
26
|
+
const defaultUploadHandler = (0, upload_file_1.createUploadHandler)("default");
|
|
27
|
+
// eslint-disable-next-line complexity
|
|
28
|
+
function BaseField(props) {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
30
|
+
const { editable, label, name, readOnly, type } = props.fieldSchema;
|
|
31
|
+
const fieldName = `${(_a = props.prefix) !== null && _a !== void 0 ? _a : ""}${name}`;
|
|
32
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
33
|
+
const isDisabled = readOnly || (props.isEditing && !editable);
|
|
34
|
+
const isRequired = !isDisabled && props.fieldSchema.required;
|
|
35
|
+
const autocompleteHandler = (_c = (_b = props.overrides) === null || _b === void 0 ? void 0 : _b.autocomplete) !== null && _c !== void 0 ? _c : autocomplete_1.autocomplete;
|
|
36
|
+
const uploadHandler = (_e = (_d = props.overrides) === null || _d === void 0 ? void 0 : _d.upload) !== null && _e !== void 0 ? _e : defaultUploadHandler;
|
|
37
|
+
/*eslint complexity: ["error", 21]*/
|
|
38
|
+
switch (type) {
|
|
39
|
+
case "file":
|
|
40
|
+
case "logo":
|
|
41
|
+
case "image":
|
|
42
|
+
return (react_1.default.createElement(file_input_1.FileInput, { control: props.control, id: fieldName, isClearable: !isRequired, isDisabled: isDisabled, isRequired: isRequired, label: label, name: fieldName, onUploadFile: uploadHandler }));
|
|
43
|
+
case "enum":
|
|
44
|
+
return (react_1.default.createElement(select_1.Select, { control: props.control, isClearable: !isRequired, isDisabled: isDisabled, isRequired: isRequired, label: label, name: fieldName, options: (_f = props.fieldSchema.options) !== null && _f !== void 0 ? _f : empty_array_1.EMPTY_ARRAY }));
|
|
45
|
+
case "boolean":
|
|
46
|
+
return (react_1.default.createElement(checkbox_input_1.CheckboxInput, { control: props.control, isDisabled: isDisabled, isRequired: isRequired, label: label, name: fieldName }));
|
|
47
|
+
case "date":
|
|
48
|
+
return (react_1.default.createElement(date_picker_input_1.DatePickerInput, { control: props.control, isClearable: !isRequired, isDisabled: isDisabled, isRequired: isRequired, label: label, name: fieldName }));
|
|
49
|
+
case "datetime":
|
|
50
|
+
return (react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { control: props.control, isClearable: !isRequired, isDisabled: isDisabled, isRequired: isRequired, label: label, name: fieldName }));
|
|
51
|
+
case "time":
|
|
52
|
+
return (react_1.default.createElement(time_picker_input_1.TimePickerInput, { control: props.control, isClearable: !isRequired, isDisabled: isDisabled, isRequired: isRequired, label: label, name: fieldName }));
|
|
53
|
+
case "files":
|
|
54
|
+
case "images":
|
|
55
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
56
|
+
react_1.default.createElement(label_1.Label, { isRequired: isRequired }, label),
|
|
57
|
+
react_1.default.createElement("div", { className: "mb-3" },
|
|
58
|
+
react_1.default.createElement(dropzone_input_1.DropzoneInput, { control: props.control, isRequired: isRequired, label: label, name: fieldName, onUploadFile: uploadHandler })),
|
|
59
|
+
react_1.default.createElement(dropzone_list_1.DropzoneList, { control: props.control, errorText: t("uxf-form-form-renderer:file-upload-error"), name: fieldName, onRemoveConfirm: (_g = props.overrides) === null || _g === void 0 ? void 0 : _g.onRemoveConfirm })));
|
|
60
|
+
case "manyToMany":
|
|
61
|
+
return (react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: props.control, isDisabled: isDisabled, isRequired: isRequired, label: label, loadOptions: (term) => { var _a; return autocompleteHandler((_a = props.fieldSchema.autocomplete) !== null && _a !== void 0 ? _a : "", term); }, name: fieldName }));
|
|
62
|
+
case "manyToOne":
|
|
63
|
+
return (react_1.default.createElement(combobox_1.Combobox, { control: props.control, isClearable: !isRequired, isDisabled: isDisabled, isRequired: isRequired, label: label, loadOptions: (term) => { var _a; return autocompleteHandler((_a = props.fieldSchema.autocomplete) !== null && _a !== void 0 ? _a : "", term); }, name: fieldName }));
|
|
64
|
+
case "integer":
|
|
65
|
+
return (react_1.default.createElement(number_input_1.NumberInput, { control: props.control, isDisabled: isDisabled, isRequired: isRequired, label: label, name: fieldName }));
|
|
66
|
+
case "text":
|
|
67
|
+
return (react_1.default.createElement(textarea_1.Textarea, { control: props.control, isDisabled: isDisabled, isRequired: isRequired, label: label, name: fieldName }));
|
|
68
|
+
default:
|
|
69
|
+
return (react_1.default.createElement(text_input_1.TextInput, { control: props.control, isDisabled: isDisabled, isRequired: isRequired, label: label, name: fieldName }));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.default = BaseField;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
function Field(props) {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
9
|
+
if (props.fieldSchema.fields === null) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (react_1.default.createElement("div", { className: "grid gap-2" }, props.fieldSchema.fields.map((schema, i) => {
|
|
13
|
+
var _a;
|
|
14
|
+
const FieldComponent = (_a = props.fields[schema.type]) !== null && _a !== void 0 ? _a : props.fields.default;
|
|
15
|
+
return (react_1.default.createElement("div", { key: i },
|
|
16
|
+
react_1.default.createElement(FieldComponent, { ...props, fieldSchema: { ...schema, label: `${props.fieldSchema.label} ${schema.label}` }, prefix: `${props.fieldSchema.name}.` })));
|
|
17
|
+
})));
|
|
18
|
+
}
|
|
19
|
+
exports.default = Field;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const translations_1 = require("@uxf/core-react/translations");
|
|
27
|
+
const icon_button_1 = require("@uxf/ui/icon-button");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
30
|
+
function Field(props) {
|
|
31
|
+
const { fields, remove, append } = (0, react_hook_form_1.useFieldArray)({ control: props.control, name: props.fieldSchema.name });
|
|
32
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
33
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
34
|
+
react_1.default.createElement("p", { className: "mb-2 font-medium" }, props.fieldSchema.label),
|
|
35
|
+
react_1.default.createElement("div", { className: "grid gap-2" }, fields.map((name, index) => (react_1.default.createElement(react_1.Fragment, { key: name.id },
|
|
36
|
+
props.fieldSchema.fields.map((schema, i) => {
|
|
37
|
+
var _a;
|
|
38
|
+
if (schema.name === "id") {
|
|
39
|
+
return react_1.default.createElement("input", { key: `${schema.name}-${i}`, name: "id", type: "hidden" });
|
|
40
|
+
}
|
|
41
|
+
const FieldComponent = (_a = props.fields[schema.type]) !== null && _a !== void 0 ? _a : props.fields.default;
|
|
42
|
+
return (react_1.default.createElement("div", { key: `${schema.name}-${i}` },
|
|
43
|
+
react_1.default.createElement(FieldComponent, { ...props, fieldSchema: schema, prefix: props.prefix
|
|
44
|
+
? `${props.prefix}.${props.fieldSchema.name}.${index}.`
|
|
45
|
+
: `${props.fieldSchema.name}.${index}.` })));
|
|
46
|
+
}),
|
|
47
|
+
react_1.default.createElement("div", { className: "flex justify-end" },
|
|
48
|
+
react_1.default.createElement(icon_button_1.IconButton, { iconName: "trash", label: t("uxf-form-form-renderer:fields.one-to-many.delete-item"), onClick: () => remove(index), variant: "secondary" })))))),
|
|
49
|
+
react_1.default.createElement("div", { className: "mt-2" },
|
|
50
|
+
react_1.default.createElement(icon_button_1.IconButton, { iconName: "plus", label: t("uxf-form-form-renderer:fields.one-to-many.add-item"), onClick: () => append({ id: null }), variant: "secondary" }))));
|
|
51
|
+
}
|
|
52
|
+
exports.default = Field;
|