@uxf/ui 10.8.0 → 10.8.2
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/_file-input-base/file-input-base.js +3 -6
- package/_select-base/_select-base.js +4 -6
- package/avatar-file-input/avatar-file-input.js +8 -1
- package/dropzone/dropzone-input.js +1 -1
- package/file-input/file-input.js +11 -2
- package/multi-combobox/_multi-combobox-base.js +7 -3
- package/package.json +1 -1
|
@@ -28,8 +28,8 @@ const react_1 = __importStar(require("react"));
|
|
|
28
28
|
const validator_exceptions_1 = require("../utils/validator/validator-exceptions");
|
|
29
29
|
exports._FileInputBase = (0, react_1.forwardRef)((props, ref) => {
|
|
30
30
|
const onChange = async (e) => {
|
|
31
|
-
var _a;
|
|
32
|
-
if (e.target.files) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
if ((_a = e.target.files) === null || _a === void 0 ? void 0 : _a.length) {
|
|
33
33
|
try {
|
|
34
34
|
const file = e.target.files[0];
|
|
35
35
|
if (props.maxFileSize && file.size > props.maxFileSize) {
|
|
@@ -39,12 +39,9 @@ exports._FileInputBase = (0, react_1.forwardRef)((props, ref) => {
|
|
|
39
39
|
await props.onChange(response, e);
|
|
40
40
|
}
|
|
41
41
|
catch (err) {
|
|
42
|
-
(
|
|
42
|
+
(_b = props.onUploadError) === null || _b === void 0 ? void 0 : _b.call(props, err);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
else {
|
|
46
|
-
props.onChange(null, e);
|
|
47
|
-
}
|
|
48
45
|
};
|
|
49
46
|
return (react_1.default.createElement("input", { accept: props.accept, "aria-invalid": props.isInvalid, "aria-describedby": props["aria-describedby"], className: props.className, disabled: props.isDisabled, form: props.form, id: props.id, name: props.name, onBlur: props.onBlur, onChange: onChange, onFocus: props.onFocus, readOnly: props.isReadOnly, ref: ref, required: props.isRequired, tabIndex: props.isDisabled ? -1 : undefined, type: "file" }));
|
|
50
47
|
});
|
|
@@ -36,10 +36,8 @@ const input_1 = require("@uxf/ui/input");
|
|
|
36
36
|
const label_1 = require("@uxf/ui/label");
|
|
37
37
|
const react_2 = __importStar(require("react"));
|
|
38
38
|
const Option = (props) => {
|
|
39
|
-
var _a, _b, _c, _d;
|
|
40
|
-
const optionKey = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, props.option);
|
|
41
39
|
const HUIComponent = props.HUIComponent;
|
|
42
|
-
return (react_2.default.createElement(HUIComponent.Option, { className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED),
|
|
40
|
+
return (react_2.default.createElement(HUIComponent.Option, { className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED), value: props.option }, (optionState) => { var _a, _b; return (_b = (_a = props.renderOption) === null || _a === void 0 ? void 0 : _a.call(props, props.option, optionState.selected)) !== null && _b !== void 0 ? _b : props.option.label; }));
|
|
43
41
|
};
|
|
44
42
|
Option.displayName = "UxfUiSelectBaseOption";
|
|
45
43
|
function isHUICombobox(HUIComponent) {
|
|
@@ -68,9 +66,9 @@ const Options = (props) => {
|
|
|
68
66
|
return (react_2.default.createElement(HUIComponent.Options, { className: (0, cx_1.cx)("uxf-dropdown uxf-select-base__options", `uxf-dropdown--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, `uxf-dropdown--variant-${(_b = props.variant) !== null && _b !== void 0 ? _b : "default"}`, props.matchWidth
|
|
69
67
|
? "uxf-select-base__options--match-width"
|
|
70
68
|
: "uxf-select-base__options--not-match-width", props.placement === "bottom" && "uxf-dropdown--bottom", props.placement === "top" && "uxf-dropdown--top", props.className), ref: props.forwardRef, static: true, style: props.style }, props.options && props.options.length > 0 ? (props.options.map((option) => {
|
|
71
|
-
var _a;
|
|
72
|
-
const optionKey = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, option);
|
|
73
|
-
return (react_2.default.createElement(Option, {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const optionKey = (_b = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, option)) !== null && _b !== void 0 ? _b : option.id;
|
|
71
|
+
return (react_2.default.createElement(Option, { HUIComponent: HUIComponent, key: optionKey, option: option, renderOption: props.renderOption }));
|
|
74
72
|
})) : (react_2.default.createElement("div", { className: "uxf-dropdown__empty-wrapper" }, props.emptyMessage))));
|
|
75
73
|
};
|
|
76
74
|
Options.displayName = "UxfUiSelectBaseOptions";
|
|
@@ -45,7 +45,14 @@ exports.AvatarFileInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
45
45
|
const stateClassName = (0, cx_1.cx)(((_a = props.isFocused) !== null && _a !== void 0 ? _a : input.focused) && classes_1.CLASSES.IS_FOCUSED, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isRequired && classes_1.CLASSES.IS_REQUIRED);
|
|
46
46
|
const rootClassName = (0, cx_1.cx)(`uxf-avatar-file-input uxf-avatar-file-input--variant-${(_b = props.variant) !== null && _b !== void 0 ? _b : "default"}`, stateClassName, props.className);
|
|
47
47
|
const onSelectFile = () => { var _a; return (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.click(); };
|
|
48
|
-
const onRemoveFile = () =>
|
|
48
|
+
const onRemoveFile = () => {
|
|
49
|
+
props.onChange(null);
|
|
50
|
+
// this ensures that the file input is cleared on remove, so that the same file can be selected again
|
|
51
|
+
const inputNode = innerRef.current;
|
|
52
|
+
if (inputNode) {
|
|
53
|
+
inputNode.value = "";
|
|
54
|
+
}
|
|
55
|
+
};
|
|
49
56
|
return (react_1.default.createElement(form_component_1.FormComponent, { className: rootClassName, errorId: props.id, helperText: props.helperText, hiddenLabel: props.hiddenLabel, inputId: id, label: props.label },
|
|
50
57
|
react_1.default.createElement("div", { className: "uxf-avatar-file-input__inner-wrapper" },
|
|
51
58
|
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-avatar-file-input__input", stateClassName), onClick: onSelectFile },
|
|
@@ -51,7 +51,7 @@ function progressHandler(progressEvent, file, onValuesChange, values) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
function fileUploadedHandler(uploadedFile, dropzoneFile, onValuesChange, values) {
|
|
54
|
-
if (values) {
|
|
54
|
+
if (values && uploadedFile) {
|
|
55
55
|
onValuesChange(values.map((f) => f.id === dropzoneFile.id ? { ...uploadedFile, progress: 100, originalFile: f.originalFile } : f));
|
|
56
56
|
}
|
|
57
57
|
}
|
package/file-input/file-input.js
CHANGED
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.FileInput = void 0;
|
|
27
27
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
28
28
|
const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
29
|
+
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
29
30
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
30
31
|
const context_1 = require("@uxf/ui/context");
|
|
31
32
|
const input_1 = require("@uxf/ui/input");
|
|
@@ -51,13 +52,21 @@ exports.FileInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
51
52
|
setIsUploading(false);
|
|
52
53
|
return response;
|
|
53
54
|
};
|
|
55
|
+
const onChange = (value, event) => {
|
|
56
|
+
const inputNode = innerRef.current;
|
|
57
|
+
// this ensures that the input is cleared after the upload, so there is no problem with uploading the same file again
|
|
58
|
+
if (!value && inputNode) {
|
|
59
|
+
inputNode.value = "";
|
|
60
|
+
}
|
|
61
|
+
props.onChange(value, event);
|
|
62
|
+
};
|
|
54
63
|
return (react_1.default.createElement(form_component_1.FormComponent, { className: (0, cx_1.cx)(input.focused && classes_1.CLASSES.IS_FOCUSED, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY), errorId: errorId, form: props.form, helperText: props.helperText, inputId: id, isRequired: props.isRequired, label: props.label, hiddenLabel: props.hiddenLabel },
|
|
55
64
|
react_1.default.createElement(react_1.default.Fragment, null,
|
|
56
|
-
react_1.default.createElement(_file_input_base_1._FileInputBase, { accept: props.accept, "aria-describedby": errorId, "aria-invalid": props.isInvalid, className: `uxf-file-input__input ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, form: props.form, id: id, isDisabled: props.isDisabled || isUploading, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, maxFileSize: props.maxFileSize, name: props.name, onBlur: input.onBlur, onChange:
|
|
65
|
+
react_1.default.createElement(_file_input_base_1._FileInputBase, { accept: props.accept, "aria-describedby": errorId, "aria-invalid": props.isInvalid, className: `uxf-file-input__input ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, form: props.form, id: id, isDisabled: props.isDisabled || isUploading, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, maxFileSize: props.maxFileSize, name: props.name, onBlur: input.onBlur, onChange: onChange, onFocus: input.onFocus, onUploadError: props.onUploadError, onUploadFile: onUploadFile, ref: (0, composeRefs_1.composeRefs)(ref, innerRef), value: props.value }),
|
|
57
66
|
react_1.default.createElement("label", { className: (0, cx_1.cx)("uxf-input", "uxf-file-input__label", input.focused && classes_1.CLASSES.IS_FOCUSED, (props.isDisabled || props.isReadOnly) && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, isUploading && classes_1.CLASSES.IS_LOADING, isUploading && "uxf-file-input__label--has-right-addon", `uxf-input--size-${(_b = props.size) !== null && _b !== void 0 ? _b : "default"}`, `uxf-input--variant-${(_c = props.variant) !== null && _c !== void 0 ? _c : "default"}`), htmlFor: id },
|
|
58
67
|
react_1.default.createElement("div", { className: "uxf-input__left-addon uxf-file-input__label__button" }, !isUploading ? ((_d = props.uploadButtonLabel) !== null && _d !== void 0 ? _d : "Vyberte soubor") : (react_1.default.createElement(loader_1.Loader, { className: "uxf-file-input__label__loader", size: "sm" }))),
|
|
59
68
|
react_1.default.createElement("div", { className: "uxf-file-input__label__wrapper" },
|
|
60
69
|
(context === null || context === void 0 ? void 0 : context.domain) && props.value ? (react_1.default.createElement("a", { className: "uxf-file-input__label__wrapper__file-name-link", href: (0, get_file_url_1.getFileUrl)(context.domain, props.value), target: "_blank", rel: "noreferrer noopenner" }, fileName)) : (react_1.default.createElement("span", { className: "uxf-file-input__label__wrapper__file-name" }, fileName)),
|
|
61
|
-
props.value && !props.isDisabled && !props.isReadOnly && props.isClearable && (react_1.default.createElement(input_1.Input.RemoveButton, { onChange:
|
|
70
|
+
props.value && !props.isDisabled && !props.isReadOnly && props.isClearable && (react_1.default.createElement(input_1.Input.RemoveButton, { onChange: onChange })))))));
|
|
62
71
|
});
|
|
63
72
|
exports.FileInput.displayName = "UxfUiFileInput";
|
|
@@ -108,6 +108,11 @@ exports._MultiComboboxBase = (0, react_3.forwardRef)((props, ref) => {
|
|
|
108
108
|
? (_f = props.allOptionsSelectedMessage) !== null && _f !== void 0 ? _f : "Všechny možnosti jsou již vybrány"
|
|
109
109
|
: (_g = props.notFoundMessage) !== null && _g !== void 0 ? _g : "Nic nenalezeno";
|
|
110
110
|
const withoutPopover = !props.withPopover;
|
|
111
|
+
const onBlur = (e) => {
|
|
112
|
+
var _a;
|
|
113
|
+
setQuery("");
|
|
114
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
115
|
+
};
|
|
111
116
|
return (react_3.default.createElement(react_2.Combobox, { as: "div", by: "id", className: (0, cx_1.cx)(withoutPopover && "uxf-form-component", "uxf-multi-combobox", props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isRequired && classes_1.CLASSES.IS_REQUIRED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.className), disabled: props.isDisabled || props.isReadOnly, multiple: true, onChange: handleComboboxValueChange, value: selectedOptions }, (renderProps) => {
|
|
112
117
|
var _a, _b;
|
|
113
118
|
const inputElement = (react_3.default.createElement(react_3.default.Fragment, null,
|
|
@@ -116,15 +121,14 @@ exports._MultiComboboxBase = (0, react_3.forwardRef)((props, ref) => {
|
|
|
116
121
|
props.leftElement && react_3.default.createElement(input_1.Input.LeftElement, null, props.leftElement),
|
|
117
122
|
react_3.default.createElement("div", { className: "uxf-multi-combobox__selected-options" },
|
|
118
123
|
selectedOptions.map((item) => (react_3.default.createElement(chip_1.Chip, { className: "uxf-multi-combobox__input-chip", color: item.color, key: item.id, onClose: item.disabled ? undefined : handleRemove(item.id), size: "large", suppressFocus: true }, item.label))),
|
|
119
|
-
react_3.default.createElement(react_2.Combobox.Input, { autoComplete: "off", className: "uxf-multi-combobox__input", onChange: handleInputChange, onKeyDown: handleInputKeyDown, placeholder: props.placeholder, type: "text", value: query })),
|
|
124
|
+
react_3.default.createElement(react_2.Combobox.Input, { autoComplete: "off", className: "uxf-multi-combobox__input", onBlur: onBlur, onChange: handleInputChange, onKeyDown: handleInputKeyDown, placeholder: props.placeholder, type: "text", value: query })),
|
|
120
125
|
props.rightAddon && react_3.default.createElement(input_1.Input.RightAddon, null, props.rightAddon),
|
|
121
126
|
props.rightElement && react_3.default.createElement(input_1.Input.RightElement, null, props.rightElement),
|
|
122
127
|
react_3.default.createElement(icon_1.Icon, { className: (0, cx_1.cx)("uxf-select-base__arrow-icon", (props.withPopover ? props.isPopoverOpen : renderProps.open) && classes_1.CLASSES.IS_OPEN), name: iconName })),
|
|
123
128
|
renderProps.open && (react_3.default.createElement(react_1.FloatingPortal, null,
|
|
124
129
|
react_3.default.createElement(react_2.Combobox.Options, { className: (0, cx_1.cx)("uxf-dropdown", `uxf-dropdown--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, `uxf-dropdown--variant-${(_b = props.variant) !== null && _b !== void 0 ? _b : "default"}`, dropdown.placement === "bottom" && "uxf-dropdown--bottom", dropdown.placement === "top" && "uxf-dropdown--top"), ref: dropdown.refs.setFloating, static: true, style: dropdown.floatingStyles }, filteredData.length > 0 ? (filteredData.map((option) => {
|
|
125
130
|
var _a, _b, _c, _d;
|
|
126
|
-
|
|
127
|
-
return (react_3.default.createElement(OptionElement, { option: option, key: (_d = (_c = props.keyExtractor) === null || _c === void 0 ? void 0 : _c.call(props, option)) !== null && _d !== void 0 ? _d : option.id, label: label, handleCheckboxChange: handleCheckboxChange(option.id), withCheckboxes: props.withCheckboxes, withoutPopover: withoutPopover }));
|
|
131
|
+
return (react_3.default.createElement(OptionElement, { option: option, key: (_b = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, option)) !== null && _b !== void 0 ? _b : option.id, label: (_d = (_c = props.renderOption) === null || _c === void 0 ? void 0 : _c.call(props, option)) !== null && _d !== void 0 ? _d : option.label, handleCheckboxChange: handleCheckboxChange(option.id), withCheckboxes: props.withCheckboxes, withoutPopover: withoutPopover }));
|
|
128
132
|
})) : (react_3.default.createElement("div", { className: "uxf-dropdown__empty-wrapper" }, emptyMessage))))),
|
|
129
133
|
props.helperText && withoutPopover && (react_3.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID), id: props.errorId }, props.helperText))));
|
|
130
134
|
return (react_3.default.createElement(react_3.default.Fragment, null, withoutPopover ? (react_3.default.createElement(react_3.default.Fragment, null,
|