@uxf/ui 1.0.0-beta.2 → 1.0.0-beta.26
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-file-input/avatar-file-input.d.ts +32 -0
- package/avatar-file-input/avatar-file-input.jsx +57 -0
- package/avatar-file-input/avatar-file-input.stories.d.ts +7 -0
- package/avatar-file-input/avatar-file-input.stories.jsx +27 -0
- package/avatar-file-input/index.d.ts +1 -0
- package/avatar-file-input/index.jsx +8 -0
- package/button/button.d.ts +14 -0
- package/button/button.jsx +23 -0
- package/button/button.stories.d.ts +7 -0
- package/button/button.stories.jsx +64 -0
- package/button/index.d.ts +2 -0
- package/button/index.js +23 -0
- package/button/theme.d.ts +18 -0
- package/button/theme.js +2 -0
- package/checkbox/checkbox.d.ts +12 -0
- package/checkbox/checkbox.jsx +23 -0
- package/checkbox/checkbox.stories.d.ts +8 -0
- package/checkbox/checkbox.stories.jsx +18 -0
- package/checkbox/index.d.ts +1 -0
- package/checkbox/index.jsx +8 -0
- package/checkbox-input/checkbox-input.d.ts +3 -0
- package/checkbox-input/checkbox-input.jsx +6 -0
- package/checkbox-input/checkbox-input.stories.d.ts +8 -0
- package/checkbox-input/checkbox-input.stories.jsx +14 -0
- package/checkbox-input/index.d.ts +1 -0
- package/checkbox-input/index.jsx +8 -0
- package/combobox/combobox.d.ts +27 -0
- package/combobox/combobox.jsx +42 -0
- package/combobox/combobox.stories.d.ts +8 -0
- package/combobox/combobox.stories.jsx +26 -0
- package/combobox/index.d.ts +1 -0
- package/combobox/index.js +8 -0
- package/dropdown/dropdown.d.ts +10 -0
- package/dropdown/dropdown.jsx +26 -0
- package/dropdown/index.d.ts +1 -0
- package/dropdown/index.js +5 -0
- package/error-message/error-message.d.ts +7 -0
- package/error-message/error-message.jsx +8 -0
- package/error-message/error-message.stories.d.ts +8 -0
- package/error-message/error-message.stories.jsx +14 -0
- package/error-message/index.d.ts +1 -0
- package/error-message/index.js +8 -0
- package/hooks/use-dropdown.d.ts +7 -0
- package/hooks/use-dropdown.js +37 -0
- package/hooks/use-fix-android-on-focus.d.ts +2 -0
- package/hooks/use-fix-android-on-focus.js +31 -0
- package/hooks/use-input-submit.d.ts +4 -0
- package/hooks/use-input-submit.js +44 -0
- package/hooks/use-latest.d.ts +2 -0
- package/hooks/use-latest.js +12 -0
- package/icon/icon.d.ts +16 -0
- package/icon/icon.jsx +22 -0
- package/icon/icon.stories.d.ts +7 -0
- package/icon/icon.stories.jsx +50 -0
- package/icon/index.d.ts +1 -0
- package/icon/index.js +8 -0
- package/icon/theme.d.ts +1 -0
- package/icon/theme.js +2 -0
- package/image-gallery/components/close-button.d.ts +6 -0
- package/image-gallery/components/close-button.jsx +13 -0
- package/image-gallery/components/dot.d.ts +6 -0
- package/image-gallery/components/dot.jsx +12 -0
- package/image-gallery/components/gallery.d.ts +11 -0
- package/image-gallery/components/gallery.jsx +75 -0
- package/image-gallery/components/icon-chevron-left.d.ts +3 -0
- package/image-gallery/components/icon-chevron-left.jsx +12 -0
- package/image-gallery/components/icon-chevron-right.d.ts +3 -0
- package/image-gallery/components/icon-chevron-right.jsx +12 -0
- package/image-gallery/components/icon-close.d.ts +3 -0
- package/image-gallery/components/icon-close.jsx +12 -0
- package/image-gallery/components/next-button.d.ts +6 -0
- package/image-gallery/components/next-button.jsx +13 -0
- package/image-gallery/components/previous-button.d.ts +6 -0
- package/image-gallery/components/previous-button.jsx +13 -0
- package/image-gallery/context.d.ts +10 -0
- package/image-gallery/context.jsx +12 -0
- package/image-gallery/image-gallery.d.ts +6 -0
- package/image-gallery/image-gallery.jsx +56 -0
- package/image-gallery/image-gallery.stories.d.ts +13 -0
- package/image-gallery/image-gallery.stories.jsx +29 -0
- package/image-gallery/image.d.ts +4 -0
- package/image-gallery/image.jsx +12 -0
- package/image-gallery/index.d.ts +3 -0
- package/image-gallery/index.js +25 -0
- package/image-gallery/types.d.ts +6 -0
- package/image-gallery/types.js +2 -0
- package/image-gallery/use-image.d.ts +2 -0
- package/image-gallery/use-image.js +16 -0
- package/input/index.d.ts +13 -0
- package/input/index.js +19 -0
- package/input/input-element.d.ts +8 -0
- package/input/input-element.jsx +11 -0
- package/input/input-left-addon.d.ts +6 -0
- package/input/input-left-addon.jsx +10 -0
- package/input/input-left-element.d.ts +6 -0
- package/input/input-left-element.jsx +10 -0
- package/input/input-right-addon.d.ts +6 -0
- package/input/input-right-addon.jsx +10 -0
- package/input/input-right-element.d.ts +6 -0
- package/input/input-right-element.jsx +10 -0
- package/input/input.d.ts +8 -0
- package/input/input.jsx +64 -0
- package/input/input.stories.d.ts +14 -0
- package/input/input.stories.jsx +78 -0
- package/input/theme.d.ts +6 -0
- package/input/theme.js +2 -0
- package/label/index.d.ts +1 -0
- package/label/index.js +8 -0
- package/label/label.d.ts +10 -0
- package/label/label.jsx +10 -0
- package/label/label.stories.d.ts +7 -0
- package/label/label.stories.jsx +14 -0
- package/package.json +16 -34
- package/radio/index.d.ts +1 -0
- package/radio/index.jsx +8 -0
- package/radio/radio.d.ts +11 -0
- package/radio/radio.jsx +19 -0
- package/radio/radio.stories.d.ts +7 -0
- package/radio/radio.stories.jsx +17 -0
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.jsx +8 -0
- package/radio-group/radio-group.d.ts +25 -0
- package/radio-group/radio-group.jsx +30 -0
- package/radio-group/radio-group.stories.d.ts +7 -0
- package/radio-group/radio-group.stories.jsx +30 -0
- package/raster-image/index.d.ts +1 -0
- package/raster-image/index.jsx +8 -0
- package/raster-image/raster-image.d.ts +16 -0
- package/raster-image/raster-image.jsx +17 -0
- package/raster-image/raster-image.stories.d.ts +8 -0
- package/raster-image/raster-image.stories.jsx +14 -0
- package/select/index.d.ts +1 -0
- package/select/index.js +8 -0
- package/select/select.d.ts +27 -0
- package/select/select.jsx +58 -0
- package/select/select.stories.d.ts +8 -0
- package/select/select.stories.jsx +26 -0
- package/text-input/index.d.ts +1 -0
- package/text-input/index.js +17 -0
- package/text-input/text-input.d.ts +22 -0
- package/text-input/text-input.jsx +32 -0
- package/text-input/text-input.stories.d.ts +9 -0
- package/text-input/text-input.stories.jsx +54 -0
- package/textarea/index.d.ts +1 -0
- package/textarea/index.jsx +8 -0
- package/textarea/textarea.d.ts +26 -0
- package/textarea/textarea.jsx +54 -0
- package/textarea/textarea.stories.d.ts +7 -0
- package/textarea/textarea.stories.jsx +29 -0
- package/types/form-control-props.d.ts +24 -0
- package/types/form-control-props.js +2 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +17 -0
- package/utils/action.d.ts +2 -0
- package/utils/action.js +11 -0
- package/utils/component-structure-analyzer.d.ts +6 -0
- package/utils/component-structure-analyzer.jsx +10 -0
- package/utils/cx.d.ts +3 -0
- package/utils/cx.js +54 -0
- package/utils/forwardRef.d.ts +12 -0
- package/utils/forwardRef.js +10 -0
- package/utils/image.d.ts +9 -0
- package/utils/image.jsx +28 -0
- package/utils/rem.d.ts +1 -0
- package/utils/rem.js +5 -0
- package/utils/storybook-config.d.ts +19 -0
- package/utils/storybook-config.jsx +24 -0
- package/components/button/button.d.ts +0 -14
- package/components/button/button.js +0 -19
- package/components/button/index.d.ts +0 -1
- package/components/button/index.js +0 -9
- package/theme/theme-context.d.ts +0 -10
- package/theme/theme-context.js +0 -59
- package/theme/theme.d.ts +0 -31
- package/theme/theme.js +0 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CSSProperties, FocusEventHandler } from "react";
|
|
2
|
+
interface FileResponse {
|
|
3
|
+
extension: string;
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
namespace?: string | null;
|
|
7
|
+
uuid: string;
|
|
8
|
+
}
|
|
9
|
+
export declare type AvatarFileInputChangeEventHandler = (file: FileResponse | null) => Promise<void>;
|
|
10
|
+
export declare type AvatarFileInputUploadHandler = (file: File, namespace?: string) => Promise<FileResponse>;
|
|
11
|
+
export interface AvatarFileInputProps {
|
|
12
|
+
className?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
error?: string;
|
|
15
|
+
form?: string;
|
|
16
|
+
id: string;
|
|
17
|
+
invalid?: boolean;
|
|
18
|
+
label: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
21
|
+
onChange: AvatarFileInputChangeEventHandler;
|
|
22
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
23
|
+
onUploadError: (err: unknown) => void;
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
style?: CSSProperties;
|
|
27
|
+
uploadHandler: AvatarFileInputUploadHandler;
|
|
28
|
+
value?: FileResponse | null | undefined;
|
|
29
|
+
namespace?: "default" | "user-files";
|
|
30
|
+
}
|
|
31
|
+
declare const _default: import("react").ForwardRefExoticComponent<AvatarFileInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
32
|
+
export default _default;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
4
|
+
const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
5
|
+
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
6
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const forwardRef_1 = require("../utils/forwardRef");
|
|
9
|
+
const error_message_1 = require("../error-message");
|
|
10
|
+
const raster_image_1 = require("../raster-image");
|
|
11
|
+
function CameraIcon() {
|
|
12
|
+
return (<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style={{ height: "36px" }}>
|
|
13
|
+
<path d="M144 288C144 226.1 194.1 176 256 176C317.9 176 368 226.1 368 288C368 349.9 317.9 400 256 400C194.1 400 144 349.9 144 288zM256 224C220.7 224 192 252.7 192 288C192 323.3 220.7 352 256 352C291.3 352 320 323.3 320 288C320 252.7 291.3 224 256 224zM362.9 64.82L373.3 96H448C483.3 96 512 124.7 512 160V416C512 451.3 483.3 480 448 480H64C28.65 480 0 451.3 0 416V160C0 124.7 28.65 96 64 96H138.7L149.1 64.82C155.6 45.22 173.9 32 194.6 32H317.4C338.1 32 356.4 45.22 362.9 64.82H362.9zM64 144C55.16 144 48 151.2 48 160V416C48 424.8 55.16 432 64 432H448C456.8 432 464 424.8 464 416V160C464 151.2 456.8 144 448 144H338.7L317.4 80H194.6L173.3 144H64z"/>
|
|
14
|
+
</svg>);
|
|
15
|
+
}
|
|
16
|
+
function AvatarFileInput(props, ref) {
|
|
17
|
+
const { className, disabled, error, form, id, invalid, label, name, onBlur, onChange, onFocus, onUploadError, readOnly, required, style, uploadHandler, value, } = props;
|
|
18
|
+
const innerRef = (0, react_1.useRef)(null);
|
|
19
|
+
const input = (0, useInputFocus_1.useInputFocus)(innerRef, onBlur, onFocus);
|
|
20
|
+
const errorId = invalid && id ? `${id}--errormessage` : undefined;
|
|
21
|
+
const [uploading, setUploading] = (0, react_1.useState)(false);
|
|
22
|
+
const _onChange = (0, react_1.useCallback)(async (e) => {
|
|
23
|
+
var _a;
|
|
24
|
+
e.persist();
|
|
25
|
+
const files = (_a = e.target.files) !== null && _a !== void 0 ? _a : [];
|
|
26
|
+
if (files.length === 1) {
|
|
27
|
+
const file = files[0];
|
|
28
|
+
try {
|
|
29
|
+
setUploading(true);
|
|
30
|
+
const response = await uploadHandler(file);
|
|
31
|
+
await onChange(response);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
onUploadError(err);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
setUploading(false);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}, [onChange, onUploadError, uploadHandler]);
|
|
41
|
+
return (<div className={`_form-field ${className || ""}`} style={style}>
|
|
42
|
+
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}
|
|
43
|
+
<div className={(0, cx_1.cx)("uxf-avatar-file-input", input.focused && classes_1.CLASSES.IS_FOCUSED, disabled && classes_1.CLASSES.IS_DISABLED, readOnly && classes_1.CLASSES.IS_READONLY, invalid && classes_1.CLASSES.IS_INVALID, value && "is-disabled:opacity-50")}>
|
|
44
|
+
<label className="sr-only" htmlFor={id}>
|
|
45
|
+
{label}
|
|
46
|
+
</label>
|
|
47
|
+
<div className="rounded-inherit relative flex h-full w-full flex-col items-center justify-center">
|
|
48
|
+
<CameraIcon />
|
|
49
|
+
<p className="mt-1 text-xs">{uploading ? "nahrávám..." : value ? "změnit foto" : "přidat foto"}</p>
|
|
50
|
+
</div>
|
|
51
|
+
{!!value && (<raster_image_1.RasterImage alt="" className={(0, cx_1.cx)("rounded-inherit absolute left-0 top-0 block h-full w-full object-cover", uploading && "opacity-0")} height={96} src={value} width={96}/>)}
|
|
52
|
+
<input accept="image/*" aria-describedby={errorId} aria-invalid={invalid} className="input-reset rounded-inherit absolute left-0 top-0 h-full w-full cursor-pointer opacity-0" disabled={disabled} form={form} id={id} name={name} onBlur={input.onBlur} onChange={_onChange} onFocus={input.onFocus} readOnly={readOnly} ref={(0, composeRefs_1.composeRefs)(innerRef, ref)} required={required} tabIndex={readOnly ? -1 : undefined} type="file"/>
|
|
53
|
+
</div>
|
|
54
|
+
{invalid && error && <error_message_1.ErrorMessage id={errorId}>{error}</error_message_1.ErrorMessage>}
|
|
55
|
+
</div>);
|
|
56
|
+
}
|
|
57
|
+
exports.default = (0, forwardRef_1.forwardRef)("AvatarFileInput", AvatarFileInput);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").ForwardRefExoticComponent<import("./avatar-file-input").AvatarFileInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export declare function Default(): JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
exports.default = {
|
|
6
|
+
title: "UI/AvatarFileInput",
|
|
7
|
+
component: index_1.AvatarFileInput,
|
|
8
|
+
};
|
|
9
|
+
function Default() {
|
|
10
|
+
return (<div className="space-y-2">
|
|
11
|
+
<index_1.AvatarFileInput id={"afi"} label="Vyberte Avatar" onChange={(value) => {
|
|
12
|
+
return new Promise(() => {
|
|
13
|
+
// eslint-disable-next-line no-console
|
|
14
|
+
console.log("Changed:", value);
|
|
15
|
+
});
|
|
16
|
+
}} onUploadError={() => {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.log("Upload error");
|
|
19
|
+
}} uploadHandler={() => {
|
|
20
|
+
return new Promise(() => {
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.log("Upload handler");
|
|
23
|
+
});
|
|
24
|
+
}}/>
|
|
25
|
+
</div>);
|
|
26
|
+
}
|
|
27
|
+
exports.Default = Default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AvatarFileInput } from "./avatar-file-input";
|
|
@@ -0,0 +1,8 @@
|
|
|
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.AvatarFileInput = void 0;
|
|
7
|
+
var avatar_file_input_1 = require("./avatar-file-input");
|
|
8
|
+
Object.defineProperty(exports, "AvatarFileInput", { enumerable: true, get: function () { return __importDefault(avatar_file_input_1).default; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { AnchorHTMLAttributes } from "react";
|
|
2
|
+
import { ButtonColors, ButtonSizes, ButtonVariants } from "@uxf/ui/button/theme";
|
|
3
|
+
import { UseAnchorProps } from "@uxf/core/hooks/useAnchorProps";
|
|
4
|
+
export declare type ButtonVariant = keyof ButtonVariants;
|
|
5
|
+
export declare type ButtonSize = keyof ButtonSizes;
|
|
6
|
+
export declare type ButtonColor = keyof ButtonColors;
|
|
7
|
+
export interface ButtonProps extends AnchorHTMLAttributes<HTMLAnchorElement>, UseAnchorProps {
|
|
8
|
+
variant?: ButtonVariant;
|
|
9
|
+
color?: ButtonColor;
|
|
10
|
+
size?: ButtonSize;
|
|
11
|
+
isFullWidth?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
14
|
+
export default _default;
|
|
@@ -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
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
8
|
+
const forwardRef_1 = require("../utils/forwardRef");
|
|
9
|
+
const useAnchorProps_1 = require("@uxf/core/hooks/useAnchorProps");
|
|
10
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
11
|
+
function Button(props, ref) {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const className = (0, cx_1.cx)("uxf-button", `uxf-button--color-${(_a = props.color) !== null && _a !== void 0 ? _a : "default"}`, `uxf-button--size-${(_b = props.size) !== null && _b !== void 0 ? _b : "default"}`, `uxf-button--variant-${(_c = props.variant) !== null && _c !== void 0 ? _c : "default"}`, props.disabled && classes_1.CLASSES.IS_DISABLED, props.loading && "is-loading", props.isFullWidth && "uxf-button--full-width");
|
|
14
|
+
const anchorProps = (0, useAnchorProps_1.useAnchorProps)({
|
|
15
|
+
...props,
|
|
16
|
+
className,
|
|
17
|
+
});
|
|
18
|
+
return (<a ref={ref} {...anchorProps} className={className}>
|
|
19
|
+
{typeof props.children === "string" ? (<span className="uxf-button__text">{props.children}</span>) : (props.children)}
|
|
20
|
+
<div className="loader"/>
|
|
21
|
+
</a>);
|
|
22
|
+
}
|
|
23
|
+
exports.default = (0, forwardRef_1.forwardRef)("Button", Button);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.ForwardRefExoticComponent<import("@uxf/ui/button").ButtonProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export declare function Default(): JSX.Element;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 __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;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Default = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const button_1 = require("@uxf/ui/button");
|
|
29
|
+
const storybook_config_1 = require("@uxf/ui/utils/storybook-config");
|
|
30
|
+
exports.default = {
|
|
31
|
+
title: "UI/Button",
|
|
32
|
+
component: button_1.Button,
|
|
33
|
+
};
|
|
34
|
+
function Default() {
|
|
35
|
+
const config = (0, storybook_config_1.useStorybookConfig)("Button");
|
|
36
|
+
return (<div className="space-y-2">
|
|
37
|
+
{config.variants.map((variant) => (<react_1.Fragment key={variant}>
|
|
38
|
+
{config.colors.map((color) => (<react_1.Fragment key={color}>
|
|
39
|
+
{config.sizes.map((size) => (<div key={`${size}${color}${variant}`} className="pb-4">
|
|
40
|
+
<div className="mb-2 text-sm">
|
|
41
|
+
Variant: <span className="font-semibold">{variant}</span>, Color:{" "}
|
|
42
|
+
<span className="font-semibold">{color}</span>, Size:{" "}
|
|
43
|
+
<span className="font-semibold">{size}</span>
|
|
44
|
+
</div>
|
|
45
|
+
<div className="mb-2 flex flex-row gap-2">
|
|
46
|
+
<button_1.Button variant={variant} color={color} size={size}>
|
|
47
|
+
Default
|
|
48
|
+
</button_1.Button>
|
|
49
|
+
<button_1.Button variant={variant} color={color} size={size} loading>
|
|
50
|
+
Loading
|
|
51
|
+
</button_1.Button>
|
|
52
|
+
<button_1.Button variant={variant} color={color} size={size} disabled>
|
|
53
|
+
Disabled
|
|
54
|
+
</button_1.Button>
|
|
55
|
+
</div>
|
|
56
|
+
<button_1.Button variant={variant} color={color} size={size} isFullWidth>
|
|
57
|
+
Full width
|
|
58
|
+
</button_1.Button>
|
|
59
|
+
</div>))}
|
|
60
|
+
</react_1.Fragment>))}
|
|
61
|
+
</react_1.Fragment>))}
|
|
62
|
+
</div>);
|
|
63
|
+
}
|
|
64
|
+
exports.Default = Default;
|
package/button/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Button = void 0;
|
|
21
|
+
var button_1 = require("@uxf/ui/button/button");
|
|
22
|
+
Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(button_1).default; } });
|
|
23
|
+
__exportStar(require("@uxf/ui/button/button"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ButtonVariants {
|
|
2
|
+
outlined: true;
|
|
3
|
+
default: true;
|
|
4
|
+
}
|
|
5
|
+
export interface ButtonSizes {
|
|
6
|
+
xs: true;
|
|
7
|
+
sm: true;
|
|
8
|
+
default: true;
|
|
9
|
+
lg: true;
|
|
10
|
+
xl: true;
|
|
11
|
+
}
|
|
12
|
+
export interface ButtonColors {
|
|
13
|
+
default: true;
|
|
14
|
+
white: true;
|
|
15
|
+
success: true;
|
|
16
|
+
warning: true;
|
|
17
|
+
error: true;
|
|
18
|
+
}
|
package/button/theme.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
className?: string;
|
|
4
|
+
checked: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
intermediate?: boolean;
|
|
7
|
+
label: string;
|
|
8
|
+
onChange: (checked: boolean) => void;
|
|
9
|
+
style?: Partial<CSSProperties>;
|
|
10
|
+
}
|
|
11
|
+
declare function Checkbox(props: Props): JSX.Element;
|
|
12
|
+
export default Checkbox;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("@headlessui/react");
|
|
4
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
5
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
6
|
+
function CheckIcon() {
|
|
7
|
+
return (<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" style={{ height: "24" }}>
|
|
8
|
+
<path d="M211.8 339.8C200.9 350.7 183.1 350.7 172.2 339.8L108.2 275.8C97.27 264.9 97.27 247.1 108.2 236.2C119.1 225.3 136.9 225.3 147.8 236.2L192 280.4L300.2 172.2C311.1 161.3 328.9 161.3 339.8 172.2C350.7 183.1 350.7 200.9 339.8 211.8L211.8 339.8zM0 96C0 60.65 28.65 32 64 32H384C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96zM48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80H64C55.16 80 48 87.16 48 96z"/>
|
|
9
|
+
</svg>);
|
|
10
|
+
}
|
|
11
|
+
function SquareIcon() {
|
|
12
|
+
return (<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" style={{ height: "24" }}>
|
|
13
|
+
<path d="M384 32C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96C0 60.65 28.65 32 64 32H384zM384 80H64C55.16 80 48 87.16 48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80z"/>
|
|
14
|
+
</svg>);
|
|
15
|
+
}
|
|
16
|
+
function Checkbox(props) {
|
|
17
|
+
const { checked, className, disabled, label, onChange, style } = props;
|
|
18
|
+
return (<react_1.Switch checked={checked} className={(0, cx_1.cx)(checked && classes_1.CLASSES.IS_SELECTED, disabled && classes_1.CLASSES.IS_DISABLED, "uxf-checkbox", className)} disabled={disabled} onChange={onChange} style={style}>
|
|
19
|
+
<span className="sr-only">{label}</span>
|
|
20
|
+
{checked ? <CheckIcon /> : <SquareIcon />}
|
|
21
|
+
</react_1.Switch>);
|
|
22
|
+
}
|
|
23
|
+
exports.default = Checkbox;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
exports.default = {
|
|
7
|
+
title: "UI/Checkbox",
|
|
8
|
+
component: index_1.Checkbox,
|
|
9
|
+
};
|
|
10
|
+
function Default() {
|
|
11
|
+
const [checked, setChecked] = (0, react_1.useState)(true);
|
|
12
|
+
return (<div className="space-y-2">
|
|
13
|
+
<index_1.Checkbox label={"Opravdu?"} onChange={() => {
|
|
14
|
+
setChecked(!checked);
|
|
15
|
+
}} checked={checked}/>
|
|
16
|
+
</div>);
|
|
17
|
+
}
|
|
18
|
+
exports.Default = Default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Checkbox } from "./checkbox";
|
|
@@ -0,0 +1,8 @@
|
|
|
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.Checkbox = void 0;
|
|
7
|
+
var checkbox_1 = require("./checkbox");
|
|
8
|
+
Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return __importDefault(checkbox_1).default; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
exports.default = {
|
|
6
|
+
title: "UI/CheckboxInput",
|
|
7
|
+
component: index_1.CheckboxInput,
|
|
8
|
+
};
|
|
9
|
+
function Default() {
|
|
10
|
+
return (<div className="space-y-2">
|
|
11
|
+
<index_1.CheckboxInput />
|
|
12
|
+
</div>);
|
|
13
|
+
}
|
|
14
|
+
exports.Default = Default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CheckboxInput } from "./checkbox-input";
|
|
@@ -0,0 +1,8 @@
|
|
|
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.CheckboxInput = void 0;
|
|
7
|
+
var checkbox_input_1 = require("./checkbox-input");
|
|
8
|
+
Object.defineProperty(exports, "CheckboxInput", { enumerable: true, get: function () { return __importDefault(checkbox_input_1).default; } });
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FocusEventHandler } from "react";
|
|
2
|
+
declare type ComboboxValue = number | string;
|
|
3
|
+
export declare type ComboboxOption<T = ComboboxValue> = {
|
|
4
|
+
key?: number | string;
|
|
5
|
+
id: T;
|
|
6
|
+
label: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export interface ComboboxProps<V = ComboboxValue, O = ComboboxOption<V>> {
|
|
10
|
+
className?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
invalid?: boolean;
|
|
14
|
+
onChange: (value: O | null) => void;
|
|
15
|
+
onBlur?: FocusEventHandler<HTMLDivElement>;
|
|
16
|
+
onFocus?: FocusEventHandler<HTMLDivElement>;
|
|
17
|
+
name: string;
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
options: O[];
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
value?: V;
|
|
25
|
+
}
|
|
26
|
+
declare const _default: import("react").ForwardRefExoticComponent<ComboboxProps<ComboboxValue, ComboboxOption<ComboboxValue>> & import("react").RefAttributes<HTMLDivElement>>;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("@headlessui/react");
|
|
4
|
+
const dropdown_1 = require("../dropdown");
|
|
5
|
+
const use_dropdown_1 = require("../hooks/use-dropdown");
|
|
6
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
7
|
+
const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
8
|
+
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
9
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
10
|
+
const react_2 = require("react");
|
|
11
|
+
const error_message_1 = require("../error-message");
|
|
12
|
+
const label_1 = require("../label");
|
|
13
|
+
const forwardRef_1 = require("@uxf/ui/utils/forwardRef");
|
|
14
|
+
function Combobox(props, ref) {
|
|
15
|
+
const { className, disabled, error, id, invalid, label, onBlur, onChange, onFocus, options, placeholder, readOnly, value, } = props;
|
|
16
|
+
const [query, setQuery] = (0, react_2.useState)("");
|
|
17
|
+
const selectedOption = options.find((option) => option.id === value);
|
|
18
|
+
const filteredData = query === ""
|
|
19
|
+
? options
|
|
20
|
+
: options.filter((item) => String(item.label).toLowerCase().includes(query.toLowerCase()));
|
|
21
|
+
const innerRef = (0, react_2.useRef)(null);
|
|
22
|
+
const disabledOrReadOnly = disabled || readOnly;
|
|
23
|
+
const errorId = invalid ? `${id}--errormessage` : undefined;
|
|
24
|
+
const input = (0, useInputFocus_1.useInputFocus)(innerRef, onBlur, onFocus);
|
|
25
|
+
const dropdown = (0, use_dropdown_1.useDropdown)("bottom", true);
|
|
26
|
+
const stableRef = (0, react_2.useMemo)(() => (0, composeRefs_1.composeRefs)(innerRef, ref, dropdown.reference), [ref, dropdown.reference]);
|
|
27
|
+
return (<react_1.Combobox as="div" className={`autocomplete-form-field ${className || ""}`} onChange={onChange} value={selectedOption}>
|
|
28
|
+
<react_1.Combobox.Label as={label_1.Label} onClick={!disabledOrReadOnly ? input.focus : undefined}>
|
|
29
|
+
{label}
|
|
30
|
+
</react_1.Combobox.Label>
|
|
31
|
+
<react_1.Combobox.Input className={(0, cx_1.cx)("border-grey w-full rounded-lg border p-4 tracking-wider outline-none", invalid && error && "outline-red border-transparent outline")} displayValue={(item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : ""; }} onBlur={onBlur} onChange={(event) => setQuery(event.target.value)} placeholder={placeholder} ref={stableRef} type="text"/>
|
|
32
|
+
{invalid && error && <error_message_1.ErrorMessage id={errorId}>{error}</error_message_1.ErrorMessage>}
|
|
33
|
+
<react_1.Combobox.Options as={dropdown_1.Dropdown.Items} className="w-full" ref={dropdown.floating} style={dropdown.style}>
|
|
34
|
+
{filteredData.map((option) => (<react_1.Combobox.Option as={react_2.Fragment} key={option.key || option.id} value={option}>
|
|
35
|
+
{(o) => (<dropdown_1.Dropdown.Item className={(0, cx_1.cx)(o.active && classes_1.CLASSES.IS_ACTIVE, o.disabled && classes_1.CLASSES.IS_DISABLED, o.selected && classes_1.CLASSES.IS_SELECTED)}>
|
|
36
|
+
{option.label}
|
|
37
|
+
</dropdown_1.Dropdown.Item>)}
|
|
38
|
+
</react_1.Combobox.Option>))}
|
|
39
|
+
</react_1.Combobox.Options>
|
|
40
|
+
</react_1.Combobox>);
|
|
41
|
+
}
|
|
42
|
+
exports.default = (0, forwardRef_1.forwardRef)("Combobox", Combobox);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComboboxOption } from "./combobox";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: import("react").ForwardRefExoticComponent<import("./combobox").ComboboxProps<string | number, ComboboxOption<string | number>> & import("react").RefAttributes<HTMLDivElement>>;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export declare function Default(): JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
exports.default = {
|
|
7
|
+
title: "UI/Combobox",
|
|
8
|
+
component: index_1.Combobox,
|
|
9
|
+
};
|
|
10
|
+
const options = [
|
|
11
|
+
{ id: "one", label: "Option one" },
|
|
12
|
+
// { id: "two", label: "Option two" },
|
|
13
|
+
// { id: "three", label: "Option three" },
|
|
14
|
+
];
|
|
15
|
+
function Default() {
|
|
16
|
+
const [value, setValue] = (0, react_1.useState)();
|
|
17
|
+
const handleChange = (v) => {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.log("Select value: ", v);
|
|
20
|
+
setValue(v === null || v === void 0 ? void 0 : v.id);
|
|
21
|
+
};
|
|
22
|
+
return (<div className="space-y-2">
|
|
23
|
+
<index_1.Combobox id="combobox-1" name="combobox" label="Start typing to see options..." options={options} onChange={handleChange} value={value}/>
|
|
24
|
+
</div>);
|
|
25
|
+
}
|
|
26
|
+
exports.Default = Default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Combobox, ComboboxProps } from "./combobox";
|
|
@@ -0,0 +1,8 @@
|
|
|
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.Combobox = void 0;
|
|
7
|
+
var combobox_1 = require("./combobox");
|
|
8
|
+
Object.defineProperty(exports, "Combobox", { enumerable: true, get: function () { return __importDefault(combobox_1).default; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseAnchorProps } from "@uxf/core/hooks/useAnchorProps";
|
|
2
|
+
import { AnchorHTMLAttributes, HTMLAttributes } from "react";
|
|
3
|
+
interface ItemProps extends AnchorHTMLAttributes<HTMLAnchorElement>, UseAnchorProps {
|
|
4
|
+
}
|
|
5
|
+
declare type ItemsProps = HTMLAttributes<HTMLDivElement>;
|
|
6
|
+
export declare const Dropdown: {
|
|
7
|
+
Item: import("react").ForwardRefExoticComponent<ItemProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
8
|
+
Items: import("react").ForwardRefExoticComponent<ItemsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Dropdown = void 0;
|
|
4
|
+
const useAnchorProps_1 = require("@uxf/core/hooks/useAnchorProps");
|
|
5
|
+
const forwardRef_1 = require("@uxf/ui/utils/forwardRef");
|
|
6
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
7
|
+
function Item(props, ref) {
|
|
8
|
+
const { children, className, ...restProps } = props;
|
|
9
|
+
const anchorProps = (0, useAnchorProps_1.useAnchorProps)({
|
|
10
|
+
className: `uxf-dropdown-item ${className || ""}`,
|
|
11
|
+
role: "menuitem",
|
|
12
|
+
...restProps,
|
|
13
|
+
});
|
|
14
|
+
return (<a ref={ref} {...anchorProps}>
|
|
15
|
+
{children}
|
|
16
|
+
</a>);
|
|
17
|
+
}
|
|
18
|
+
function Items(props, ref) {
|
|
19
|
+
return (<div className={(0, cx_1.cx)("uxf-dropdown-items", props.className)} ref={ref} role={props.role}>
|
|
20
|
+
{props.children}
|
|
21
|
+
</div>);
|
|
22
|
+
}
|
|
23
|
+
exports.Dropdown = {
|
|
24
|
+
Item: (0, forwardRef_1.forwardRef)("Item.", Item),
|
|
25
|
+
Items: (0, forwardRef_1.forwardRef)("Items", Items),
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Dropdown } from "./dropdown";
|