@uxf/ui 1.0.0-beta.35 → 1.0.0-beta.37
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/combobox/combobox.js +2 -2
- package/form-control/form-control.d.ts +13 -0
- package/form-control/form-control.js +19 -0
- package/form-control/form-control.stories.d.ts +13 -0
- package/form-control/form-control.stories.js +23 -0
- package/form-control/index.d.ts +1 -0
- package/form-control/index.js +17 -0
- package/icon/icon.d.ts +1 -1
- package/image-gallery/components/gallery.js +5 -2
- package/image-gallery/image-gallery.js +3 -3
- package/image-gallery/image-gallery.stories.js +1 -1
- package/image-gallery/image.js +3 -1
- package/image-gallery/index.d.ts +1 -0
- package/image-gallery/index.js +1 -0
- package/image-gallery/types.d.ts +2 -1
- package/image-gallery/use-image.d.ts +1 -1
- package/image-gallery/use-image.js +1 -1
- package/label/label.d.ts +2 -1
- package/label/label.js +2 -1
- package/package.json +1 -1
- package/radio/radio.d.ts +2 -8
- package/radio/radio.js +2 -6
- package/radio/radio.stories.js +13 -5
- package/radio-group/radio-group.js +1 -1
- package/select/select.js +2 -3
- package/text-input/text-input.js +5 -5
package/combobox/combobox.js
CHANGED
|
@@ -48,10 +48,10 @@ function Combobox(props, ref) {
|
|
|
48
48
|
react_2.default.createElement(react_1.Combobox.Button, { as: "div", className: (0, cx_1.cx)("uxf-combobox__button", (renderProps.open || input.focused) && classes_1.CLASSES.IS_FOCUSED, renderProps.disabled && classes_1.CLASSES.IS_DISABLED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isInvalid && classes_1.CLASSES.IS_INVALID), onBlur: input.onBlur, onFocus: input.onFocus, tabIndex: props.isDisabled || props.isReadOnly ? undefined : 0, ref: stableRef, "aria-invalid": props.isInvalid, "aria-describedby": errorId },
|
|
49
49
|
react_2.default.createElement(react_1.Combobox.Input, { className: (0, cx_1.cx)("uxf-combobox__input"), displayValue: (item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : ""; }, onBlur: props.onBlur, onChange: (event) => setQuery(event.target.value), placeholder: props.placeholder, ref: stableRef, type: "text" }),
|
|
50
50
|
renderProps.open ? (react_2.default.createElement(icon_1.Icon, { Component: icon_1.ChevronUpIcon, size: 12 })) : (react_2.default.createElement(icon_1.Icon, { Component: icon_1.ChevronDownIcon, size: 12 }))),
|
|
51
|
+
props.helperText && (react_2.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID) }, props.helperText)),
|
|
51
52
|
react_2.default.createElement(react_1.Combobox.Options, { className: "uxf-dropdown", ref: dropdown.floating, style: dropdown.style }, filteredData.map((option) => {
|
|
52
53
|
var _a, _b, _c, _d;
|
|
53
54
|
return (react_2.default.createElement(react_1.Combobox.Option, { key: (_b = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, option)) !== null && _b !== void 0 ? _b : option.id, value: 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) }, (_d = (_c = props.renderOption) === null || _c === void 0 ? void 0 : _c.call(props, option)) !== null && _d !== void 0 ? _d : option.label));
|
|
54
|
-
}))
|
|
55
|
-
react_2.default.createElement("div", { className: "uxf-combobox__helper-text" }, props.isInvalid && props.error ? props.error : props.helperText)))));
|
|
55
|
+
}))))));
|
|
56
56
|
}
|
|
57
57
|
exports.default = (0, forwardRef_1.forwardRef)("Combobox", Combobox);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
interface FormControlProps {
|
|
3
|
+
form?: string;
|
|
4
|
+
inputId: string;
|
|
5
|
+
errorId?: string;
|
|
6
|
+
isRequired?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
helperText?: ReactNode;
|
|
10
|
+
children?: ReactElement;
|
|
11
|
+
}
|
|
12
|
+
export declare function FormControl(props: FormControlProps): JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FormControl = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const label_1 = require("../label");
|
|
9
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
10
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
11
|
+
// TODO - tohle asi ještě nějak předělám (ten interface je trochu nelogickej)
|
|
12
|
+
function FormControl(props) {
|
|
13
|
+
const helperTextClassName = (0, cx_1.cx)("uxf-helper-text", props.errorId && classes_1.CLASSES.IS_INVALID);
|
|
14
|
+
return (react_1.default.createElement("div", { className: props.className },
|
|
15
|
+
react_1.default.createElement(label_1.Label, { isRequired: props.isRequired, htmlFor: props.inputId, form: props.form }, props.label),
|
|
16
|
+
props.children,
|
|
17
|
+
react_1.default.createElement("div", { className: helperTextClassName }, props.helperText)));
|
|
18
|
+
}
|
|
19
|
+
exports.FormControl = FormControl;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormControl } from "./form-control";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof FormControl;
|
|
6
|
+
parameters: {
|
|
7
|
+
actions: {
|
|
8
|
+
argTypesRegex: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
13
|
+
export declare function Default(): JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Default = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const form_control_1 = require("./form-control");
|
|
9
|
+
exports.default = {
|
|
10
|
+
title: "UI/FormControl",
|
|
11
|
+
component: form_control_1.FormControl,
|
|
12
|
+
parameters: { actions: { argTypesRegex: "^on.*" } },
|
|
13
|
+
};
|
|
14
|
+
function Default() {
|
|
15
|
+
return (react_1.default.createElement("div", { className: "space-y-4" },
|
|
16
|
+
react_1.default.createElement(form_control_1.FormControl, { inputId: "default", helperText: "helper text", label: "Default" },
|
|
17
|
+
react_1.default.createElement("div", null, "Default")),
|
|
18
|
+
react_1.default.createElement(form_control_1.FormControl, { inputId: "default", helperText: "helper text", label: "Default", isRequired: true },
|
|
19
|
+
react_1.default.createElement("div", null, "Is required")),
|
|
20
|
+
react_1.default.createElement(form_control_1.FormControl, { inputId: "error", helperText: "helper text", label: "Default", errorId: "error--error", isRequired: true },
|
|
21
|
+
react_1.default.createElement("div", null, "Is invalid"))));
|
|
22
|
+
}
|
|
23
|
+
exports.Default = Default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./form-control";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./form-control"), exports);
|
package/icon/icon.d.ts
CHANGED
|
@@ -31,7 +31,9 @@ const previous_button_1 = __importDefault(require("./previous-button"));
|
|
|
31
31
|
const next_button_1 = __importDefault(require("./next-button"));
|
|
32
32
|
const dot_1 = __importDefault(require("./dot"));
|
|
33
33
|
const react_1 = __importStar(require("react"));
|
|
34
|
+
const resizer_1 = require("@uxf/core/utils/resizer");
|
|
34
35
|
function Gallery(props) {
|
|
36
|
+
var _a;
|
|
35
37
|
(0, react_1.useEffect)(() => {
|
|
36
38
|
const onKeyDown = (event) => {
|
|
37
39
|
switch (event.key) {
|
|
@@ -54,15 +56,16 @@ function Gallery(props) {
|
|
|
54
56
|
};
|
|
55
57
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
58
|
}, []);
|
|
59
|
+
const imageSrc = props.images[props.imageIndex].src;
|
|
57
60
|
return (react_1.default.createElement("div", { className: "fixed inset-0 top-0 bottom-0 z-50 flex flex-col bg-black bg-opacity-75 transition-opacity" },
|
|
58
61
|
react_1.default.createElement("div", { className: "flex justify-end" },
|
|
59
62
|
react_1.default.createElement(close_button_1.default, { onClick: props.onClose })),
|
|
60
63
|
react_1.default.createElement("div", { className: "container mx-auto flex h-full flex-1 flex-col" },
|
|
61
64
|
react_1.default.createElement("div", { className: "relative flex flex-1 items-center justify-center" },
|
|
62
|
-
react_1.default.createElement("img", { alt: "", className: "absolute left-0 right-0 top-0 h-full w-full object-contain", src:
|
|
65
|
+
react_1.default.createElement("img", { alt: "", className: "absolute left-0 right-0 top-0 h-full w-full object-contain", src: typeof imageSrc === "string" ? imageSrc : (_a = (0, resizer_1.resizerImageUrl)(imageSrc)) !== null && _a !== void 0 ? _a : "" }),
|
|
63
66
|
react_1.default.createElement("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-between p-2" },
|
|
64
67
|
react_1.default.createElement(previous_button_1.default, { onClick: props.onPrevious }),
|
|
65
68
|
react_1.default.createElement(next_button_1.default, { onClick: props.onNext })))),
|
|
66
|
-
react_1.default.createElement("div", { className: "row mx-auto flex space-x-2 p-4" }, props.images.map((
|
|
69
|
+
react_1.default.createElement("div", { className: "row mx-auto flex space-x-2 p-4" }, props.images.map((image, index) => (react_1.default.createElement(dot_1.default, { key: typeof image.src === "string" ? image.src : image.src.uuid, active: index === props.imageIndex }))))));
|
|
67
70
|
}
|
|
68
71
|
exports.default = Gallery;
|
|
@@ -32,9 +32,9 @@ const gallery_1 = __importDefault(require("./components/gallery"));
|
|
|
32
32
|
function ImageGallery(props) {
|
|
33
33
|
const [images, setImages] = (0, react_1.useState)([]);
|
|
34
34
|
const [imageIndex, setImageIndex] = (0, react_1.useState)(null);
|
|
35
|
-
const registerImage = (0, react_1.
|
|
36
|
-
const unregisterImage = (0, react_1.
|
|
37
|
-
const openGallery = (image) => setImageIndex(images.findIndex((i) => i.src === image.src));
|
|
35
|
+
const registerImage = (0, react_1.useCallback)((image) => setImages((v) => [...v, image]), []);
|
|
36
|
+
const unregisterImage = (0, react_1.useCallback)((image) => setImages((v) => v.filter((u) => u.src !== image.src)), []);
|
|
37
|
+
const openGallery = (0, react_1.useCallback)((image) => setImageIndex(images.findIndex((i) => i.src === image.src)), [images]);
|
|
38
38
|
const onPrevious = (0, react_1.useCallback)(() => {
|
|
39
39
|
setImageIndex((v) => (v === null ? null : v - 1));
|
|
40
40
|
}, []);
|
|
@@ -21,6 +21,6 @@ const images = [
|
|
|
21
21
|
];
|
|
22
22
|
function Default() {
|
|
23
23
|
return (react_1.default.createElement(image_gallery_1.default, null,
|
|
24
|
-
react_1.default.createElement("div", { className: "flex-direction flex gap-2" }, images.map((src) => (react_1.default.createElement(image_1.default, { key: src, src: src, className: "h-56 w-56 cursor-pointer object-cover transition-transform hover:scale-105" }))))));
|
|
24
|
+
react_1.default.createElement("div", { className: "flex-direction flex gap-2" }, images.map((src) => (react_1.default.createElement(image_1.default, { key: typeof src === "string" ? src : src.uuid, src: src, className: "h-56 w-56 cursor-pointer object-cover transition-transform hover:scale-105" }))))));
|
|
25
25
|
}
|
|
26
26
|
exports.Default = Default;
|
package/image-gallery/image.js
CHANGED
|
@@ -5,8 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const use_image_1 = require("./use-image");
|
|
8
|
+
const resizer_1 = require("@uxf/core/utils/resizer");
|
|
8
9
|
function Image(props) {
|
|
10
|
+
var _a;
|
|
9
11
|
const openGallery = (0, use_image_1.useImage)(props);
|
|
10
|
-
return (react_1.default.createElement("img", { src: props.src, alt: props.alt, title: props.title, className: props.className, onClick:
|
|
12
|
+
return (react_1.default.createElement("img", { src: typeof props.src === "string" ? props.src : (_a = (0, resizer_1.resizerImageUrl)(props.src)) !== null && _a !== void 0 ? _a : "", alt: props.alt, title: props.title, className: props.className, onClick: openGallery }));
|
|
11
13
|
}
|
|
12
14
|
exports.default = Image;
|
package/image-gallery/index.d.ts
CHANGED
package/image-gallery/index.js
CHANGED
|
@@ -23,3 +23,4 @@ Object.defineProperty(exports, "Image", { enumerable: true, get: function () { r
|
|
|
23
23
|
var image_gallery_1 = require("./image-gallery");
|
|
24
24
|
Object.defineProperty(exports, "ImageGallery", { enumerable: true, get: function () { return __importDefault(image_gallery_1).default; } });
|
|
25
25
|
__exportStar(require("./use-image"), exports);
|
|
26
|
+
__exportStar(require("./types"), exports);
|
package/image-gallery/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ImageGalleryImageProps } from "./types";
|
|
2
|
-
export declare function useImage(props: ImageGalleryImageProps): (
|
|
2
|
+
export declare function useImage(props: ImageGalleryImageProps): () => void;
|
package/label/label.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { MouseEventHandler, ReactNode } from "react";
|
|
2
2
|
export interface LabelProps {
|
|
3
3
|
children?: ReactNode;
|
|
4
|
+
className?: string;
|
|
4
5
|
htmlFor?: string;
|
|
5
6
|
form?: string;
|
|
6
7
|
onClick?: MouseEventHandler<HTMLLabelElement>;
|
|
7
|
-
|
|
8
|
+
isRequired?: boolean;
|
|
8
9
|
}
|
|
9
10
|
declare const _default: React.ForwardRefExoticComponent<LabelProps & React.RefAttributes<HTMLLabelElement>>;
|
|
10
11
|
export default _default;
|
package/label/label.js
CHANGED
|
@@ -7,6 +7,7 @@ const forwardRef_1 = require("@uxf/ui/utils/forwardRef");
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
9
9
|
function Label(props, ref) {
|
|
10
|
-
|
|
10
|
+
const className = (0, cx_1.cx)("uxf-label", props.isRequired && "is-required", props.className);
|
|
11
|
+
return (react_1.default.createElement("label", { className: className, ref: ref, htmlFor: props.htmlFor, form: props.form, onClick: props.onClick }, props.children));
|
|
11
12
|
}
|
|
12
13
|
exports.default = (0, forwardRef_1.forwardRef)("Label", Label);
|
package/package.json
CHANGED
package/radio/radio.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
checked?: boolean;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
invalid?: boolean;
|
|
7
|
-
label: string;
|
|
8
|
-
className?: string;
|
|
9
|
-
}
|
|
2
|
+
import { FormControlProps } from "../types";
|
|
3
|
+
export declare type RadioProps = FormControlProps<boolean>;
|
|
10
4
|
declare const _default: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
5
|
export default _default;
|
package/radio/radio.js
CHANGED
|
@@ -8,11 +8,7 @@ const cx_1 = require("@uxf/core/utils/cx");
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const forwardRef_1 = require("../utils/forwardRef");
|
|
10
10
|
function Radio(props, ref) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-radio__control", active && classes_1.CLASSES.IS_FOCUSED, checked && classes_1.CLASSES.IS_SELECTED, disabled && classes_1.CLASSES.IS_DISABLED, invalid && classes_1.CLASSES.IS_INVALID, className), ref: ref, ...restProps },
|
|
14
|
-
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-radio", active && classes_1.CLASSES.IS_FOCUSED, checked && classes_1.CLASSES.IS_SELECTED, disabled && classes_1.CLASSES.IS_DISABLED, invalid && classes_1.CLASSES.IS_INVALID) },
|
|
15
|
-
react_1.default.createElement("div", { className: (0, cx_1.cx)(checked && classes_1.CLASSES.IS_SELECTED, "uxf-radio__inner") })),
|
|
16
|
-
react_1.default.createElement("p", { className: "cursor-default" }, label)));
|
|
11
|
+
return (react_1.default.createElement("div", { ref: ref, className: (0, cx_1.cx)("uxf-radio", props.value && classes_1.CLASSES.IS_SELECTED, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY), onClick: () => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, !props.value); } },
|
|
12
|
+
react_1.default.createElement("div", { className: "uxf-radio__inner" })));
|
|
17
13
|
}
|
|
18
14
|
exports.default = (0, forwardRef_1.forwardRef)("Radio", Radio);
|
package/radio/radio.stories.js
CHANGED
|
@@ -11,10 +11,18 @@ exports.default = {
|
|
|
11
11
|
component: index_1.Radio,
|
|
12
12
|
};
|
|
13
13
|
function Default() {
|
|
14
|
-
return (react_1.default.createElement("div",
|
|
15
|
-
react_1.default.createElement(
|
|
16
|
-
react_1.default.createElement(
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
return (react_1.default.createElement("div", null,
|
|
15
|
+
react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold" }, "Default"),
|
|
16
|
+
react_1.default.createElement("div", { className: "flex flex-row gap-4" },
|
|
17
|
+
react_1.default.createElement(index_1.Radio, { value: false }),
|
|
18
|
+
react_1.default.createElement(index_1.Radio, { value: true })),
|
|
19
|
+
react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold" }, "Invalid"),
|
|
20
|
+
react_1.default.createElement("div", { className: "flex flex-row gap-4" },
|
|
21
|
+
react_1.default.createElement(index_1.Radio, { value: false, isInvalid: true }),
|
|
22
|
+
react_1.default.createElement(index_1.Radio, { value: true, isInvalid: true })),
|
|
23
|
+
react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold" }, "Disabled"),
|
|
24
|
+
react_1.default.createElement("div", { className: "flex flex-row gap-4" },
|
|
25
|
+
react_1.default.createElement(index_1.Radio, { value: false, isDisabled: true }),
|
|
26
|
+
react_1.default.createElement(index_1.Radio, { value: true, isDisabled: true }))));
|
|
19
27
|
}
|
|
20
28
|
exports.Default = Default;
|
|
@@ -39,7 +39,7 @@ function RadioGroup(props, ref) {
|
|
|
39
39
|
const errorId = invalid ? `${id}--errormessage` : undefined;
|
|
40
40
|
return (react_1.default.createElement(react_2.RadioGroup, { className: `_form-field ${className || ""}`, disabled: disabled, id: id, value: value, onChange: onChange, style: style },
|
|
41
41
|
!hiddenLabel && (react_1.default.createElement(react_2.RadioGroup.Label, { as: label_1.Label, className: "mb-2" }, label)),
|
|
42
|
-
react_1.default.createElement("div", { className: `flex ${forceColumn ? "flex-col" : "flex-wrap items-center"} focus-visible:ring-gray-dark outline-none focus-visible:ring-2`, onBlur: onBlur, onFocus: onFocus, ref: (0, composeRefs_1.composeRefs)(innerRef, ref), tabIndex: disabled ? -1 : 0 }, options.map((option) => (react_1.default.createElement(react_2.RadioGroup.Option, { as: react_1.Fragment, disabled: option.disabled, key: option.value.toString(), value: option.value }, (o) =>
|
|
42
|
+
react_1.default.createElement("div", { className: `flex ${forceColumn ? "flex-col" : "flex-wrap items-center"} focus-visible:ring-gray-dark outline-none focus-visible:ring-2`, onBlur: onBlur, onFocus: onFocus, ref: (0, composeRefs_1.composeRefs)(innerRef, ref), tabIndex: disabled ? -1 : 0 }, options.map((option) => (react_1.default.createElement(react_2.RadioGroup.Option, { as: react_1.Fragment, disabled: option.disabled, key: option.value.toString(), value: option.value }, (o) => react_1.default.createElement(radio_1.Radio, { value: o.checked, isDisabled: disabled || o.disabled, isInvalid: invalid }))))),
|
|
43
43
|
invalid && error && react_1.default.createElement(error_message_1.ErrorMessage, { id: errorId }, error)));
|
|
44
44
|
}
|
|
45
45
|
exports.default = (0, forwardRef_1.forwardRef)("RadioGroup", RadioGroup);
|
package/select/select.js
CHANGED
|
@@ -47,9 +47,8 @@ function Select(props, ref) {
|
|
|
47
47
|
react_2.default.createElement(react_1.Listbox.Label, { as: label_1.Label, onClick: props.isDisabled || props.isReadOnly ? undefined : input.focus }, props.label),
|
|
48
48
|
react_2.default.createElement(react_1.Listbox.Button, { as: "div", className: (0, cx_1.cx)("uxf-select__button", (renderProps.open || input.focused) && classes_1.CLASSES.IS_FOCUSED, renderProps.disabled && classes_1.CLASSES.IS_DISABLED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isInvalid && classes_1.CLASSES.IS_INVALID), onBlur: input.onBlur, onFocus: input.onFocus, tabIndex: props.isDisabled || props.isReadOnly ? undefined : 0, ref: stableRef, "aria-invalid": props.isInvalid, "aria-describedby": errorId },
|
|
49
49
|
react_2.default.createElement("div", { className: "uxf-select__button-text" }, (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || props.placeholder),
|
|
50
|
-
renderProps.open ? (react_2.default.createElement(icon_1.Icon, { Component: icon_1.ChevronUpIcon, size: 12 })) : (react_2.default.createElement(icon_1.Icon, { Component: icon_1.ChevronDownIcon, size: 12 })),
|
|
51
|
-
|
|
52
|
-
react_2.default.createElement("div", { className: "uxf-select__helper-text" }, props.helperText),
|
|
50
|
+
renderProps.open ? (react_2.default.createElement(icon_1.Icon, { Component: icon_1.ChevronUpIcon, size: 12 })) : (react_2.default.createElement(icon_1.Icon, { Component: icon_1.ChevronDownIcon, size: 12 }))),
|
|
51
|
+
props.helperText && (react_2.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID) }, props.helperText)),
|
|
53
52
|
react_2.default.createElement(react_1.Listbox.Options, { ref: dropdown.floating, style: dropdown.style, className: "uxf-dropdown" }, props.options.map((option) => {
|
|
54
53
|
var _a, _b, _c, _d;
|
|
55
54
|
return (react_2.default.createElement(react_1.Listbox.Option, { key: (_b = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, option)) !== null && _b !== void 0 ? _b : option.id, value: 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) }, (_d = (_c = props.renderOption) === null || _c === void 0 ? void 0 : _c.call(props, option)) !== null && _d !== void 0 ? _d : option.label));
|
package/text-input/text-input.js
CHANGED
|
@@ -27,13 +27,15 @@ exports.TextInput = void 0;
|
|
|
27
27
|
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
|
+
const form_control_1 = require("../form-control");
|
|
31
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
30
32
|
function TextInput(props) {
|
|
31
33
|
var _a;
|
|
32
34
|
const [isFocused, setIsFocused] = (0, react_1.useState)(false);
|
|
33
35
|
const generatedId = (0, react_1.useId)();
|
|
34
36
|
const id = (_a = props.id) !== null && _a !== void 0 ? _a : generatedId;
|
|
35
37
|
const errorId = props.isInvalid ? `${id}--error-message` : undefined;
|
|
36
|
-
const rootClassName = (0, cx_1.cx)("uxf-text-input", props.isInvalid &&
|
|
38
|
+
const rootClassName = (0, cx_1.cx)("uxf-text-input", props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isRequired && "is-required", isFocused && classes_1.CLASSES.IS_FOCUSED);
|
|
37
39
|
const onFocus = (e) => {
|
|
38
40
|
var _a;
|
|
39
41
|
setIsFocused(true);
|
|
@@ -44,14 +46,12 @@ function TextInput(props) {
|
|
|
44
46
|
setIsFocused(false);
|
|
45
47
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
46
48
|
};
|
|
47
|
-
return (react_1.default.createElement(
|
|
48
|
-
react_1.default.createElement("label", { className: "uxf-text-input__label", htmlFor: id }, props.label),
|
|
49
|
+
return (react_1.default.createElement(form_control_1.FormControl, { inputId: id, errorId: errorId, className: rootClassName, isRequired: props.isRequired, helperText: props.helperText, label: props.label, form: props.form },
|
|
49
50
|
react_1.default.createElement(input_1.Input, { size: props.size, variant: props.variant },
|
|
50
51
|
props.leftAddon && react_1.default.createElement(input_1.Input.LeftAddon, null, props.leftAddon),
|
|
51
52
|
props.leftElement && react_1.default.createElement(input_1.Input.LeftElement, null, props.leftElement),
|
|
52
53
|
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 }),
|
|
53
54
|
props.rightElement && react_1.default.createElement(input_1.Input.RightElement, null, props.rightElement),
|
|
54
|
-
props.rightAddon && react_1.default.createElement(input_1.Input.RightAddon, null, props.rightAddon))
|
|
55
|
-
react_1.default.createElement("div", { className: "uxf-text-input__helper-text", id: errorId }, props.helperText)));
|
|
55
|
+
props.rightAddon && react_1.default.createElement(input_1.Input.RightAddon, null, props.rightAddon))));
|
|
56
56
|
}
|
|
57
57
|
exports.TextInput = TextInput;
|