@uxf/form 1.0.0-beta.92 → 1.0.0-beta.94
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/multi-combobox/index.d.ts +1 -0
- package/multi-combobox/index.js +17 -0
- package/multi-combobox/multi-combobox.d.ts +7 -0
- package/multi-combobox/multi-combobox.js +29 -0
- package/multi-combobox/multi-combobox.stories.d.ts +8 -0
- package/multi-combobox/multi-combobox.stories.js +35 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./multi-combobox";
|
|
@@ -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("./multi-combobox"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MultiComboboxProps as UIMultiComboboxProps } from "@uxf/ui/mutli-combobox";
|
|
3
|
+
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
+
export declare type ComboProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIMultiComboboxProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
5
|
+
requiredMessage?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function MultiCombobox<FormData extends Record<string, any>>(props: ComboProps<FormData>): JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
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.MultiCombobox = void 0;
|
|
7
|
+
const mutli_combobox_1 = require("@uxf/ui/mutli-combobox");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
+
function MultiCombobox(props) {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
13
|
+
control: props.control,
|
|
14
|
+
defaultValue: props.defaultValue,
|
|
15
|
+
name: props.name,
|
|
16
|
+
rules: {
|
|
17
|
+
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
18
|
+
...((_a = props.rules) !== null && _a !== void 0 ? _a : {}),
|
|
19
|
+
},
|
|
20
|
+
shouldUnregister: props.shouldUnregister,
|
|
21
|
+
});
|
|
22
|
+
const onBlur = (event) => {
|
|
23
|
+
var _a;
|
|
24
|
+
field.onBlur();
|
|
25
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
26
|
+
};
|
|
27
|
+
return (react_1.default.createElement(mutli_combobox_1.MultiCombobox, { className: props.className, dropdownPlacement: props.dropdownPlacement, helperText: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, id: props.id, isDisabled: props.options.length === 0 || props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: (value) => field.onChange(value), onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, ref: field.ref, value: field.value, withCheckboxes: props.withCheckboxes }));
|
|
28
|
+
}
|
|
29
|
+
exports.MultiCombobox = MultiCombobox;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 = void 0;
|
|
7
|
+
const button_1 = require("@uxf/ui/button");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const form_1 = require("../storybook/form");
|
|
10
|
+
const multi_combobox_1 = require("./multi-combobox");
|
|
11
|
+
exports.default = {
|
|
12
|
+
title: "Form/MultiCombobox",
|
|
13
|
+
component: multi_combobox_1.MultiCombobox,
|
|
14
|
+
};
|
|
15
|
+
const options = [
|
|
16
|
+
{ id: "one", label: "Option one", color: "red" },
|
|
17
|
+
{ id: "two", label: "Option two", color: "blue" },
|
|
18
|
+
{ id: "three", label: "Option three", color: "green" },
|
|
19
|
+
{ id: "four", label: "Option four" },
|
|
20
|
+
{ id: "five", label: "Option five" },
|
|
21
|
+
{ id: "six", label: "Option six" },
|
|
22
|
+
];
|
|
23
|
+
function Default() {
|
|
24
|
+
const storyFormComboboxes = (control) => (react_1.default.createElement("div", { className: "space-y-8" },
|
|
25
|
+
react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, helperText: "Za\u010Dn\u011Bte ps\u00E1t pro vyhled\u00E1v\u00E1n\u00ED...", id: "form-combobox", label: "Combobox form", name: "combobox1", options: options, placeholder: "Placeholder" }),
|
|
26
|
+
react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, helperText: "Za\u010Dn\u011Bte ps\u00E1t pro vyhled\u00E1v\u00E1n\u00ED...", id: "form-combobox", label: "Combobox with checkboxes", name: "combobox-with-checkboxes", options: options, placeholder: "Placeholder", withCheckboxes: true }),
|
|
27
|
+
react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, helperText: "Za\u010Dn\u011Bte ps\u00E1t pro vyhled\u00E1v\u00E1n\u00ED...", id: "form-combobox", isRequired: true, label: "Combobox form required", name: "combobox-required", options: options, placeholder: "Placeholder" }),
|
|
28
|
+
react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, id: "form-combobox", isDisabled: true, label: "Combobox form disabled", name: "combobox-disabled", options: options, placeholder: "Placeholder" }),
|
|
29
|
+
react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, dropdownPlacement: "top", id: "form-combobox", label: "Combobox form with dropdown top", name: "select-dropdown-top", options: options, placeholder: "Placeholder" }),
|
|
30
|
+
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
31
|
+
return (react_1.default.createElement(form_1.Form, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
32
|
+
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormComboboxes(control)),
|
|
33
|
+
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormComboboxes(control))))));
|
|
34
|
+
}
|
|
35
|
+
exports.Default = Default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/form",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.94",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "UX Fans s.r.o",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@uxf/ui": "^1.0.0-beta.
|
|
16
|
+
"@uxf/ui": "^1.0.0-beta.94",
|
|
17
17
|
"react-hook-form": "latest"
|
|
18
18
|
}
|
|
19
19
|
}
|