@uxf/ui 1.0.0-beta.10 → 1.0.0-beta.13
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/avatar.d.ts +14 -0
- package/avatar/avatar.jsx +10 -0
- package/avatar/avatar.stories.d.ts +8 -0
- package/avatar/avatar.stories.jsx +29 -0
- package/avatar/theme.d.ts +5 -0
- package/avatar/theme.js +2 -0
- package/button/button.css +75 -0
- package/button/button.d.ts +1 -0
- package/button/button.jsx +17 -0
- package/button/button.stories.jsx +59 -0
- package/{stories → button}/button.stories.tsx +1 -1
- package/button/button.tsx +36 -0
- package/button/index.js +0 -1
- package/button/index.ts +2 -0
- package/button/theme.d.ts +4 -1
- package/button/theme.js +0 -1
- package/button/theme.ts +20 -0
- package/image-gallery/components/close-button.d.ts +6 -0
- package/image-gallery/components/close-button.jsx +13 -0
- package/image-gallery/components/close-button.tsx +19 -0
- package/image-gallery/components/dot.d.ts +6 -0
- package/image-gallery/components/dot.jsx +12 -0
- package/image-gallery/components/dot.tsx +17 -0
- package/image-gallery/components/gallery.d.ts +11 -0
- package/image-gallery/components/gallery.jsx +74 -0
- package/image-gallery/components/gallery.tsx +67 -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-left.tsx +18 -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-chevron-right.tsx +18 -0
- package/image-gallery/components/icon-close.d.ts +3 -0
- package/image-gallery/components/icon-close.jsx +12 -0
- package/image-gallery/components/icon-close.tsx +22 -0
- package/image-gallery/components/next-button.d.ts +6 -0
- package/image-gallery/components/next-button.jsx +13 -0
- package/image-gallery/components/next-button.tsx +19 -0
- package/image-gallery/components/previous-button.d.ts +6 -0
- package/image-gallery/components/previous-button.jsx +13 -0
- package/image-gallery/components/previous-button.tsx +19 -0
- package/image-gallery/context.d.ts +10 -0
- package/image-gallery/context.jsx +12 -0
- package/image-gallery/context.tsx +17 -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-gallery.stories.tsx +33 -0
- package/image-gallery/image-gallery.tsx +59 -0
- package/image-gallery/image.d.ts +4 -0
- package/image-gallery/image.jsx +12 -0
- package/image-gallery/image.tsx +19 -0
- package/image-gallery/index.d.ts +3 -0
- package/image-gallery/index.js +25 -0
- package/image-gallery/index.ts +3 -0
- package/image-gallery/types.d.ts +6 -0
- package/image-gallery/types.js +2 -0
- package/image-gallery/types.ts +6 -0
- package/image-gallery/use-image.d.ts +2 -0
- package/image-gallery/use-image.js +16 -0
- package/image-gallery/use-image.ts +17 -0
- package/input/index.d.ts +12 -0
- package/input/index.js +19 -0
- package/input/index.ts +14 -0
- package/input/input-basic.css +18 -0
- package/input/input-element.d.ts +8 -0
- package/input/input-element.jsx +11 -0
- package/input/input-element.tsx +30 -0
- package/input/input-left-addon.d.ts +6 -0
- package/input/input-left-addon.jsx +10 -0
- package/input/input-left-addon.tsx +12 -0
- package/input/input-left-element.d.ts +6 -0
- package/input/input-left-element.jsx +10 -0
- package/input/input-left-element.tsx +11 -0
- package/input/input-right-addon.d.ts +6 -0
- package/input/input-right-addon.jsx +10 -0
- package/input/input-right-addon.tsx +11 -0
- package/input/input-right-element.d.ts +6 -0
- package/input/input-right-element.jsx +10 -0
- package/input/input-right-element.tsx +11 -0
- package/input/input.css +75 -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/input.stories.tsx +79 -0
- package/input/input.tsx +70 -0
- package/input/theme.d.ts +6 -0
- package/input/theme.js +2 -0
- package/input/theme.ts +7 -0
- package/package.json +8 -34
- package/text-input/index.d.ts +1 -0
- package/{storybook → text-input}/index.js +1 -2
- package/text-input/index.ts +1 -0
- package/text-input/text-input.css +29 -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/text-input/text-input.stories.tsx +72 -0
- package/text-input/text-input.tsx +99 -0
- package/tsconfig.json +7 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/types/form-control-props.d.ts +24 -0
- package/types/form-control-props.js +2 -0
- package/types/form-control-props.ts +35 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +17 -0
- package/types/index.ts +1 -0
- package/utils/action.d.ts +2 -0
- package/utils/action.js +11 -0
- package/utils/action.ts +14 -0
- package/utils/component-structure-analyzer.css +28 -0
- package/utils/component-structure-analyzer.d.ts +6 -0
- package/utils/component-structure-analyzer.jsx +10 -0
- package/utils/component-structure-analyzer.tsx +12 -0
- package/utils/cx.d.ts +3 -0
- package/utils/cx.js +54 -0
- package/utils/cx.ts +56 -0
- package/utils/forwardRef.d.ts +12 -0
- package/utils/forwardRef.js +10 -0
- package/utils/forwardRef.ts +30 -0
- package/{storybook → utils}/storybook-config.d.ts +3 -6
- package/{storybook/storybook-config.js → utils/storybook-config.jsx} +5 -5
- package/utils/storybook-config.tsx +42 -0
- package/button/button.js +0 -17
- package/button/button.stories.js +0 -33
- package/storybook/index.d.ts +0 -1
- package/tailwindui/button.css +0 -51
- package/types.d.ts +0 -3
- package/types.js +0 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { forwardRef } from "../utils/forwardRef";
|
|
3
|
+
|
|
4
|
+
interface InputLeftAddonProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function InputLeftAddon(props: InputLeftAddonProps) {
|
|
9
|
+
return <div className="uxf-input__left-addon">{props.children}</div>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export 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,11 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
interface InputLeftElementProps {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function InputLeftElement(props: InputLeftElementProps) {
|
|
8
|
+
return <div className="uxf-input__left-element">{props.children}</div>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export 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,11 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
interface InputRightAddonProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function InputRightAddon(props: InputRightAddonProps) {
|
|
8
|
+
return <div className="uxf-input__right-addon">{props.children}</div>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export 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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
interface InputRightElementProps {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function InputRightElement(props: InputRightElementProps) {
|
|
8
|
+
return <div className="uxf-input__right-element">{props.children}</div>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default InputRightElement;
|
package/input/input.css
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
.uxf-input {
|
|
2
|
+
@apply rounded-md text-sm shadow-sm;
|
|
3
|
+
|
|
4
|
+
&__left-element,
|
|
5
|
+
&__right-element {
|
|
6
|
+
@apply text-gray-400;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&__left-element {
|
|
10
|
+
@apply pl-2;
|
|
11
|
+
}
|
|
12
|
+
&__right-element {
|
|
13
|
+
@apply pr-2;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&__left-addon,
|
|
17
|
+
&__right-addon {
|
|
18
|
+
@apply border border-gray-300 bg-gray-50 px-2 text-gray-500;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&__left-addon {
|
|
22
|
+
@apply rounded-l-md border-r-0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&__right-addon {
|
|
26
|
+
@apply rounded-r-md border-l-0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&__wrapper {
|
|
30
|
+
@apply h-10 rounded-md border border-gray-300;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&__element {
|
|
34
|
+
@apply bg-transparent outline-none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&--has-right-addon {
|
|
38
|
+
.uxf-input__wrapper {
|
|
39
|
+
@apply rounded-r-none;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&--has-left-addon {
|
|
44
|
+
.uxf-input__wrapper {
|
|
45
|
+
@apply rounded-l-none;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&--focused {
|
|
50
|
+
.uxf-input__wrapper {
|
|
51
|
+
@apply border-primary-500 ring-1 ring-inset ring-primary-500 ring-offset-0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&--invalid {
|
|
56
|
+
&.uxf-input--focused {
|
|
57
|
+
.uxf-input__wrapper {
|
|
58
|
+
@apply ring-1 ring-inset ring-error-500 ring-offset-0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.uxf-input__wrapper {
|
|
63
|
+
@apply border-error-500 placeholder-error-300;
|
|
64
|
+
|
|
65
|
+
.uxf-input__left-element,
|
|
66
|
+
.uxf-input__right-element {
|
|
67
|
+
@apply text-error-500;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.uxf-input__element {
|
|
71
|
+
@apply text-error-900 placeholder-error-300;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
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;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import ComponentStructureAnalyzer from "@uxf/ui/utils/component-structure-analyzer";
|
|
3
|
+
import { action } from "@uxf/ui/utils/action";
|
|
4
|
+
import { Input } from "@uxf/ui/input";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "UI/Input",
|
|
8
|
+
component: Input,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function Default() {
|
|
12
|
+
const [value, onChange] = useState("");
|
|
13
|
+
const [isInvalid, setInvalid] = useState(false);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className="space-y-2">
|
|
17
|
+
<input
|
|
18
|
+
type="checkbox"
|
|
19
|
+
checked={isInvalid}
|
|
20
|
+
onChange={(e) => setInvalid(e.target.checked)}
|
|
21
|
+
/>
|
|
22
|
+
<Input>
|
|
23
|
+
<Input.LeftAddon>InputLeftAddon</Input.LeftAddon>
|
|
24
|
+
<Input.LeftElement>InputLeftElement</Input.LeftElement>
|
|
25
|
+
<Input.Element
|
|
26
|
+
value={value}
|
|
27
|
+
onChange={action("onChange", onChange)}
|
|
28
|
+
placeholder="Placeholder"
|
|
29
|
+
isInvalid={isInvalid}
|
|
30
|
+
/>
|
|
31
|
+
<Input.RightElement>InputRightElement</Input.RightElement>
|
|
32
|
+
<Input.RightAddon>InputRightAddon</Input.RightAddon>
|
|
33
|
+
</Input>
|
|
34
|
+
<Input>
|
|
35
|
+
<Input.LeftAddon>https://</Input.LeftAddon>
|
|
36
|
+
<Input.Element
|
|
37
|
+
value={value}
|
|
38
|
+
onChange={action("onChange", onChange)}
|
|
39
|
+
placeholder="Placeholder"
|
|
40
|
+
isInvalid={isInvalid}
|
|
41
|
+
/>
|
|
42
|
+
<Input.RightAddon>.uxf.cz</Input.RightAddon>
|
|
43
|
+
</Input>
|
|
44
|
+
<Input>
|
|
45
|
+
<Input.LeftElement>🌷</Input.LeftElement>
|
|
46
|
+
<Input.Element
|
|
47
|
+
value={value}
|
|
48
|
+
onChange={action("onChange", onChange)}
|
|
49
|
+
placeholder="Placeholder"
|
|
50
|
+
isInvalid={isInvalid}
|
|
51
|
+
/>
|
|
52
|
+
<Input.RightElement>🔔</Input.RightElement>
|
|
53
|
+
</Input>
|
|
54
|
+
<Input>
|
|
55
|
+
<Input.Element
|
|
56
|
+
value={value}
|
|
57
|
+
onChange={action("onChange", onChange)}
|
|
58
|
+
placeholder="Placeholder"
|
|
59
|
+
isInvalid={isInvalid}
|
|
60
|
+
/>
|
|
61
|
+
</Input>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function ComponentStructure() {
|
|
67
|
+
const [value, onChange] = useState("");
|
|
68
|
+
return (
|
|
69
|
+
<ComponentStructureAnalyzer>
|
|
70
|
+
<Input>
|
|
71
|
+
<Input.LeftAddon>Left addon</Input.LeftAddon>
|
|
72
|
+
<Input.LeftElement>Left element</Input.LeftElement>
|
|
73
|
+
<Input.Element value={value} onChange={onChange} />
|
|
74
|
+
<Input.RightElement>Right element</Input.RightElement>
|
|
75
|
+
<Input.RightAddon>Right addon</Input.RightAddon>
|
|
76
|
+
</Input>
|
|
77
|
+
</ComponentStructureAnalyzer>
|
|
78
|
+
);
|
|
79
|
+
}
|
package/input/input.tsx
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, { ReactElement, ReactNode, useRef, useState } from "react";
|
|
2
|
+
import { cx } from "@uxf/ui/utils/cx";
|
|
3
|
+
import { InputGroupSizes, InputGroupVariants } from "@uxf/ui/input/theme";
|
|
4
|
+
|
|
5
|
+
export interface InputProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
variant?: keyof InputGroupVariants;
|
|
8
|
+
size?: keyof InputGroupSizes;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getChildrenById(
|
|
12
|
+
children: ReactNode,
|
|
13
|
+
componentName: string
|
|
14
|
+
): ReactElement | undefined {
|
|
15
|
+
return React.Children.toArray(children)
|
|
16
|
+
.filter(React.isValidElement)
|
|
17
|
+
.find((ch) => (ch.type as any).displayName === componentName);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function Input(props: InputProps) {
|
|
21
|
+
const inputWrapperRef = useRef<HTMLDivElement>(null);
|
|
22
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
23
|
+
const [focused, setFocused] = useState(false);
|
|
24
|
+
|
|
25
|
+
const mainInput = getChildrenById(props.children, "InputElement");
|
|
26
|
+
const leftAddon = getChildrenById(props.children, "InputLeftAddon");
|
|
27
|
+
const rightAddon = getChildrenById(props.children, "InputRightAddon");
|
|
28
|
+
const leftElement = getChildrenById(props.children, "InputLeftElement");
|
|
29
|
+
const rightElement = getChildrenById(props.children, "InputRightElement");
|
|
30
|
+
|
|
31
|
+
const inputGroupClasses = cx(
|
|
32
|
+
"uxf-input",
|
|
33
|
+
leftAddon && "uxf-input--has-left-addon",
|
|
34
|
+
leftElement && "uxf-input--has-left-element",
|
|
35
|
+
rightElement && "uxf-input--has-right-element",
|
|
36
|
+
rightAddon && "uxf-input--has-right-addon",
|
|
37
|
+
focused && "uxf-input--focused",
|
|
38
|
+
mainInput?.props.isInvalid && "uxf-input--invalid"
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const onFocus = (e: any) => {
|
|
42
|
+
setFocused(true);
|
|
43
|
+
mainInput?.props.onFocus?.(e);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const onBlur = (e: any) => {
|
|
47
|
+
setFocused(false);
|
|
48
|
+
mainInput?.props.onBlur?.(e);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div className={inputGroupClasses}>
|
|
53
|
+
{leftAddon}
|
|
54
|
+
<div
|
|
55
|
+
className="uxf-input__wrapper"
|
|
56
|
+
ref={inputWrapperRef}
|
|
57
|
+
onClick={() => inputRef.current?.focus()}
|
|
58
|
+
>
|
|
59
|
+
{leftElement}
|
|
60
|
+
{mainInput
|
|
61
|
+
? React.cloneElement(mainInput, { ref: inputRef, onFocus, onBlur })
|
|
62
|
+
: null}
|
|
63
|
+
{rightElement}
|
|
64
|
+
</div>
|
|
65
|
+
{rightAddon}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default Input;
|
package/input/theme.d.ts
ADDED
package/input/theme.js
ADDED
package/input/theme.ts
ADDED
package/package.json
CHANGED
|
@@ -1,46 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/ui",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "index.js",
|
|
3
|
+
"version": "1.0.0-beta.13",
|
|
4
|
+
"description": "",
|
|
6
5
|
"publishConfig": {
|
|
7
6
|
"access": "public"
|
|
8
7
|
},
|
|
9
8
|
"scripts": {
|
|
10
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
-
"dev": "concurrently \"tailwindcss -i ./global.css -o ./.storybook/generated.css --watch\" \"start-storybook -p 6006\"",
|
|
12
9
|
"build": "npm run-script clean && npm run-script compile",
|
|
13
10
|
"clean": "rm -rf ./dist",
|
|
14
|
-
"compile": "tsc -P tsconfig.
|
|
15
|
-
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
11
|
+
"compile": "tsc -P tsconfig.json",
|
|
12
|
+
"typecheck": "tsc --noEmit --skipLibCheck",
|
|
13
|
+
"prepublish": "yarn run build"
|
|
16
14
|
},
|
|
17
15
|
"author": "",
|
|
18
|
-
"license": "
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@babel/core": "^7.18.9",
|
|
21
|
-
"@storybook/addon-actions": "^6.5.9",
|
|
22
|
-
"@storybook/addon-essentials": "^6.5.9",
|
|
23
|
-
"@storybook/addon-interactions": "^6.5.9",
|
|
24
|
-
"@storybook/addon-links": "^6.5.9",
|
|
25
|
-
"@storybook/builder-webpack4": "^6.5.9",
|
|
26
|
-
"@storybook/manager-webpack4": "^6.5.9",
|
|
27
|
-
"@storybook/react": "^6.5.9",
|
|
28
|
-
"@storybook/testing-library": "^0.0.13",
|
|
29
|
-
"@types/react": "^18.0.15",
|
|
30
|
-
"autoprefixer": "^10.4.8",
|
|
31
|
-
"babel-loader": "^8.2.5",
|
|
32
|
-
"concurrently": "^7.3.0",
|
|
33
|
-
"postcss": "^8.4.14",
|
|
34
|
-
"postcss-import": "^14.1.0",
|
|
35
|
-
"postcss-nesting": "^10.1.10",
|
|
36
|
-
"prettier": "^2.7.1",
|
|
37
|
-
"react": "^17.0.2",
|
|
38
|
-
"react-dom": "^17.0.2",
|
|
39
|
-
"tailwindcss": "^3.1.6",
|
|
40
|
-
"tsconfig-paths-webpack-plugin": "^4.0.0",
|
|
41
|
-
"typescript": "^4.7.4"
|
|
42
|
-
},
|
|
16
|
+
"license": "MIT",
|
|
43
17
|
"dependencies": {
|
|
44
|
-
"@uxf/core": "
|
|
18
|
+
"@uxf/core": "latest"
|
|
45
19
|
}
|
|
46
|
-
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./text-input";
|
|
@@ -14,5 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3Rvcnlib29rL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxxREFBbUMifQ==
|
|
17
|
+
__exportStar(require("./text-input"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./text-input";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.uxf-text-input {
|
|
2
|
+
&__label {
|
|
3
|
+
@apply mb-1 block text-sm font-medium text-gray-700;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
&__helper-text {
|
|
7
|
+
@apply mt-1 text-xs text-gray-500;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&--invalid {
|
|
11
|
+
.uxf-text-input__helper-text {
|
|
12
|
+
@apply text-error-600;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&--focused {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&--disabled {
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&--required {
|
|
23
|
+
.uxf-text-input__label {
|
|
24
|
+
&::after {
|
|
25
|
+
content: " *";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FormControlProps } from "@uxf/ui/types";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { InputProps } from "@uxf/ui/input/input";
|
|
4
|
+
declare type EnterKeyHint = "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
5
|
+
declare type InputMode = "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
|
|
6
|
+
export interface TextInputProps extends FormControlProps<string>, Pick<InputProps, "size" | "variant"> {
|
|
7
|
+
autoComplete?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
enterKeyHint?: EnterKeyHint;
|
|
10
|
+
form?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
inputMode?: InputMode;
|
|
13
|
+
label?: ReactNode;
|
|
14
|
+
helperText?: ReactNode;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
leftElement?: ReactNode;
|
|
17
|
+
rightElement?: ReactNode;
|
|
18
|
+
leftAddon?: ReactNode;
|
|
19
|
+
rightAddon?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export declare function TextInput(props: TextInputProps): JSX.Element;
|
|
22
|
+
export {};
|