@uxf/form 1.0.0-beta.125 → 1.0.0-beta.127
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/multi-combobox.d.ts +1 -1
- package/multi-combobox/multi-combobox.js +2 -2
- package/multi-select/index.d.ts +1 -0
- package/multi-select/index.js +17 -0
- package/multi-select/multi-select.d.ts +7 -0
- package/multi-select/multi-select.js +29 -0
- package/multi-select/multi-select.stories.d.ts +8 -0
- package/multi-select/multi-select.stories.js +41 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { MultiComboboxProps as UIMultiComboboxProps } from "@uxf/ui/
|
|
2
|
+
import { MultiComboboxProps as UIMultiComboboxProps } from "@uxf/ui/multi-combobox";
|
|
3
3
|
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
4
|
export declare type ComboProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIMultiComboboxProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
5
5
|
requiredMessage?: string;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MultiCombobox = void 0;
|
|
7
|
-
const
|
|
7
|
+
const multi_combobox_1 = require("@uxf/ui/multi-combobox");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
10
|
function MultiCombobox(props) {
|
|
@@ -24,6 +24,6 @@ function MultiCombobox(props) {
|
|
|
24
24
|
field.onBlur();
|
|
25
25
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
26
26
|
};
|
|
27
|
-
return (react_1.default.createElement(
|
|
27
|
+
return (react_1.default.createElement(multi_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: ((_d = props.options) === null || _d === void 0 ? void 0 : _d.length) === 0 || props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, loadOptions: props.loadOptions, 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
28
|
}
|
|
29
29
|
exports.MultiCombobox = MultiCombobox;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./multi-select";
|
|
@@ -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-select"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MultiSelectProps as UIMultiSelectProps } from "@uxf/ui/multi-select";
|
|
3
|
+
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
+
export declare type ComboProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIMultiSelectProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
5
|
+
requiredMessage?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function MultiSelect<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.MultiSelect = void 0;
|
|
7
|
+
const multi_select_1 = require("@uxf/ui/multi-select");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
+
function MultiSelect(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(multi_select_1.MultiSelect, { 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, withPopover: props.withPopover }));
|
|
28
|
+
}
|
|
29
|
+
exports.MultiSelect = MultiSelect;
|
|
@@ -0,0 +1,41 @@
|
|
|
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_select_1 = require("./multi-select");
|
|
11
|
+
exports.default = {
|
|
12
|
+
title: "Form/MultiSelect",
|
|
13
|
+
component: multi_select_1.MultiSelect,
|
|
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 storyFormMultiSelect = (control) => (react_1.default.createElement("div", { className: "space-y-8" },
|
|
25
|
+
react_1.default.createElement(multi_select_1.MultiSelect, { control: control, helperText: "Vyberte pros\u00EDm jednu nebo v\u00EDce mo\u017Enost\u00ED", id: "form-multi-select", label: "MultiSelect form", name: "multi-select", options: options, placeholder: "Vyberte .." }),
|
|
26
|
+
react_1.default.createElement(multi_select_1.MultiSelect, { control: control, id: "form-multi-select", label: "MultiSelect with popover", name: "multi-select-with-popover", options: options, placeholder: "Vyberte ..", withPopover: true }),
|
|
27
|
+
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
28
|
+
return (react_1.default.createElement(form_1.Form, { defaultValues: {
|
|
29
|
+
"multi-select": [
|
|
30
|
+
{ id: "one", label: "Option one" },
|
|
31
|
+
{ id: "two", label: "Option two" },
|
|
32
|
+
],
|
|
33
|
+
"multi-select-with-popover": [
|
|
34
|
+
{ id: "one", label: "Option one" },
|
|
35
|
+
{ id: "two", label: "Option two" },
|
|
36
|
+
],
|
|
37
|
+
} }, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
38
|
+
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormMultiSelect(control)),
|
|
39
|
+
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormMultiSelect(control))))));
|
|
40
|
+
}
|
|
41
|
+
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.127",
|
|
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.127",
|
|
17
17
|
"react-hook-form": "latest",
|
|
18
18
|
"coordinate-parser": "^1.0.7"
|
|
19
19
|
}
|