@uxf/ui 11.53.2 → 11.55.0
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/avatar/avatar.d.ts +2 -1
- package/avatar/avatar.js +2 -1
- package/avatar-file-input/avatar-file-input.js +1 -1
- package/css/tooltip.css +10 -2
- package/dropzone/dropzone.stories.js +3 -3
- package/package.json +4 -4
- package/tooltip/tooltip.stories.js +29 -5
- package/tooltip/use-tooltip.d.ts +1 -0
- package/tooltip/use-tooltip.js +11 -7
package/avatar/avatar.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from "react";
|
|
1
|
+
import React, { HTMLAttributes, ReactNode } from "react";
|
|
2
2
|
export interface AvatarProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
src?: string;
|
|
4
|
+
placeholder?: ReactNode;
|
|
4
5
|
}
|
|
5
6
|
export declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLDivElement>>;
|
package/avatar/avatar.js
CHANGED
|
@@ -28,7 +28,8 @@ const cx_1 = require("@uxf/core/utils/cx");
|
|
|
28
28
|
const react_1 = __importStar(require("react"));
|
|
29
29
|
const icon_1 = require("../icon");
|
|
30
30
|
exports.Avatar = (0, react_1.forwardRef)((props, ref) => {
|
|
31
|
+
var _a;
|
|
31
32
|
const avatarClassName = (0, cx_1.cx)("uxf-avatar", props.className);
|
|
32
|
-
return (react_1.default.createElement("div", { className: avatarClassName, ref: ref }, props.src ? react_1.default.createElement("img", { alt: "", className: "uxf-avatar__image", src: props.src }) : react_1.default.createElement(icon_1.Icon, { name: "user", size: 16 })));
|
|
33
|
+
return (react_1.default.createElement("div", { className: avatarClassName, ref: ref }, props.src ? (react_1.default.createElement("img", { alt: "", className: "uxf-avatar__image", src: props.src })) : (((_a = props.placeholder) !== null && _a !== void 0 ? _a : react_1.default.createElement(icon_1.Icon, { name: "user", size: 16 })))));
|
|
33
34
|
});
|
|
34
35
|
exports.Avatar.displayName = "UxfUiAvatar";
|
|
@@ -55,7 +55,7 @@ exports.AvatarFileInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
55
55
|
inputNode.value = "";
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
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, name: props.name },
|
|
58
|
+
return (react_1.default.createElement(form_component_1.FormComponent, { className: rootClassName, errorId: props.id, helperText: props.helperText, hiddenLabel: props.hiddenLabel, inputId: id, isRequired: props.isRequired, label: props.label, name: props.name },
|
|
59
59
|
react_1.default.createElement("div", { className: "uxf-avatar-file-input__inner-wrapper" },
|
|
60
60
|
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-avatar-file-input__input", stateClassName), onClick: onSelectFile },
|
|
61
61
|
react_1.default.createElement(_file_input_base_1._FileInputBase, { accept: (_c = props.accept) !== null && _c !== void 0 ? _c : "image/*", "aria-describedby": errorId, "aria-invalid": props.isInvalid, className: "uxf-avatar-file-input__input-element", form: props.form, id: id, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, maxFileSize: props.maxFileSize, name: props.name, onBlur: input.onBlur, onChange: props.onChange, onFocus: input.onFocus, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: (0, compose_refs_1.composeRefs)(innerRef, ref), value: props.value }),
|
package/css/tooltip.css
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
.uxf-tooltip {
|
|
2
|
-
|
|
2
|
+
background-color: theme("colors.lightHigh");
|
|
3
|
+
border-radius: theme("borderRadius.lg");
|
|
4
|
+
color: theme("colors.white");
|
|
5
|
+
max-width: calc(100vw - 20px);
|
|
6
|
+
padding: theme("spacing.3");
|
|
7
|
+
width: max-content;
|
|
8
|
+
z-index: theme("zIndex.tooltip");
|
|
3
9
|
|
|
4
10
|
&__arrow {
|
|
5
|
-
|
|
11
|
+
background-color: theme("colors.lightHigh");
|
|
12
|
+
border-radius: theme("borderRadius.sm");
|
|
13
|
+
z-index: theme("zIndex.tooltip");
|
|
6
14
|
}
|
|
7
15
|
}
|
|
@@ -28,6 +28,7 @@ const show_1 = require("@uxf/core-react/components/show");
|
|
|
28
28
|
const is_not_empty_1 = require("@uxf/core/utils/is-not-empty");
|
|
29
29
|
const handle_rejected_files_1 = require("@uxf/ui/dropzone/handle-rejected-files");
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
|
+
const text_input_1 = require("../text-input");
|
|
31
32
|
const toggle_1 = require("../toggle");
|
|
32
33
|
const action_1 = require("../utils/action");
|
|
33
34
|
const upload_file_mock_1 = require("../utils/mocks/upload-file.mock");
|
|
@@ -48,11 +49,10 @@ function Default() {
|
|
|
48
49
|
react_1.default.createElement(toggle_1.Toggle, { label: "Only images upload", name: "toggle", onChange: () => setHasOnlyImagesAllowed((prev) => !prev), value: hasOnlyImagesAllowed }),
|
|
49
50
|
react_1.default.createElement("div", { className: "flex items-center" },
|
|
50
51
|
react_1.default.createElement(toggle_1.Toggle, { label: "Limit file count", name: "toggle", onChange: () => setIsFileCountLimited((prev) => !prev), value: isFileCountLimited }),
|
|
51
|
-
react_1.default.createElement(
|
|
52
|
+
react_1.default.createElement(text_input_1.TextInput, { className: "w-20", name: "limit-file-count", onChange: (value) => setFileCountLimit(parseInt(value, 10)), type: "number", value: fileCountLimit.toString() })),
|
|
52
53
|
react_1.default.createElement("div", { className: "flex items-center" },
|
|
53
54
|
react_1.default.createElement(toggle_1.Toggle, { label: "Limit file size", name: "toggle", onChange: () => setIsFileSizeLimited((prev) => !prev), value: isFileSizeLimited }),
|
|
54
|
-
react_1.default.createElement(
|
|
55
|
-
"MB"),
|
|
55
|
+
react_1.default.createElement(text_input_1.TextInput, { className: "w-28", name: "limit-file-size", onChange: (value) => setFileSizeLimit(parseInt(value, 10)), rightElement: "MB", type: "number", value: fileSizeLimit.toString() })),
|
|
56
56
|
react_1.default.createElement(index_1.Dropzone, { accept: hasOnlyImagesAllowed ? { "image/*": [] } : undefined, isDisabled: isDisabled, label: "Use drag and drop or click to upload", maxFileSize: isFileSizeLimited ? fileSizeLimit * MB_SIZE : undefined, maxFilesCount: isFileCountLimited ? fileCountLimit : undefined, name: "dropzone-disabled-drag-and-drop", onChange: onChange, onDropRejected: (fileRejections) => (0, handle_rejected_files_1.handleRejectedFiles)(fileRejections, fileCountLimit), onUploadFile: upload_file_mock_1.uploadFile, value: files }),
|
|
57
57
|
react_1.default.createElement(index_1.Dropzone.List, { className: "mt-6", errorText: "Chyba p\u0159i nahr\u00E1v\u00E1n\u00ED souboru", isDisabled: isDisabled, name: "dropzone-error-message", onChange: onChange, onRemoveConfirm: onRemoveConfirm, value: files }),
|
|
58
58
|
react_1.default.createElement(show_1.Show, { when: (0, is_not_empty_1.isNotEmpty)(files) },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/ui",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.55.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@floating-ui/react": "0.26.28",
|
|
25
25
|
"@headlessui/react": "1.7.19",
|
|
26
|
-
"@uxf/core": "11.
|
|
27
|
-
"@uxf/core-react": "11.
|
|
26
|
+
"@uxf/core": "11.54.0",
|
|
27
|
+
"@uxf/core-react": "11.54.0",
|
|
28
28
|
"@uxf/datepicker": "11.50.0",
|
|
29
|
-
"@uxf/styles": "11.
|
|
29
|
+
"@uxf/styles": "11.54.0",
|
|
30
30
|
"color2k": "2.0.3",
|
|
31
31
|
"dayjs": "1.11.13",
|
|
32
32
|
"jump.js": "1.0.2",
|
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.Default = Default;
|
|
7
|
-
const react_1 =
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const checkbox_input_1 = require("../checkbox-input");
|
|
8
29
|
const chip_1 = require("../chip");
|
|
9
30
|
const tooltip_1 = require("./tooltip");
|
|
10
31
|
function Default() {
|
|
11
32
|
const sides = ["top", "bottom", "bottom-start", "left", "right"];
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
const [isPointingDisabled, setIsPointingDisabled] = (0, react_1.useState)(false);
|
|
34
|
+
return (react_1.default.createElement("div", { className: "grid h-96 place-items-center" },
|
|
35
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: "Disable pointing inside tooltip?", name: "isPointingDisabled", onChange: (value) => setIsPointingDisabled(Boolean(value)), value: isPointingDisabled }),
|
|
36
|
+
sides.map((placement) => (react_1.default.createElement(tooltip_1.Tooltip, { content: "My tooltip content", isPointingDisabled: isPointingDisabled, key: placement, placement: placement },
|
|
37
|
+
react_1.default.createElement(chip_1.Chip, { color: "green" }, placement))))));
|
|
14
38
|
}
|
package/tooltip/use-tooltip.d.ts
CHANGED
package/tooltip/use-tooltip.js
CHANGED
|
@@ -5,7 +5,7 @@ const react_1 = require("@floating-ui/react");
|
|
|
5
5
|
const react_2 = require("react");
|
|
6
6
|
function useTooltip(options) {
|
|
7
7
|
var _a, _b;
|
|
8
|
-
const [
|
|
8
|
+
const [isOpen, setIsOpen] = (0, react_2.useState)(false);
|
|
9
9
|
const data = (0, react_1.useFloating)({
|
|
10
10
|
middleware: [
|
|
11
11
|
(0, react_1.offset)((_a = options.offset) !== null && _a !== void 0 ? _a : 16),
|
|
@@ -13,23 +13,27 @@ function useTooltip(options) {
|
|
|
13
13
|
(0, react_1.shift)({ padding: (_b = options.shiftPadding) !== null && _b !== void 0 ? _b : 8 }),
|
|
14
14
|
(0, react_1.arrow)({ element: options.arrowRef }),
|
|
15
15
|
],
|
|
16
|
-
open,
|
|
17
|
-
onOpenChange:
|
|
16
|
+
open: isOpen,
|
|
17
|
+
onOpenChange: setIsOpen,
|
|
18
18
|
placement: options.placement,
|
|
19
19
|
whileElementsMounted: (reference, floating, update) => (0, react_1.autoUpdate)(reference, floating, update, {
|
|
20
20
|
elementResize: typeof ResizeObserver !== "undefined",
|
|
21
21
|
}),
|
|
22
22
|
});
|
|
23
23
|
const context = data.context;
|
|
24
|
-
const hover = (0, react_1.useHover)(context, {
|
|
24
|
+
const hover = (0, react_1.useHover)(context, {
|
|
25
|
+
delay: options.isPointingDisabled ? undefined : 200,
|
|
26
|
+
handleClose: options.isPointingDisabled ? null : (0, react_1.safePolygon)(),
|
|
27
|
+
move: false,
|
|
28
|
+
});
|
|
25
29
|
const focus = (0, react_1.useFocus)(context);
|
|
26
30
|
const role = (0, react_1.useRole)(context, { role: "tooltip" });
|
|
27
31
|
const dismiss = (0, react_1.useDismiss)(context);
|
|
28
32
|
const interactions = (0, react_1.useInteractions)([hover, focus, dismiss, role]);
|
|
29
33
|
return (0, react_2.useMemo)(() => ({
|
|
30
|
-
open,
|
|
31
|
-
setOpen,
|
|
34
|
+
open: isOpen,
|
|
35
|
+
setOpen: setIsOpen,
|
|
32
36
|
...interactions,
|
|
33
37
|
...data,
|
|
34
|
-
}), [
|
|
38
|
+
}), [isOpen, setIsOpen, interactions, data]);
|
|
35
39
|
}
|