@uxf/ui 11.10.0 → 11.11.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/color-scheme/get-color-scheme-class-name.d.ts +2 -0
- package/color-scheme/get-color-scheme-class-name.js +14 -0
- package/color-scheme/get-color-scheme.d.ts +2 -0
- package/color-scheme/get-color-scheme.js +17 -0
- package/color-scheme/index.d.ts +2 -0
- package/color-scheme/index.js +5 -1
- package/color-scheme/use-color-scheme.d.ts +2 -1
- package/color-scheme/use-color-scheme.js +10 -13
- package/css/button-list.css +2 -0
- package/input/input-element.js +1 -1
- package/package.json +1 -1
- package/select/select.stories.d.ts +0 -9
- package/select/select.stories.js +1 -7
- package/text-input/text-input.stories.d.ts +0 -5
- package/text-input/text-input.stories.js +7 -13
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getColorSchemeClassName = void 0;
|
|
4
|
+
function getColorSchemeClassName(colorScheme) {
|
|
5
|
+
switch (colorScheme) {
|
|
6
|
+
case "dark":
|
|
7
|
+
return "dark";
|
|
8
|
+
case "light":
|
|
9
|
+
return "light";
|
|
10
|
+
default:
|
|
11
|
+
return "light";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.getColorSchemeClassName = getColorSchemeClassName;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getColorScheme = void 0;
|
|
4
|
+
const isServer_1 = require("@uxf/core/utils/isServer");
|
|
5
|
+
function getColorScheme() {
|
|
6
|
+
if (isServer_1.isServer) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const bodyClassList = document.body.classList;
|
|
10
|
+
if (bodyClassList.contains("light")) {
|
|
11
|
+
return "light";
|
|
12
|
+
}
|
|
13
|
+
if (bodyClassList.contains("dark")) {
|
|
14
|
+
return "dark";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.getColorScheme = getColorScheme;
|
package/color-scheme/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { COLOR_SCHEME_DEFAULTS } from "./color-scheme-defaults";
|
|
2
|
+
export { getColorScheme } from "./get-color-scheme";
|
|
3
|
+
export { getColorSchemeClassName } from "./get-color-scheme-class-name";
|
|
2
4
|
export { useColorScheme } from "./use-color-scheme";
|
|
3
5
|
export { useToggleColorScheme } from "./use-toggle-color-scheme";
|
package/color-scheme/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useToggleColorScheme = exports.useColorScheme = exports.COLOR_SCHEME_DEFAULTS = void 0;
|
|
3
|
+
exports.useToggleColorScheme = exports.useColorScheme = exports.getColorSchemeClassName = exports.getColorScheme = exports.COLOR_SCHEME_DEFAULTS = void 0;
|
|
4
4
|
var color_scheme_defaults_1 = require("./color-scheme-defaults");
|
|
5
5
|
Object.defineProperty(exports, "COLOR_SCHEME_DEFAULTS", { enumerable: true, get: function () { return color_scheme_defaults_1.COLOR_SCHEME_DEFAULTS; } });
|
|
6
|
+
var get_color_scheme_1 = require("./get-color-scheme");
|
|
7
|
+
Object.defineProperty(exports, "getColorScheme", { enumerable: true, get: function () { return get_color_scheme_1.getColorScheme; } });
|
|
8
|
+
var get_color_scheme_class_name_1 = require("./get-color-scheme-class-name");
|
|
9
|
+
Object.defineProperty(exports, "getColorSchemeClassName", { enumerable: true, get: function () { return get_color_scheme_class_name_1.getColorSchemeClassName; } });
|
|
6
10
|
var use_color_scheme_1 = require("./use-color-scheme");
|
|
7
11
|
Object.defineProperty(exports, "useColorScheme", { enumerable: true, get: function () { return use_color_scheme_1.useColorScheme; } });
|
|
8
12
|
var use_toggle_color_scheme_1 = require("./use-toggle-color-scheme");
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { ColorScheme } from "../types";
|
|
2
|
+
export declare function useColorScheme(): ColorScheme | undefined;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.useColorScheme = void 0;
|
|
4
|
-
const
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const get_color_scheme_1 = require("./get-color-scheme");
|
|
5
7
|
function useColorScheme() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
if (bodyClassList.contains("dark")) {
|
|
15
|
-
return "dark";
|
|
16
|
-
}
|
|
17
|
-
};
|
|
8
|
+
const [colorScheme, setColorScheme] = (0, react_1.useState)(get_color_scheme_1.getColorScheme);
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
const observer = new MutationObserver((mutations) => mutations.forEach(() => setColorScheme((0, get_color_scheme_1.getColorScheme)())));
|
|
11
|
+
observer.observe(document.body, { attributes: true, attributeFilter: ["class"] });
|
|
12
|
+
return () => observer.disconnect();
|
|
13
|
+
}, []);
|
|
14
|
+
return colorScheme;
|
|
18
15
|
}
|
|
19
16
|
exports.useColorScheme = useColorScheme;
|
package/css/button-list.css
CHANGED
package/input/input-element.js
CHANGED
|
@@ -28,6 +28,6 @@ const react_1 = __importStar(require("react"));
|
|
|
28
28
|
exports.InputElement = (0, react_1.forwardRef)((props, ref) => {
|
|
29
29
|
const onChange = (event) => props.onChange(event.target.value, event);
|
|
30
30
|
const filteredProps = Object.fromEntries(Object.entries(props).filter((p) => p[0].startsWith("aria-") || p[0].startsWith("data-")));
|
|
31
|
-
return (react_1.default.createElement("input", { ...filteredProps, "aria-describedby": props["aria-describedby"], "aria-invalid": props.isInvalid, autoComplete: props.autoComplete, autoFocus: props.autoFocus, className: "uxf-input__element", disabled: props.isDisabled, form: props.form, id: props.id, inputMode: props.inputMode, max: props.max, maxLength: props.maxLength, min: props.min, minLength: props.minLength, onBlur: props.onBlur, onChange: onChange, onFocus: props.onFocus, onKeyDown: props.onKeyDown, pattern: props.pattern, placeholder: props.placeholder, readOnly: props.isReadOnly, ref: ref, step: props.step, tabIndex: props.isReadOnly ? -1 : undefined, type: props.type, value: props.value }));
|
|
31
|
+
return (react_1.default.createElement("input", { ...filteredProps, "aria-describedby": props["aria-describedby"], "aria-invalid": props.isInvalid, autoComplete: props.autoComplete, autoFocus: props.autoFocus, className: "uxf-input__element", disabled: props.isDisabled, form: props.form, id: props.id, inputMode: props.inputMode, max: props.max, maxLength: props.maxLength, min: props.min, minLength: props.minLength, name: props.name, onBlur: props.onBlur, onChange: onChange, onFocus: props.onFocus, onKeyDown: props.onKeyDown, pattern: props.pattern, placeholder: props.placeholder, readOnly: props.isReadOnly, ref: ref, step: props.step, tabIndex: props.isReadOnly ? -1 : undefined, type: props.type, value: props.value }));
|
|
32
32
|
});
|
|
33
33
|
exports.InputElement.displayName = "UxfUiInputElement";
|
package/package.json
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SelectOption } from "./index";
|
|
3
|
-
declare const _default: {
|
|
4
|
-
title: string;
|
|
5
|
-
component: {
|
|
6
|
-
<ValueId = import("../_select-base").SelectBaseValueId, Option = SelectOption<ValueId>, Value = Option>(props: import("./select").SelectProps<ValueId, Option, ValueId>): React.JSX.Element;
|
|
7
|
-
displayName: string;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export default _default;
|
|
11
2
|
export declare function Default(): React.JSX.Element;
|
|
12
3
|
export declare function ComponentStructure(): React.JSX.Element;
|
package/select/select.stories.js
CHANGED
|
@@ -31,10 +31,6 @@ const react_1 = __importStar(require("react"));
|
|
|
31
31
|
const action_1 = require("../utils/action");
|
|
32
32
|
const component_structure_analyzer_1 = __importDefault(require("../utils/component-structure-analyzer"));
|
|
33
33
|
const index_1 = require("./index");
|
|
34
|
-
exports.default = {
|
|
35
|
-
title: "UI/Select",
|
|
36
|
-
component: index_1.Select,
|
|
37
|
-
};
|
|
38
34
|
const options = [
|
|
39
35
|
{ id: "one", label: "Option one" },
|
|
40
36
|
{ id: "two", label: "Option two disabled", disabled: true },
|
|
@@ -54,7 +50,7 @@ function Default() {
|
|
|
54
50
|
console.log("Select value: ", v);
|
|
55
51
|
setValue(v);
|
|
56
52
|
});
|
|
57
|
-
|
|
53
|
+
return (react_1.default.createElement("div", { className: "flex flex-col gap-2" },
|
|
58
54
|
react_1.default.createElement(index_1.Select, { helperText: "Helper text", label: "Default select", onChange: onChange, options: options, placeholder: "Vyberte...", value: value }),
|
|
59
55
|
react_1.default.createElement(index_1.Select, { helperText: "Helper text", isInvalid: true, label: "Invalid select", onChange: onChange, options: options, placeholder: "Vyberte...", value: value, isClearable: true }),
|
|
60
56
|
react_1.default.createElement(index_1.Select, { helperText: "Helper text", isDisabled: true, label: "Disabled select", onChange: onChange, options: options, placeholder: "Vyberte...", value: value }),
|
|
@@ -71,8 +67,6 @@ function Default() {
|
|
|
71
67
|
isSelected && " (selected)")), renderSelectedOption: (option) => react_1.default.createElement(react_1.default.Fragment, null,
|
|
72
68
|
"Selected: ",
|
|
73
69
|
option.label) })));
|
|
74
|
-
return (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
75
|
-
react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" }, storySelects)));
|
|
76
70
|
}
|
|
77
71
|
exports.Default = Default;
|
|
78
72
|
function ComponentStructure() {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
declare const _default: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: React.ForwardRefExoticComponent<import("@uxf/ui/text-input").TextInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
|
-
};
|
|
6
|
-
export default _default;
|
|
7
2
|
export declare function Default(): React.JSX.Element;
|
|
8
3
|
export declare function ComponentStructure(): React.JSX.Element;
|
|
@@ -35,10 +35,6 @@ const text_input_1 = require("@uxf/ui/text-input");
|
|
|
35
35
|
const component_structure_analyzer_1 = __importDefault(require("@uxf/ui/utils/component-structure-analyzer"));
|
|
36
36
|
const react_1 = __importStar(require("react"));
|
|
37
37
|
const action_1 = require("../utils/action");
|
|
38
|
-
exports.default = {
|
|
39
|
-
title: "UI/TextInput",
|
|
40
|
-
component: text_input_1.TextInput,
|
|
41
|
-
};
|
|
42
38
|
function Default() {
|
|
43
39
|
const [value, setValue] = (0, react_1.useState)("");
|
|
44
40
|
const [timeValue, setTimeValue] = (0, react_1.useState)("");
|
|
@@ -51,16 +47,14 @@ function Default() {
|
|
|
51
47
|
variant: isCopied ? "success" : "error",
|
|
52
48
|
});
|
|
53
49
|
});
|
|
54
|
-
|
|
55
|
-
react_1.default.createElement(text_input_1.TextInput, { label: "Default input", value: value, onChange: onChange, helperText: "Helper text", leftAddon: "https://", rightAddon: ".cz", leftElement: "\uD83C\uDF37", rightElement: "\uD83D\uDD14", placeholder: "Some beautiful placeholder..." }),
|
|
56
|
-
react_1.default.createElement(text_input_1.TextInput, { label: "Error input", value: value, onChange: onChange, helperText: "Error helper text", leftAddon: "https://", rightAddon: ".cz", leftElement: "\uD83C\uDF37", rightElement: "\uD83D\uDD14", placeholder: "Some beautiful placeholder...", isInvalid: true }),
|
|
57
|
-
react_1.default.createElement(text_input_1.TextInput, { label: "Read only input", value: value, onChange: onChange, helperText: "Error helper text", leftAddon: "https://", rightAddon: ".cz", leftElement: "\uD83C\uDF37", rightElement: "\uD83D\uDD14", placeholder: "Some beautiful placeholder...", isReadOnly: true }),
|
|
58
|
-
react_1.default.createElement(text_input_1.TextInput, { label: "Disabled input", value: value, onChange: onChange, helperText: "Error helper text", leftAddon: "https://", rightAddon: ".cz", leftElement: "\uD83C\uDF37", rightElement: "\uD83D\uDD14", placeholder: "Some beautiful placeholder...", isDisabled: true }),
|
|
59
|
-
react_1.default.createElement(text_input_1.TextInput, { label: "Default html time input", value: timeValue, onChange: onTimeChange, placeholder: "Some beautiful placeholder...", type: "time" }),
|
|
60
|
-
react_1.default.createElement(text_input_1.TextInput, { label: "Copy to clipboard input", leftAddon: "I can be copied!", onChange: onChange, placeholder: "Some beautiful placeholder...", rightAddon: react_1.default.createElement(button_1.Button, { className: "size-full rounded-l-none border-none", disabled: value === "", onClick: onCopy, variant: "white" },
|
|
50
|
+
return (react_1.default.createElement("div", { className: "space-y-2 p-20" },
|
|
51
|
+
react_1.default.createElement(text_input_1.TextInput, { name: "default", label: "Default input", value: value, onChange: onChange, helperText: "Helper text", leftAddon: "https://", rightAddon: ".cz", leftElement: "\uD83C\uDF37", rightElement: "\uD83D\uDD14", placeholder: "Some beautiful placeholder..." }),
|
|
52
|
+
react_1.default.createElement(text_input_1.TextInput, { name: "error", label: "Error input", value: value, onChange: onChange, helperText: "Error helper text", leftAddon: "https://", rightAddon: ".cz", leftElement: "\uD83C\uDF37", rightElement: "\uD83D\uDD14", placeholder: "Some beautiful placeholder...", isInvalid: true }),
|
|
53
|
+
react_1.default.createElement(text_input_1.TextInput, { name: "readOnly", label: "Read only input", value: value, onChange: onChange, helperText: "Error helper text", leftAddon: "https://", rightAddon: ".cz", leftElement: "\uD83C\uDF37", rightElement: "\uD83D\uDD14", placeholder: "Some beautiful placeholder...", isReadOnly: true }),
|
|
54
|
+
react_1.default.createElement(text_input_1.TextInput, { name: "disabled", label: "Disabled input", value: value, onChange: onChange, helperText: "Error helper text", leftAddon: "https://", rightAddon: ".cz", leftElement: "\uD83C\uDF37", rightElement: "\uD83D\uDD14", placeholder: "Some beautiful placeholder...", isDisabled: true }),
|
|
55
|
+
react_1.default.createElement(text_input_1.TextInput, { name: "defaultHtmlTime", label: "Default html time input", value: timeValue, onChange: onTimeChange, placeholder: "Some beautiful placeholder...", type: "time" }),
|
|
56
|
+
react_1.default.createElement(text_input_1.TextInput, { name: "copyToClipboard", label: "Copy to clipboard input", leftAddon: "I can be copied!", onChange: onChange, placeholder: "Some beautiful placeholder...", rightAddon: react_1.default.createElement(button_1.Button, { className: "size-full rounded-l-none border-none", disabled: value === "", onClick: onCopy, variant: "white" },
|
|
61
57
|
react_1.default.createElement(icon_1.Icon, { className: "w-4", name: "copy" })), value: value })));
|
|
62
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
63
|
-
react_1.default.createElement("div", { className: "space-y-2 p-20" }, storyTextInputs)));
|
|
64
58
|
}
|
|
65
59
|
exports.Default = Default;
|
|
66
60
|
function ComponentStructure() {
|