@uxf/ui 1.0.0-beta.28 → 1.0.0-beta.30
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/input/input-element.d.ts +3 -0
- package/input/input-element.js +1 -1
- package/input/input.js +2 -1
- package/package.json +2 -2
- package/text-input/text-input.d.ts +1 -0
- package/text-input/text-input.js +7 -3
- package/text-input/text-input.stories.d.ts +1 -1
- package/text-input/text-input.stories.js +7 -8
package/input/input-element.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { FormControlProps } from "@uxf/ui/types/form-control-props";
|
|
|
3
3
|
export interface InputElementProps extends FormControlProps<string> {
|
|
4
4
|
id?: string;
|
|
5
5
|
placeholder?: string;
|
|
6
|
+
"aria-describedby"?: string;
|
|
7
|
+
"aria-invalid"?: boolean;
|
|
8
|
+
type?: "email" | "number" | "password" | "tel" | "text" | "url";
|
|
6
9
|
}
|
|
7
10
|
declare const _default: React.ForwardRefExoticComponent<InputElementProps & React.RefAttributes<HTMLInputElement>>;
|
|
8
11
|
export default _default;
|
package/input/input-element.js
CHANGED
|
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const forwardRef_1 = require("@uxf/ui/utils/forwardRef");
|
|
8
8
|
function InputElement(props, ref) {
|
|
9
|
-
return (react_1.default.createElement("input", { id: props.id, ref: ref, className: "uxf-input__element", value: props.value, onFocus: props.onFocus, onBlur: props.onBlur, onChange: (event) => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, event.target.value, event); }, placeholder: props.placeholder }));
|
|
9
|
+
return (react_1.default.createElement("input", { id: props.id, ref: ref, className: "uxf-input__element", value: props.value, onFocus: props.onFocus, onBlur: props.onBlur, onChange: (event) => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, event.target.value, event); }, placeholder: props.placeholder, "aria-invalid": props.isInvalid, "aria-describedby": props["aria-describedby"], readOnly: props.isReadOnly, disabled: props.isDisabled, type: props.type }));
|
|
10
10
|
}
|
|
11
11
|
exports.default = (0, forwardRef_1.forwardRef)("InputElement", InputElement);
|
package/input/input.js
CHANGED
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.Input = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
29
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
29
30
|
function getChildrenById(children, componentName) {
|
|
30
31
|
return react_1.Children.toArray(children)
|
|
31
32
|
.filter(react_1.isValidElement)
|
|
@@ -40,7 +41,7 @@ function Input(props) {
|
|
|
40
41
|
const rightAddon = getChildrenById(props.children, "InputRightAddon");
|
|
41
42
|
const leftElement = getChildrenById(props.children, "InputLeftElement");
|
|
42
43
|
const rightElement = getChildrenById(props.children, "InputRightElement");
|
|
43
|
-
const inputGroupClasses = (0, cx_1.cx)("uxf-input", leftAddon && "uxf-input--has-left-addon", leftElement && "uxf-input--has-left-element", rightElement && "uxf-input--has-right-element", rightAddon && "uxf-input--has-right-addon", focused &&
|
|
44
|
+
const inputGroupClasses = (0, cx_1.cx)("uxf-input", leftAddon && "uxf-input--has-left-addon", leftElement && "uxf-input--has-left-element", rightElement && "uxf-input--has-right-element", rightAddon && "uxf-input--has-right-addon", focused && classes_1.CLASSES.IS_FOCUSED, (mainInput === null || mainInput === void 0 ? void 0 : mainInput.props.isInvalid) && classes_1.CLASSES.IS_INVALID, (mainInput === null || mainInput === void 0 ? void 0 : mainInput.props.isDisabled) && classes_1.CLASSES.IS_DISABLED, (mainInput === null || mainInput === void 0 ? void 0 : mainInput.props.isReadOnly) && classes_1.CLASSES.IS_READONLY);
|
|
44
45
|
const onFocus = (e) => {
|
|
45
46
|
var _a, _b;
|
|
46
47
|
setFocused(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/ui",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.30",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@floating-ui/react-dom": "^0.6.0",
|
|
17
17
|
"@headlessui/react": "^1.6.6",
|
|
18
|
-
"@uxf/core": "
|
|
18
|
+
"@uxf/core": "^2.2.5",
|
|
19
19
|
"jump.js": "^1.0.2",
|
|
20
20
|
"ua-parser-js": "^1.0.2"
|
|
21
21
|
},
|
|
@@ -17,6 +17,7 @@ export interface TextInputProps extends FormControlProps<string>, Pick<InputProp
|
|
|
17
17
|
rightElement?: ReactNode;
|
|
18
18
|
leftAddon?: ReactNode;
|
|
19
19
|
rightAddon?: ReactNode;
|
|
20
|
+
type?: "email" | "number" | "password" | "tel" | "text" | "url";
|
|
20
21
|
}
|
|
21
22
|
export declare function TextInput(props: TextInputProps): JSX.Element;
|
|
22
23
|
export {};
|
package/text-input/text-input.js
CHANGED
|
@@ -28,7 +28,11 @@ const input_1 = require("@uxf/ui/input");
|
|
|
28
28
|
const react_1 = __importStar(require("react"));
|
|
29
29
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
30
30
|
function TextInput(props) {
|
|
31
|
+
var _a;
|
|
31
32
|
const [isFocused, setIsFocused] = (0, react_1.useState)(false);
|
|
33
|
+
const generatedId = (0, react_1.useId)();
|
|
34
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : generatedId;
|
|
35
|
+
const errorId = props.isInvalid ? `${id}--error-message` : undefined;
|
|
32
36
|
const rootClassName = (0, cx_1.cx)("uxf-text-input", props.isInvalid && "uxf-text-input--invalid", props.isDisabled && "uxf-text-input--disabled", props.isRequired && "uxf-text-input--required", isFocused && "uxf-text-input--focused");
|
|
33
37
|
const onFocus = (e) => {
|
|
34
38
|
var _a;
|
|
@@ -41,13 +45,13 @@ function TextInput(props) {
|
|
|
41
45
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
42
46
|
};
|
|
43
47
|
return (react_1.default.createElement("div", { className: rootClassName },
|
|
44
|
-
react_1.default.createElement("label", { className: "uxf-text-input__label" }, props.label),
|
|
48
|
+
react_1.default.createElement("label", { className: "uxf-text-input__label", htmlFor: id }, props.label),
|
|
45
49
|
react_1.default.createElement(input_1.Input, { size: props.size, variant: props.variant },
|
|
46
50
|
props.leftAddon && react_1.default.createElement(input_1.Input.LeftAddon, null, props.leftAddon),
|
|
47
51
|
props.leftElement && react_1.default.createElement(input_1.Input.LeftElement, null, props.leftElement),
|
|
48
|
-
react_1.default.createElement(input_1.Input.Element, { name: props.name, value: props.value, onChange: props.onChange, onFocus: onFocus, onBlur: onBlur, isInvalid: props.isInvalid, isRequired: props.isRequired, isReadOnly: props.isReadOnly, isDisabled: props.isDisabled, placeholder: props.placeholder }),
|
|
52
|
+
react_1.default.createElement(input_1.Input.Element, { id: id, name: props.name, value: props.value, onChange: props.onChange, onFocus: onFocus, onBlur: onBlur, isInvalid: props.isInvalid, isRequired: props.isRequired, isReadOnly: props.isReadOnly, isDisabled: props.isDisabled, placeholder: props.placeholder, "aria-describedby": errorId, type: props.type }),
|
|
49
53
|
props.rightElement && react_1.default.createElement(input_1.Input.RightElement, null, props.rightElement),
|
|
50
54
|
props.rightAddon && react_1.default.createElement(input_1.Input.RightAddon, null, props.rightAddon)),
|
|
51
|
-
react_1.default.createElement("div", { className: "uxf-text-input__helper-text" }, props.helperText)));
|
|
55
|
+
react_1.default.createElement("div", { className: "uxf-text-input__helper-text", id: errorId }, props.helperText)));
|
|
52
56
|
}
|
|
53
57
|
exports.TextInput = TextInput;
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.ComponentStructure = exports.
|
|
29
|
+
exports.ComponentStructure = exports.Full = void 0;
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
31
|
const text_input_1 = require("@uxf/ui/text-input");
|
|
32
32
|
const component_structure_analyzer_1 = __importDefault(require("@uxf/ui/utils/component-structure-analyzer"));
|
|
@@ -34,16 +34,15 @@ exports.default = {
|
|
|
34
34
|
title: "UI/TextInput",
|
|
35
35
|
component: text_input_1.TextInput,
|
|
36
36
|
};
|
|
37
|
-
function
|
|
37
|
+
function Full() {
|
|
38
38
|
const [value, onChange] = (0, react_1.useState)("");
|
|
39
|
-
const [isInvalid, setInvalid] = (0, react_1.useState)(false);
|
|
40
39
|
return (react_1.default.createElement("div", { className: "space-y-4" },
|
|
41
|
-
react_1.default.createElement(
|
|
42
|
-
react_1.default.createElement(text_input_1.TextInput, { label: "
|
|
43
|
-
react_1.default.createElement(text_input_1.TextInput, { label: "
|
|
44
|
-
react_1.default.createElement(text_input_1.TextInput, { label: "
|
|
40
|
+
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..." }),
|
|
41
|
+
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 }),
|
|
42
|
+
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 }),
|
|
43
|
+
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 })));
|
|
45
44
|
}
|
|
46
|
-
exports.
|
|
45
|
+
exports.Full = Full;
|
|
47
46
|
function ComponentStructure() {
|
|
48
47
|
const [value, onChange] = (0, react_1.useState)("");
|
|
49
48
|
return (react_1.default.createElement(component_structure_analyzer_1.default, null,
|