@uxf/ui 1.0.0-beta.22 → 1.0.0-beta.23
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/button/button.d.ts +15 -0
- package/button/button.jsx +17 -0
- package/button/button.stories.d.ts +10 -0
- package/button/button.stories.jsx +59 -0
- package/button/index.d.ts +2 -0
- package/button/index.js +23 -0
- package/button/theme.d.ts +18 -0
- package/{avatar → button}/theme.js +0 -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/{avatar/avatar.stories.d.ts → error-message/error-message.stories.d.ts} +2 -2
- 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/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 +74 -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 +58 -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 +9 -0
- package/input/input.jsx +65 -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 +9 -0
- package/label/label.jsx +9 -0
- package/label/label.stories.d.ts +7 -0
- package/label/label.stories.jsx +14 -0
- package/package.json +3 -4
- package/select/index.d.ts +1 -0
- package/select/index.js +8 -0
- package/select/select.d.ts +27 -0
- package/select/select.jsx +47 -0
- package/select/select.stories.d.ts +8 -0
- package/select/select.stories.jsx +22 -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 +55 -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/storybook-config.d.ts +19 -0
- package/utils/storybook-config.jsx +47 -0
- package/avatar/avatar.d.ts +0 -14
- package/avatar/avatar.jsx +0 -10
- package/avatar/avatar.stories.jsx +0 -29
- package/avatar/theme.d.ts +0 -5
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import ImageGallery from "./image-gallery";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof ImageGallery;
|
|
6
|
+
parameters: {
|
|
7
|
+
actions: {
|
|
8
|
+
argTypesRegex: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
13
|
+
export declare function Default(): JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 image_gallery_1 = __importDefault(require("./image-gallery"));
|
|
9
|
+
const image_1 = __importDefault(require("./image"));
|
|
10
|
+
exports.default = {
|
|
11
|
+
title: "Lab/ImageGallery",
|
|
12
|
+
component: image_gallery_1.default,
|
|
13
|
+
parameters: { actions: { argTypesRegex: "^on.*" } },
|
|
14
|
+
};
|
|
15
|
+
const images = [
|
|
16
|
+
"https://opentopo.app/hero_image.jpeg",
|
|
17
|
+
"https://opentopo.app/generated/area-18/d/9/d9033d93-ea48-4f66-b0c1-6045c091b326_1024_1024_c.jpg",
|
|
18
|
+
"https://opentopo.app/generated/area-16/f/4/f4a4ca79-ea9e-44d1-a4ec-3c8ccfbcc218_1024_1024_c.jpg",
|
|
19
|
+
"https://opentopo.app/generated/area-1/8/b/8b84e378-1f55-4ce7-b750-b504091cb833_1024_1024_c.jpg",
|
|
20
|
+
"https://opentopo.app/generated/area-2/e/7/e7ec532b-20c2-407e-9305-fa7cfb71f01f_1024_1024_c.jpg",
|
|
21
|
+
];
|
|
22
|
+
function Default() {
|
|
23
|
+
return (<image_gallery_1.default>
|
|
24
|
+
<div className="flex-direction flex gap-2">
|
|
25
|
+
{images.map((src) => (<image_1.default key={src} src={src} className="h-56 w-56 cursor-pointer object-cover transition-transform hover:scale-105"/>))}
|
|
26
|
+
</div>
|
|
27
|
+
</image_gallery_1.default>);
|
|
28
|
+
}
|
|
29
|
+
exports.Default = Default;
|
|
@@ -0,0 +1,12 @@
|
|
|
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 use_image_1 = require("./use-image");
|
|
8
|
+
function Image(props) {
|
|
9
|
+
const openGallery = (0, use_image_1.useImage)(props);
|
|
10
|
+
return (<img src={props.src} alt={props.alt} title={props.title} className={props.className} onClick={() => openGallery(props)}/>);
|
|
11
|
+
}
|
|
12
|
+
exports.default = Image;
|
|
@@ -0,0 +1,25 @@
|
|
|
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.ImageGallery = exports.Image = void 0;
|
|
21
|
+
var image_1 = require("./image");
|
|
22
|
+
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return __importDefault(image_1).default; } });
|
|
23
|
+
var image_gallery_1 = require("./image-gallery");
|
|
24
|
+
Object.defineProperty(exports, "ImageGallery", { enumerable: true, get: function () { return __importDefault(image_gallery_1).default; } });
|
|
25
|
+
__exportStar(require("./use-image"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useImage = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const context_1 = require("./context");
|
|
6
|
+
function useImage(props) {
|
|
7
|
+
const { registerImage, unregisterImage, openGallery } = (0, context_1.useImageGalleryContext)();
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
registerImage(props);
|
|
10
|
+
return () => {
|
|
11
|
+
unregisterImage(props);
|
|
12
|
+
};
|
|
13
|
+
}, [props]);
|
|
14
|
+
return openGallery;
|
|
15
|
+
}
|
|
16
|
+
exports.useImage = useImage;
|
package/input/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import RootInput from "./input";
|
|
3
|
+
import LeftElement from "./input-left-element";
|
|
4
|
+
import RightElement from "./input-right-element";
|
|
5
|
+
import LeftAddon from "./input-left-addon";
|
|
6
|
+
import RightAddon from "./input-right-addon";
|
|
7
|
+
export declare const Input: typeof RootInput & {
|
|
8
|
+
Element: import("react").ForwardRefExoticComponent<import("./input-element").InputElementProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
9
|
+
LeftElement: typeof LeftElement;
|
|
10
|
+
RightElement: typeof RightElement;
|
|
11
|
+
LeftAddon: typeof LeftAddon;
|
|
12
|
+
RightAddon: typeof RightAddon;
|
|
13
|
+
};
|
package/input/index.js
ADDED
|
@@ -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.Input = void 0;
|
|
7
|
+
const input_1 = __importDefault(require("./input"));
|
|
8
|
+
const input_element_1 = __importDefault(require("./input-element"));
|
|
9
|
+
const input_left_element_1 = __importDefault(require("./input-left-element"));
|
|
10
|
+
const input_right_element_1 = __importDefault(require("./input-right-element"));
|
|
11
|
+
const input_left_addon_1 = __importDefault(require("./input-left-addon"));
|
|
12
|
+
const input_right_addon_1 = __importDefault(require("./input-right-addon"));
|
|
13
|
+
exports.Input = Object.assign(input_1.default, {
|
|
14
|
+
Element: input_element_1.default,
|
|
15
|
+
LeftElement: input_left_element_1.default,
|
|
16
|
+
RightElement: input_right_element_1.default,
|
|
17
|
+
LeftAddon: input_left_addon_1.default,
|
|
18
|
+
RightAddon: input_right_addon_1.default,
|
|
19
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FormControlProps } from "@uxf/ui/types/form-control-props";
|
|
3
|
+
export interface InputElementProps extends FormControlProps<string> {
|
|
4
|
+
id?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: React.ForwardRefExoticComponent<InputElementProps & React.RefAttributes<HTMLInputElement>>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 forwardRef_1 = require("@uxf/ui/utils/forwardRef");
|
|
8
|
+
function InputElement(props, ref) {
|
|
9
|
+
return (<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}/>);
|
|
10
|
+
}
|
|
11
|
+
exports.default = (0, forwardRef_1.forwardRef)("InputElement", InputElement);
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
function InputLeftAddon(props) {
|
|
8
|
+
return <div className="uxf-input__left-addon">{props.children}</div>;
|
|
9
|
+
}
|
|
10
|
+
exports.default = InputLeftAddon;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
function InputLeftElement(props) {
|
|
8
|
+
return <div className="uxf-input__left-element">{props.children}</div>;
|
|
9
|
+
}
|
|
10
|
+
exports.default = InputLeftElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
function InputRightAddon(props) {
|
|
8
|
+
return <div className="uxf-input__right-addon">{props.children}</div>;
|
|
9
|
+
}
|
|
10
|
+
exports.default = InputRightAddon;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
function InputRightElement(props) {
|
|
8
|
+
return <div className="uxf-input__right-element">{props.children}</div>;
|
|
9
|
+
}
|
|
10
|
+
exports.default = InputRightElement;
|
package/input/input.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { InputGroupSizes, InputGroupVariants } from "@uxf/ui/input/theme";
|
|
3
|
+
export interface InputProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
variant?: keyof InputGroupVariants;
|
|
6
|
+
size?: keyof InputGroupSizes;
|
|
7
|
+
}
|
|
8
|
+
declare function Input(props: InputProps): JSX.Element;
|
|
9
|
+
export default Input;
|
package/input/input.jsx
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
const react_1 = __importStar(require("react"));
|
|
27
|
+
const cx_1 = require("@uxf/ui/utils/cx");
|
|
28
|
+
function getChildrenById(children, componentName) {
|
|
29
|
+
return react_1.default.Children.toArray(children)
|
|
30
|
+
.filter(react_1.default.isValidElement)
|
|
31
|
+
.find((ch) => ch.type.displayName === componentName);
|
|
32
|
+
}
|
|
33
|
+
function Input(props) {
|
|
34
|
+
const inputWrapperRef = (0, react_1.useRef)(null);
|
|
35
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
36
|
+
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
37
|
+
const mainInput = getChildrenById(props.children, "InputElement");
|
|
38
|
+
const leftAddon = getChildrenById(props.children, "InputLeftAddon");
|
|
39
|
+
const rightAddon = getChildrenById(props.children, "InputRightAddon");
|
|
40
|
+
const leftElement = getChildrenById(props.children, "InputLeftElement");
|
|
41
|
+
const rightElement = getChildrenById(props.children, "InputRightElement");
|
|
42
|
+
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 && "uxf-input--focused", (mainInput === null || mainInput === void 0 ? void 0 : mainInput.props.isInvalid) && "uxf-input--invalid");
|
|
43
|
+
const onFocus = (e) => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
setFocused(true);
|
|
46
|
+
(_b = mainInput === null || mainInput === void 0 ? void 0 : (_a = mainInput.props).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
47
|
+
};
|
|
48
|
+
const onBlur = (e) => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
setFocused(false);
|
|
51
|
+
(_b = mainInput === null || mainInput === void 0 ? void 0 : (_a = mainInput.props).onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
52
|
+
};
|
|
53
|
+
return (<div className={inputGroupClasses}>
|
|
54
|
+
{leftAddon}
|
|
55
|
+
<div className="uxf-input__wrapper" ref={inputWrapperRef} onClick={() => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }}>
|
|
56
|
+
{leftElement}
|
|
57
|
+
{mainInput
|
|
58
|
+
? react_1.default.cloneElement(mainInput, { ref: inputRef, onFocus, onBlur })
|
|
59
|
+
: null}
|
|
60
|
+
{rightElement}
|
|
61
|
+
</div>
|
|
62
|
+
{rightAddon}
|
|
63
|
+
</div>);
|
|
64
|
+
}
|
|
65
|
+
exports.default = Input;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: typeof import("./input").default & {
|
|
5
|
+
Element: React.ForwardRefExoticComponent<import("./input-element").InputElementProps & React.RefAttributes<HTMLInputElement>>;
|
|
6
|
+
LeftElement: typeof import("./input-left-element").default;
|
|
7
|
+
RightElement: typeof import("./input-right-element").default;
|
|
8
|
+
LeftAddon: typeof import("./input-left-addon").default;
|
|
9
|
+
RightAddon: typeof import("./input-right-addon").default;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
13
|
+
export declare function Default(): JSX.Element;
|
|
14
|
+
export declare function ComponentStructure(): JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ComponentStructure = exports.Default = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const component_structure_analyzer_1 = __importDefault(require("@uxf/ui/utils/component-structure-analyzer"));
|
|
32
|
+
const action_1 = require("@uxf/ui/utils/action");
|
|
33
|
+
const input_1 = require("@uxf/ui/input");
|
|
34
|
+
exports.default = {
|
|
35
|
+
title: "UI/Input",
|
|
36
|
+
component: input_1.Input,
|
|
37
|
+
};
|
|
38
|
+
function Default() {
|
|
39
|
+
const [value, onChange] = (0, react_1.useState)("");
|
|
40
|
+
const [isInvalid, setInvalid] = (0, react_1.useState)(false);
|
|
41
|
+
return (<div className="space-y-2">
|
|
42
|
+
<input type="checkbox" checked={isInvalid} onChange={(e) => setInvalid(e.target.checked)}/>
|
|
43
|
+
<input_1.Input>
|
|
44
|
+
<input_1.Input.LeftAddon>InputLeftAddon</input_1.Input.LeftAddon>
|
|
45
|
+
<input_1.Input.LeftElement>InputLeftElement</input_1.Input.LeftElement>
|
|
46
|
+
<input_1.Input.Element value={value} onChange={(0, action_1.action)("onChange", onChange)} placeholder="Placeholder" isInvalid={isInvalid}/>
|
|
47
|
+
<input_1.Input.RightElement>InputRightElement</input_1.Input.RightElement>
|
|
48
|
+
<input_1.Input.RightAddon>InputRightAddon</input_1.Input.RightAddon>
|
|
49
|
+
</input_1.Input>
|
|
50
|
+
<input_1.Input>
|
|
51
|
+
<input_1.Input.LeftAddon>https://</input_1.Input.LeftAddon>
|
|
52
|
+
<input_1.Input.Element value={value} onChange={(0, action_1.action)("onChange", onChange)} placeholder="Placeholder" isInvalid={isInvalid}/>
|
|
53
|
+
<input_1.Input.RightAddon>.uxf.cz</input_1.Input.RightAddon>
|
|
54
|
+
</input_1.Input>
|
|
55
|
+
<input_1.Input>
|
|
56
|
+
<input_1.Input.LeftElement>🌷</input_1.Input.LeftElement>
|
|
57
|
+
<input_1.Input.Element value={value} onChange={(0, action_1.action)("onChange", onChange)} placeholder="Placeholder" isInvalid={isInvalid}/>
|
|
58
|
+
<input_1.Input.RightElement>🔔</input_1.Input.RightElement>
|
|
59
|
+
</input_1.Input>
|
|
60
|
+
<input_1.Input>
|
|
61
|
+
<input_1.Input.Element value={value} onChange={(0, action_1.action)("onChange", onChange)} placeholder="Placeholder" isInvalid={isInvalid}/>
|
|
62
|
+
</input_1.Input>
|
|
63
|
+
</div>);
|
|
64
|
+
}
|
|
65
|
+
exports.Default = Default;
|
|
66
|
+
function ComponentStructure() {
|
|
67
|
+
const [value, onChange] = (0, react_1.useState)("");
|
|
68
|
+
return (<component_structure_analyzer_1.default>
|
|
69
|
+
<input_1.Input>
|
|
70
|
+
<input_1.Input.LeftAddon>Left addon</input_1.Input.LeftAddon>
|
|
71
|
+
<input_1.Input.LeftElement>Left element</input_1.Input.LeftElement>
|
|
72
|
+
<input_1.Input.Element value={value} onChange={onChange}/>
|
|
73
|
+
<input_1.Input.RightElement>Right element</input_1.Input.RightElement>
|
|
74
|
+
<input_1.Input.RightAddon>Right addon</input_1.Input.RightAddon>
|
|
75
|
+
</input_1.Input>
|
|
76
|
+
</component_structure_analyzer_1.default>);
|
|
77
|
+
}
|
|
78
|
+
exports.ComponentStructure = ComponentStructure;
|
package/input/theme.d.ts
ADDED
package/input/theme.js
ADDED
package/label/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Label } from "./label";
|
package/label/index.js
ADDED
|
@@ -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.Label = void 0;
|
|
7
|
+
var label_1 = require("./label");
|
|
8
|
+
Object.defineProperty(exports, "Label", { enumerable: true, get: function () { return __importDefault(label_1).default; } });
|
package/label/label.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from "react";
|
|
2
|
+
export interface LabelProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
htmlFor?: string;
|
|
5
|
+
form?: string;
|
|
6
|
+
onClick?: MouseEventHandler<HTMLLabelElement>;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
9
|
+
export default _default;
|
package/label/label.jsx
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const forwardRef_1 = require("@uxf/ui/utils/forwardRef");
|
|
4
|
+
function Label(props, ref) {
|
|
5
|
+
return (<label className="uxf-label" ref={ref} htmlFor={props.htmlFor} form={props.form} onClick={props.onClick}>
|
|
6
|
+
{props.children}
|
|
7
|
+
</label>);
|
|
8
|
+
}
|
|
9
|
+
exports.default = (0, forwardRef_1.forwardRef)("Label", Label);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").ForwardRefExoticComponent<import("./label").LabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export declare function Default(): JSX.Element;
|
|
@@ -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/Label",
|
|
7
|
+
component: index_1.Label,
|
|
8
|
+
};
|
|
9
|
+
function Default() {
|
|
10
|
+
return (<div className="space-y-2">
|
|
11
|
+
<index_1.Label>Label</index_1.Label>
|
|
12
|
+
</div>);
|
|
13
|
+
}
|
|
14
|
+
exports.Default = Default;
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/ui",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.23",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "npm run
|
|
9
|
+
"build": "npm run compile",
|
|
10
10
|
"compile": "tsc -P tsconfig.json",
|
|
11
|
-
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
12
|
-
"prepublish": "npm run-script build"
|
|
11
|
+
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
13
12
|
},
|
|
14
13
|
"author": "",
|
|
15
14
|
"license": "MIT",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Select } from "./select";
|
package/select/index.js
ADDED
|
@@ -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.Select = void 0;
|
|
7
|
+
var select_1 = require("./select");
|
|
8
|
+
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return __importDefault(select_1).default; } });
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FocusEventHandler } from "react";
|
|
2
|
+
export declare type SelectValue = number | string;
|
|
3
|
+
export declare type SelectOption<T = SelectValue> = {
|
|
4
|
+
key?: number | string;
|
|
5
|
+
id: T;
|
|
6
|
+
label: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export interface SelectProps<V = SelectValue, O = SelectOption<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<SelectProps<SelectValue, SelectOption<SelectValue>> & import("react").RefAttributes<HTMLDivElement>>;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 Select(props, ref) {
|
|
15
|
+
const { className, disabled, error, id, invalid, label, onBlur, onChange, onFocus, options, placeholder = "Vyberte z možností...", readOnly, value, } = props;
|
|
16
|
+
const selectedOption = (0, react_2.useMemo)(() => options.find((option) => option.id === value), [options, value]);
|
|
17
|
+
const innerRef = (0, react_2.useRef)(null);
|
|
18
|
+
const disabledOrReadOnly = disabled || readOnly;
|
|
19
|
+
const errorId = invalid ? `${id}--errormessage` : undefined;
|
|
20
|
+
const input = (0, useInputFocus_1.useInputFocus)(innerRef, onBlur, onFocus);
|
|
21
|
+
const dropdown = (0, use_dropdown_1.useDropdown)("bottom", true);
|
|
22
|
+
const stableRef = (0, react_2.useMemo)(() => (0, composeRefs_1.composeRefs)(innerRef, ref, dropdown.reference), [ref, dropdown.reference]);
|
|
23
|
+
return (<react_1.Listbox as="div" className={`select-form-field ${className || ""}`} onChange={onChange} value={selectedOption}>
|
|
24
|
+
<react_1.Listbox.Label as={label_1.Label} onClick={!disabledOrReadOnly ? input.focus : undefined}>
|
|
25
|
+
{label}
|
|
26
|
+
</react_1.Listbox.Label>
|
|
27
|
+
<react_1.Listbox.Button as="div">
|
|
28
|
+
{(b) => (
|
|
29
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
30
|
+
<div aria-invalid={invalid} aria-describedby={errorId} className={(0, cx_1.cx)("select-text-input__control select-text-input__control--select", (b.open || input.focused) && classes_1.CLASSES.IS_FOCUSED, b.disabled && classes_1.CLASSES.IS_DISABLED, readOnly && classes_1.CLASSES.IS_READONLY, invalid && classes_1.CLASSES.IS_INVALID)} onBlur={input.onBlur} onFocus={input.onFocus} tabIndex={!disabledOrReadOnly ? 0 : undefined} ref={stableRef}>
|
|
31
|
+
<div className={`select-text-input ${!value ? "text-gray-muted" : ""}`}>
|
|
32
|
+
{(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || placeholder}
|
|
33
|
+
</div>
|
|
34
|
+
{b.open ? "▲" : "▼"}
|
|
35
|
+
</div>)}
|
|
36
|
+
</react_1.Listbox.Button>
|
|
37
|
+
{invalid && error && <error_message_1.ErrorMessage id={errorId}>{error}</error_message_1.ErrorMessage>}
|
|
38
|
+
<react_1.Listbox.Options as={dropdown_1.Dropdown.Items} className="w-full" ref={dropdown.floating} style={dropdown.style}>
|
|
39
|
+
{options.map((option) => (<react_1.Listbox.Option as={react_2.Fragment} key={option.key || option.id} value={option}>
|
|
40
|
+
{(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)}>
|
|
41
|
+
{option.label}
|
|
42
|
+
</dropdown_1.Dropdown.Item>)}
|
|
43
|
+
</react_1.Listbox.Option>))}
|
|
44
|
+
</react_1.Listbox.Options>
|
|
45
|
+
</react_1.Listbox>);
|
|
46
|
+
}
|
|
47
|
+
exports.default = (0, forwardRef_1.forwardRef)("Select", Select);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SelectOption, SelectValue } from "./select";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: import("react").ForwardRefExoticComponent<import("./select").SelectProps<SelectValue, SelectOption<SelectValue>> & import("react").RefAttributes<HTMLDivElement>>;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export declare function Default(): JSX.Element;
|