@uxf/ui 1.0.0-beta.127 → 1.0.0-beta.129
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/_private-utils/get-provider-config.js +1 -0
- package/context/context.d.ts +1 -0
- package/css/combobox.css +10 -3
- package/css/dropzone.css +4 -0
- package/css/file-input.css +4 -0
- package/css/input.css +9 -2
- package/css/textarea.css +10 -3
- package/dropzone/dropzone-list.d.ts +1 -1
- package/dropzone/dropzone-list.js +29 -6
- package/dropzone/dropzone.stories.js +6 -3
- package/file-input/file-input.js +5 -1
- package/package.json +1 -1
- package/utils/files/get-file-url.d.ts +2 -0
- package/utils/files/get-file-url.js +7 -0
|
@@ -10,6 +10,7 @@ const getProviderConfig = () => ({
|
|
|
10
10
|
respectSystemSetting: false,
|
|
11
11
|
respectUserSettings: false,
|
|
12
12
|
},
|
|
13
|
+
domain: "https://localhost:6006",
|
|
13
14
|
icon: { spriteFilePath: "/icons-generated/_icon-sprite.svg", iconsConfig: icons_1.ICONS },
|
|
14
15
|
rasterImage: {
|
|
15
16
|
breakpoints: tw_screens_1.twScreens,
|
package/context/context.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ColorSchemeOptions } from "../color-scheme/use-handle-color-scheme";
|
|
|
3
3
|
import { IconName } from "../icon/types";
|
|
4
4
|
export declare type UiContextType = {
|
|
5
5
|
colorScheme: ColorSchemeOptions;
|
|
6
|
+
domain: string;
|
|
6
7
|
icon: {
|
|
7
8
|
spriteFilePath: string;
|
|
8
9
|
iconsConfig: Record<IconName, {
|
package/css/combobox.css
CHANGED
|
@@ -92,16 +92,23 @@
|
|
|
92
92
|
&,
|
|
93
93
|
&:hover,
|
|
94
94
|
&:focus {
|
|
95
|
-
|
|
95
|
+
-webkit-appearance: none;
|
|
96
|
+
-moz-appearance: none;
|
|
97
|
+
appearance: none;
|
|
98
|
+
transition: background-color 5000s ease-in-out 0s !important;
|
|
96
99
|
|
|
97
100
|
:root .dark & {
|
|
101
|
+
-webkit-text-fill-color: theme("colors.gray.300");
|
|
98
102
|
-webkit-box-shadow: inset 0 0 0 1000px theme("colors.gray.800");
|
|
103
|
+
box-shadow: inset 0 0 0 1000px theme("colors.gray.800");
|
|
104
|
+
background-color: theme("colors.gray.800");
|
|
99
105
|
caret-color: white;
|
|
100
|
-
-webkit-text-fill-color: theme("colors.gray.300");
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
:root .light & {
|
|
104
|
-
-webkit-box-shadow: inset 0 0 0 1000px theme("colors.
|
|
109
|
+
-webkit-box-shadow: inset 0 0 0 1000px theme("colors.white");
|
|
110
|
+
box-shadow: inset 0 0 0 1000px theme("colors.white");
|
|
111
|
+
background-color: theme("colors.white");
|
|
105
112
|
}
|
|
106
113
|
}
|
|
107
114
|
}
|
package/css/dropzone.css
CHANGED
package/css/file-input.css
CHANGED
package/css/input.css
CHANGED
|
@@ -217,16 +217,23 @@
|
|
|
217
217
|
&,
|
|
218
218
|
&:hover,
|
|
219
219
|
&:focus {
|
|
220
|
-
|
|
220
|
+
-webkit-appearance: none;
|
|
221
|
+
-moz-appearance: none;
|
|
222
|
+
appearance: none;
|
|
223
|
+
transition: background-color 5000s ease-in-out 0s !important;
|
|
221
224
|
|
|
222
225
|
:root .dark & {
|
|
226
|
+
-webkit-text-fill-color: theme("colors.gray.300");
|
|
223
227
|
-webkit-box-shadow: inset 0 0 0 1000px theme("colors.gray.800");
|
|
228
|
+
box-shadow: inset 0 0 0 1000px theme("colors.gray.800");
|
|
229
|
+
background-color: theme("colors.gray.800");
|
|
224
230
|
caret-color: white;
|
|
225
|
-
-webkit-text-fill-color: theme("colors.gray.300");
|
|
226
231
|
}
|
|
227
232
|
|
|
228
233
|
:root .light & {
|
|
229
234
|
-webkit-box-shadow: inset 0 0 0 1000px theme("colors.white");
|
|
235
|
+
box-shadow: inset 0 0 0 1000px theme("colors.white");
|
|
236
|
+
background-color: theme("colors.white");
|
|
230
237
|
}
|
|
231
238
|
}
|
|
232
239
|
}
|
package/css/textarea.css
CHANGED
|
@@ -101,16 +101,23 @@
|
|
|
101
101
|
&,
|
|
102
102
|
&:hover,
|
|
103
103
|
&:focus {
|
|
104
|
-
|
|
104
|
+
-webkit-appearance: none;
|
|
105
|
+
-moz-appearance: none;
|
|
106
|
+
appearance: none;
|
|
107
|
+
transition: background-color 5000s ease-in-out 0s !important;
|
|
105
108
|
|
|
106
109
|
:root .dark & {
|
|
110
|
+
-webkit-text-fill-color: theme("colors.gray.300");
|
|
107
111
|
-webkit-box-shadow: inset 0 0 0 1000px theme("colors.gray.800");
|
|
112
|
+
box-shadow: inset 0 0 0 1000px theme("colors.gray.800");
|
|
113
|
+
background-color: theme("colors.gray.800");
|
|
108
114
|
caret-color: white;
|
|
109
|
-
-webkit-text-fill-color: theme("colors.gray.300");
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
:root .light & {
|
|
113
|
-
-webkit-box-shadow: inset 0 0 0 1000px theme("colors.
|
|
118
|
+
-webkit-box-shadow: inset 0 0 0 1000px theme("colors.white");
|
|
119
|
+
box-shadow: inset 0 0 0 1000px theme("colors.white");
|
|
120
|
+
background-color: theme("colors.white");
|
|
114
121
|
}
|
|
115
122
|
}
|
|
116
123
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { FormControlProps } from "@uxf/ui/types";
|
|
1
2
|
import { FC, ReactNode } from "react";
|
|
2
|
-
import { FormControlProps } from "../types";
|
|
3
3
|
import { DropzoneFile } from "./types";
|
|
4
4
|
export interface DropzoneListProps extends FormControlProps<DropzoneFile[]> {
|
|
5
5
|
errorText?: string;
|
|
@@ -1,14 +1,36 @@
|
|
|
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.DropzoneList = void 0;
|
|
7
27
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
8
28
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
9
|
-
const
|
|
10
|
-
const icon_1 = require("
|
|
11
|
-
const loader_1 = require("
|
|
29
|
+
const context_1 = require("@uxf/ui/context");
|
|
30
|
+
const icon_1 = require("@uxf/ui/icon");
|
|
31
|
+
const loader_1 = require("@uxf/ui/loader/loader");
|
|
32
|
+
const get_file_url_1 = require("@uxf/ui/utils/files/get-file-url");
|
|
33
|
+
const react_1 = __importStar(require("react"));
|
|
12
34
|
function formatBytes(bytes, decimals = 2) {
|
|
13
35
|
const k = 1024;
|
|
14
36
|
const dm = decimals < 0 ? 0 : decimals;
|
|
@@ -32,6 +54,7 @@ function getIconName(extension) {
|
|
|
32
54
|
}
|
|
33
55
|
}
|
|
34
56
|
const DropzoneList = (props) => {
|
|
57
|
+
const context = (0, react_1.useContext)(context_1.UiContext);
|
|
35
58
|
const onRemove = (file, isUploading) => () => {
|
|
36
59
|
var _a, _b, _c;
|
|
37
60
|
// eslint-disable-next-line no-alert
|
|
@@ -55,7 +78,7 @@ const DropzoneList = (props) => {
|
|
|
55
78
|
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-dropzone-list__item", !!file.error && classes_1.CLASSES.IS_INVALID) },
|
|
56
79
|
react_1.default.createElement("div", { className: "uxf-dropzone-list__item__block" },
|
|
57
80
|
react_1.default.createElement(icon_1.Icon, { className: "uxf-dropzone-list__item__block__icon", name: getIconName(file.extension) }),
|
|
58
|
-
react_1.default.createElement("span", { className: "uxf-dropzone-list__item__block__file-name" }, file.name)),
|
|
81
|
+
(context === null || context === void 0 ? void 0 : context.domain) && file.id > 0 ? (react_1.default.createElement("a", { className: "uxf-dropzone-list__item__block__file-name-link", href: (0, get_file_url_1.getFileUrl)(context.domain, file), target: "_blank", rel: "noreferrer noopenner" }, file.name)) : (react_1.default.createElement("span", { className: "uxf-dropzone-list__item__block__file-name" }, file.name))),
|
|
59
82
|
react_1.default.createElement("div", { className: "uxf-dropzone-list__item__block" },
|
|
60
83
|
isUploading ? (react_1.default.createElement(loader_1.Loader, { size: "sm" })) : (!file.error &&
|
|
61
84
|
((_c = file.originalFile) === null || _c === void 0 ? void 0 : _c.size) && (react_1.default.createElement("span", { className: "uxf-dropzone-list__item__block__file-size" }, formatBytes(file.originalFile.size)))),
|
|
@@ -30,6 +30,8 @@ exports.ComponentStructure = exports.Default = void 0;
|
|
|
30
30
|
const component_structure_analyzer_1 = __importDefault(require("@uxf/ui/utils/component-structure-analyzer"));
|
|
31
31
|
const uploadFIle_mock_1 = require("@uxf/ui/utils/mocks/uploadFIle.mock");
|
|
32
32
|
const react_1 = __importStar(require("react"));
|
|
33
|
+
const get_provider_config_1 = require("../_private-utils/get-provider-config");
|
|
34
|
+
const context_1 = require("../context");
|
|
33
35
|
const index_1 = require("./index");
|
|
34
36
|
exports.default = {
|
|
35
37
|
title: "UI/Dropzone",
|
|
@@ -46,9 +48,10 @@ function Default() {
|
|
|
46
48
|
react_1.default.createElement(index_1.Dropzone.List, { errorText: "Chyba p\u0159i nahr\u00E1v\u00E1n\u00ED souboru", onAbortWarning: "Opravdu chcete p\u0159eru\u0161it nahr\u00E1v\u00E1n\u00ED?", onChange: setFiles, onRemoveWarning: "Opravdu chcete soubor smazat?", value: files }),
|
|
47
49
|
react_1.default.createElement(index_1.Dropzone.List, { onChange: setFiles, value: files, renderItem: (file) => (react_1.default.createElement("li", { key: file.id },
|
|
48
50
|
react_1.default.createElement("pre", null, JSON.stringify(file, null, 4)))) })));
|
|
49
|
-
return (react_1.default.createElement(
|
|
50
|
-
react_1.default.createElement("div", { className: "
|
|
51
|
-
|
|
51
|
+
return (react_1.default.createElement(context_1.UiContextProvider, { value: (0, get_provider_config_1.getProviderConfig)() },
|
|
52
|
+
react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
53
|
+
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyDropzone),
|
|
54
|
+
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyDropzone))));
|
|
52
55
|
}
|
|
53
56
|
exports.Default = Default;
|
|
54
57
|
function ComponentStructure() {
|
package/file-input/file-input.js
CHANGED
|
@@ -28,20 +28,24 @@ const classes_1 = require("@uxf/core/constants/classes");
|
|
|
28
28
|
const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
29
29
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
30
30
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
31
|
+
const context_1 = require("@uxf/ui/context");
|
|
31
32
|
const form_control_1 = require("@uxf/ui/form-control");
|
|
32
33
|
const input_1 = require("@uxf/ui/input");
|
|
33
34
|
const loader_1 = require("@uxf/ui/loader/loader");
|
|
35
|
+
const get_file_url_1 = require("@uxf/ui/utils/files/get-file-url");
|
|
34
36
|
const react_1 = __importStar(require("react"));
|
|
35
37
|
const file_input_base_1 = require("./file-input-base");
|
|
36
38
|
// eslint-disable-next-line complexity
|
|
37
39
|
exports.FileInput = (0, forwardRef_1.forwardRef)("FileInput", (props, ref) => {
|
|
38
40
|
var _a, _b;
|
|
41
|
+
const context = (0, react_1.useContext)(context_1.UiContext);
|
|
39
42
|
const [isUploading, setIsUploading] = (0, react_1.useState)(false);
|
|
40
43
|
const generatedId = (0, react_1.useId)();
|
|
41
44
|
const id = props.id || generatedId;
|
|
42
45
|
const innerRef = (0, react_1.useRef)(null);
|
|
43
46
|
const input = (0, useInputFocus_1.useInputFocus)(innerRef, props.onBlur, props.onFocus);
|
|
44
47
|
const errorId = props.isInvalid && props.id ? `${props.id}--errormessage` : undefined;
|
|
48
|
+
const fileName = props.value ? `${props.value.name}` : props.placeholder || "No file has been selected yet";
|
|
45
49
|
const onChange = async (_, e) => {
|
|
46
50
|
var _a, _b, _c;
|
|
47
51
|
const file = (_a = e === null || e === void 0 ? void 0 : e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -66,6 +70,6 @@ exports.FileInput = (0, forwardRef_1.forwardRef)("FileInput", (props, ref) => {
|
|
|
66
70
|
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-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, `uxf-input--variant-${(_b = props.variant) !== null && _b !== void 0 ? _b : "default"}`), htmlFor: id },
|
|
67
71
|
react_1.default.createElement("div", { className: "uxf-input__left-addon uxf-file-input__label__button" }, !isUploading ? ("Vyberte soubor") : (react_1.default.createElement(loader_1.Loader, { className: "uxf-file-input__label__loader", size: "sm" }))),
|
|
68
72
|
react_1.default.createElement("div", { className: "uxf-file-input__label__wrapper" },
|
|
69
|
-
react_1.default.createElement("
|
|
73
|
+
(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)),
|
|
70
74
|
props.value && !props.isDisabled && !props.isReadOnly && props.isClearable && (react_1.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })))))));
|
|
71
75
|
});
|
package/package.json
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFileUrl = void 0;
|
|
4
|
+
function getFileUrl(domain, file) {
|
|
5
|
+
return `${domain}/upload/${file.namespace || "default"}/${file.uuid[0]}/${file.uuid[1]}/${file.uuid}.${file.extension}`;
|
|
6
|
+
}
|
|
7
|
+
exports.getFileUrl = getFileUrl;
|