@uxf/ui 1.0.0-beta.12 → 1.0.0-beta.18

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.
Files changed (40) hide show
  1. package/avatar/avatar.d.ts +14 -0
  2. package/avatar/avatar.jsx +10 -0
  3. package/avatar/avatar.stories.d.ts +8 -0
  4. package/avatar/avatar.stories.jsx +29 -0
  5. package/avatar/theme.d.ts +5 -0
  6. package/{types.js → avatar/theme.js} +0 -0
  7. package/button/button.d.ts +1 -0
  8. package/button/button.jsx +1 -1
  9. package/button/button.stories.jsx +4 -4
  10. package/input/index.d.ts +13 -6
  11. package/input/index.js +14 -13
  12. package/input/input-element.d.ts +8 -0
  13. package/input/input-element.jsx +11 -0
  14. package/input/input-left-addon.jsx +1 -1
  15. package/input/input-left-element.jsx +1 -1
  16. package/input/input-right-addon.jsx +1 -1
  17. package/input/input-right-element.jsx +1 -1
  18. package/input/input.d.ts +8 -7
  19. package/input/input.jsx +61 -7
  20. package/input/input.stories.d.ts +9 -4
  21. package/input/input.stories.jsx +37 -59
  22. package/package.json +11 -7
  23. package/text-input/index.d.ts +1 -0
  24. package/{storybook → text-input}/index.js +1 -1
  25. package/text-input/text-input.d.ts +22 -0
  26. package/text-input/text-input.jsx +32 -0
  27. package/text-input/text-input.stories.d.ts +9 -0
  28. package/text-input/text-input.stories.jsx +55 -0
  29. package/types/form-control-props.d.ts +1 -1
  30. package/types/index.d.ts +1 -0
  31. package/types/index.js +17 -0
  32. package/{storybook → utils}/action.d.ts +0 -0
  33. package/{storybook → utils}/action.js +0 -0
  34. package/{storybook → utils}/storybook-config.d.ts +1 -1
  35. package/{storybook → utils}/storybook-config.jsx +0 -0
  36. package/input/input-group.d.ts +0 -9
  37. package/input/input-group.jsx +0 -63
  38. package/postcss.config.js +0 -8
  39. package/storybook/index.d.ts +0 -1
  40. package/types.d.ts +0 -6
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { AvatarSizes } from "./theme";
3
+ interface FileResponse {
4
+ uuid: string;
5
+ namespace?: string;
6
+ extension: string;
7
+ }
8
+ export interface AvatarProps {
9
+ src: FileResponse | string | null | undefined;
10
+ size?: keyof AvatarSizes;
11
+ rounded?: boolean;
12
+ }
13
+ export declare function Avatar(props: AvatarProps): JSX.Element;
14
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Avatar = void 0;
4
+ const cx_1 = require("@uxf/core/utils/cx");
5
+ function Avatar(props) {
6
+ var _a;
7
+ const className = (0, cx_1.cx)("avatar", `avatar--size-${props.size}`, `avatar--variant-${(_a = props.circular) !== null && _a !== void 0 ? _a : "default"}`);
8
+ return <img src={props.src} className={className}/>;
9
+ }
10
+ exports.Avatar = Avatar;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { Avatar } from "./avatar";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof Avatar;
6
+ };
7
+ export default _default;
8
+ 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 storybook_config_1 = require("@uxf/ui/utils/storybook-config");
9
+ const avatar_1 = require("./avatar");
10
+ exports.default = {
11
+ title: "UI/Avatar",
12
+ component: avatar_1.Avatar,
13
+ };
14
+ function Default() {
15
+ const config = (0, storybook_config_1.useStorybookConfig)("Button");
16
+ return (<div className="space-y-4">
17
+ <div className="flex flex-row items-center space-x-4">
18
+ <avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="8"/>
19
+ <avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="10"/>
20
+ <avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="12"/>
21
+ </div>
22
+ <div className="flex flex-row items-center space-x-4">
23
+ <avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="8" variant="circular"/>
24
+ <avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="10" variant="circular"/>
25
+ <avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="12" variant="circular"/>
26
+ </div>
27
+ </div>);
28
+ }
29
+ exports.Default = Default;
@@ -0,0 +1,5 @@
1
+ export interface AvatarSizes {
2
+ "8": true;
3
+ "10": true;
4
+ "12": true;
5
+ }
File without changes
@@ -8,6 +8,7 @@ interface ButtonProps {
8
8
  loading?: boolean;
9
9
  startAdornment?: ReactNode;
10
10
  endAdornment?: ReactNode;
11
+ type?: "button" | "submit" | "reset";
11
12
  children: ReactNode;
12
13
  }
13
14
  declare function Button(props: ButtonProps): JSX.Element;
package/button/button.jsx CHANGED
@@ -8,7 +8,7 @@ const cx_1 = require("@uxf/core/utils/cx");
8
8
  function Button(props) {
9
9
  var _a, _b, _c;
10
10
  const className = (0, cx_1.cx)("button", `button--color-${(_a = props.color) !== null && _a !== void 0 ? _a : "default"}`, `button--size-${(_b = props.size) !== null && _b !== void 0 ? _b : "default"}`, `button--variant-${(_c = props.variant) !== null && _c !== void 0 ? _c : "default"}`, props.disabled && `button--disabled`, props.loading && `button--loading`);
11
- return (<button type="button" className={className}>
11
+ return (<button type={props.type} className={className}>
12
12
  {props.startAdornment}
13
13
  {props.children}
14
14
  {props.endAdornment}
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Loading = exports.Disabled = exports.Default = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const button_1 = require("@uxf/ui/button");
9
- const storybook_1 = require("@uxf/ui/storybook");
9
+ const storybook_config_1 = require("@uxf/ui/utils/storybook-config");
10
10
  const react_2 = require("react");
11
11
  exports.default = {
12
12
  title: "UI/Button",
13
13
  component: button_1.Button,
14
14
  };
15
15
  function Default() {
16
- const config = (0, storybook_1.useStorybookConfig)("Button");
16
+ const config = (0, storybook_config_1.useStorybookConfig)("Button");
17
17
  return (<div className="space-y-2">
18
18
  {config.variants.map((variant) => (<react_2.Fragment key={variant}>
19
19
  {config.colors.map((color) => (<react_2.Fragment key={color}>
@@ -28,7 +28,7 @@ function Default() {
28
28
  }
29
29
  exports.Default = Default;
30
30
  function Disabled() {
31
- const config = (0, storybook_1.useStorybookConfig)("Button");
31
+ const config = (0, storybook_config_1.useStorybookConfig)("Button");
32
32
  return (<div className="space-y-2">
33
33
  {config.variants.map((variant) => (<react_2.Fragment key={variant}>
34
34
  {config.colors.map((color) => (<react_2.Fragment key={color}>
@@ -43,7 +43,7 @@ function Disabled() {
43
43
  }
44
44
  exports.Disabled = Disabled;
45
45
  function Loading() {
46
- const config = (0, storybook_1.useStorybookConfig)("Button");
46
+ const config = (0, storybook_config_1.useStorybookConfig)("Button");
47
47
  return (<div className="space-y-2">
48
48
  {config.variants.map((variant) => (<react_2.Fragment key={variant}>
49
49
  {config.colors.map((color) => (<react_2.Fragment key={color}>
package/input/index.d.ts CHANGED
@@ -1,6 +1,13 @@
1
- export { default as Input } from "./input";
2
- export { default as InputGroup } from "./input-group";
3
- export { default as InputLeftElement } from "./input-left-element";
4
- export { default as InputRightElement } from "./input-right-element";
5
- export { default as InputLeftAddon } from "./input-left-addon";
6
- export { default as InputRightAddon } from "./input-right-addon";
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 CHANGED
@@ -3,16 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InputRightAddon = exports.InputLeftAddon = exports.InputRightElement = exports.InputLeftElement = exports.InputGroup = exports.Input = void 0;
7
- var input_1 = require("./input");
8
- Object.defineProperty(exports, "Input", { enumerable: true, get: function () { return __importDefault(input_1).default; } });
9
- var input_group_1 = require("./input-group");
10
- Object.defineProperty(exports, "InputGroup", { enumerable: true, get: function () { return __importDefault(input_group_1).default; } });
11
- var input_left_element_1 = require("./input-left-element");
12
- Object.defineProperty(exports, "InputLeftElement", { enumerable: true, get: function () { return __importDefault(input_left_element_1).default; } });
13
- var input_right_element_1 = require("./input-right-element");
14
- Object.defineProperty(exports, "InputRightElement", { enumerable: true, get: function () { return __importDefault(input_right_element_1).default; } });
15
- var input_left_addon_1 = require("./input-left-addon");
16
- Object.defineProperty(exports, "InputLeftAddon", { enumerable: true, get: function () { return __importDefault(input_left_addon_1).default; } });
17
- var input_right_addon_1 = require("./input-right-addon");
18
- Object.defineProperty(exports, "InputRightAddon", { enumerable: true, get: function () { return __importDefault(input_right_addon_1).default; } });
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);
@@ -5,6 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  function InputLeftAddon(props) {
8
- return <div className="uxf-input-left-addon">{props.children}</div>;
8
+ return <div className="uxf-input__left-addon">{props.children}</div>;
9
9
  }
10
10
  exports.default = InputLeftAddon;
@@ -5,6 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  function InputLeftElement(props) {
8
- return <div className="uxf-input-left-element">{props.children}</div>;
8
+ return <div className="uxf-input__left-element">{props.children}</div>;
9
9
  }
10
10
  exports.default = InputLeftElement;
@@ -5,6 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  function InputRightAddon(props) {
8
- return <div className="uxf-input-right-addon">{props.children}</div>;
8
+ return <div className="uxf-input__right-addon">{props.children}</div>;
9
9
  }
10
10
  exports.default = InputRightAddon;
@@ -5,6 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  function InputRightElement(props) {
8
- return <div className="uxf-input-right-element">{props.children}</div>;
8
+ return <div className="uxf-input__right-element">{props.children}</div>;
9
9
  }
10
10
  exports.default = InputRightElement;
package/input/input.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import React from "react";
2
- import { FormControlProps } from "@uxf/ui/types/form-control-props";
3
- interface InputProps extends FormControlProps<string> {
4
- id?: string;
5
- placeholder?: string;
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;
6
7
  }
7
- declare const _default: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
8
- export default _default;
8
+ declare function Input(props: InputProps): JSX.Element;
9
+ export default Input;
package/input/input.jsx CHANGED
@@ -1,11 +1,65 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const forwardRef_1 = require("@uxf/ui/utils/forwardRef");
8
- function Input(props, ref) {
9
- return (<input id={props.id} ref={ref} className="uxf-input" 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}/>);
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);
10
32
  }
11
- exports.default = (0, forwardRef_1.forwardRef)("Input", Input);
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;
@@ -1,9 +1,14 @@
1
- /// <reference types="react" />
2
- import InputGroup from "@uxf/ui/input/input-group";
1
+ import React from "react";
3
2
  declare const _default: {
4
3
  title: string;
5
- component: typeof InputGroup;
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
+ };
6
11
  };
7
12
  export default _default;
8
- export declare function ComponentStructure(): JSX.Element;
9
13
  export declare function Default(): JSX.Element;
14
+ export declare function ComponentStructure(): JSX.Element;
@@ -26,75 +26,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Default = exports.ComponentStructure = void 0;
29
+ exports.ComponentStructure = exports.Default = void 0;
30
30
  const react_1 = __importStar(require("react"));
31
- const input_1 = __importDefault(require("@uxf/ui/input/input"));
32
- const input_left_addon_1 = __importDefault(require("@uxf/ui/input/input-left-addon"));
33
- const input_right_addon_1 = __importDefault(require("@uxf/ui/input/input-right-addon"));
34
- const input_group_1 = __importDefault(require("@uxf/ui/input/input-group"));
35
31
  const component_structure_analyzer_1 = __importDefault(require("@uxf/ui/utils/component-structure-analyzer"));
36
- const input_left_element_1 = __importDefault(require("@uxf/ui/input/input-left-element"));
37
- const input_right_element_1 = __importDefault(require("@uxf/ui/input/input-right-element"));
38
- const action_1 = require("@uxf/ui/storybook/action");
32
+ const action_1 = require("@uxf/ui/utils/action");
33
+ const input_1 = require("@uxf/ui/input");
39
34
  exports.default = {
40
35
  title: "UI/Input",
41
- component: input_group_1.default,
36
+ component: input_1.Input,
42
37
  };
43
- function ComponentStructure() {
44
- const [value, onChange] = (0, react_1.useState)("");
45
- return (<>
46
- <h2>Full example</h2>
47
- <component_structure_analyzer_1.default>
48
- <input_group_1.default>
49
- <input_left_addon_1.default>Left addon</input_left_addon_1.default>
50
- <input_left_element_1.default>Left element</input_left_element_1.default>
51
- <input_1.default value={value} onChange={onChange}/>
52
- <input_right_element_1.default>Right element</input_right_element_1.default>
53
- <input_right_addon_1.default>Right addon</input_right_addon_1.default>
54
- </input_group_1.default>
55
- </component_structure_analyzer_1.default>
56
- <h2>Only input elements</h2>
57
- <component_structure_analyzer_1.default>
58
- <input_group_1.default>
59
- <input_left_element_1.default>Left element</input_left_element_1.default>
60
- <input_1.default value={value} onChange={onChange}/>
61
- <input_right_element_1.default>Right element</input_right_element_1.default>
62
- </input_group_1.default>
63
- </component_structure_analyzer_1.default>
64
- <h2>Only addons</h2>
65
- <component_structure_analyzer_1.default>
66
- <input_group_1.default>
67
- <input_1.default value={value} onChange={onChange}/>
68
- </input_group_1.default>
69
- </component_structure_analyzer_1.default>
70
- </>);
71
- }
72
- exports.ComponentStructure = ComponentStructure;
73
38
  function Default() {
74
39
  const [value, onChange] = (0, react_1.useState)("");
75
40
  const [isInvalid, setInvalid] = (0, react_1.useState)(false);
76
41
  return (<div className="space-y-2">
77
42
  <input type="checkbox" checked={isInvalid} onChange={(e) => setInvalid(e.target.checked)}/>
78
- <input_group_1.default>
79
- <input_left_addon_1.default>InputLeftAddon</input_left_addon_1.default>
80
- <input_left_element_1.default>InputLeftElement</input_left_element_1.default>
81
- <input_1.default value={value} onChange={(0, action_1.action)("onChange", onChange)} placeholder="Placeholder" isInvalid={isInvalid}/>
82
- <input_right_element_1.default>InputRightElement</input_right_element_1.default>
83
- <input_right_addon_1.default>InputRightAddon</input_right_addon_1.default>
84
- </input_group_1.default>
85
- <input_group_1.default>
86
- <input_left_addon_1.default>https://</input_left_addon_1.default>
87
- <input_1.default value={value} onChange={(0, action_1.action)("onChange", onChange)} placeholder="Placeholder" isInvalid={isInvalid}/>
88
- <input_right_addon_1.default>.uxf.cz</input_right_addon_1.default>
89
- </input_group_1.default>
90
- <input_group_1.default>
91
- <input_left_element_1.default>🌷</input_left_element_1.default>
92
- <input_1.default value={value} onChange={(0, action_1.action)("onChange", onChange)} placeholder="Placeholder" isInvalid={isInvalid}/>
93
- <input_right_element_1.default>🔔</input_right_element_1.default>
94
- </input_group_1.default>
95
- <input_group_1.default>
96
- <input_1.default value={value} onChange={(0, action_1.action)("onChange", onChange)} placeholder="Placeholder" isInvalid={isInvalid}/>
97
- </input_group_1.default>
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>
98
63
  </div>);
99
64
  }
100
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/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "@uxf/ui",
3
- "version": "1.0.0-beta.12",
3
+ "version": "1.0.0-beta.18",
4
4
  "description": "",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
5
8
  "scripts": {
6
- "build": "npm run-script clean && npm run-script compile",
7
- "clean": "rm -rf ./dist",
9
+ "build": "yarn compile",
8
10
  "compile": "tsc -P tsconfig.json",
9
- "typecheck": "tsc --noEmit --skipLibCheck"
11
+ "typecheck": "tsc --noEmit --skipLibCheck",
12
+ "prepublish": "yarn build"
10
13
  },
11
14
  "author": "",
12
15
  "license": "MIT",
13
16
  "dependencies": {
14
- "@uxf/core": "^2.2.4"
15
- }
16
- }
17
+ "@uxf/core": "latest"
18
+ },
19
+ "stableVersion": "1.0.0-beta.15"
20
+ }
@@ -0,0 +1 @@
1
+ export * from "./text-input";
@@ -14,4 +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("./storybook-config"), exports);
17
+ __exportStar(require("./text-input"), exports);
@@ -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 {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextInput = void 0;
4
+ const input_1 = require("@uxf/ui/input");
5
+ const react_1 = require("react");
6
+ const cx_1 = require("@uxf/ui/utils/cx");
7
+ function TextInput(props) {
8
+ const [isFocused, setIsFocused] = (0, react_1.useState)(false);
9
+ const rootClassName = (0, cx_1.cx)("uxf-text-input", props.isInvalid && "uxf-text-input--invalid", props.isDisabled && "uxf-text-input--disabled", props.isRequired && "uxf-text-input--required", isFocused && "uxf-text-input--focused");
10
+ const onFocus = (e) => {
11
+ var _a;
12
+ setIsFocused(true);
13
+ (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e);
14
+ };
15
+ const onBlur = (e) => {
16
+ var _a;
17
+ setIsFocused(false);
18
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
19
+ };
20
+ return (<div className={rootClassName}>
21
+ <label className="uxf-text-input__label">{props.label}</label>
22
+ <input_1.Input size={props.size} variant={props.variant}>
23
+ {props.leftAddon && (<input_1.Input.LeftAddon>{props.leftAddon}</input_1.Input.LeftAddon>)}
24
+ {props.leftElement && (<input_1.Input.LeftElement>{props.leftElement}</input_1.Input.LeftElement>)}
25
+ <input_1.Input.Element name={props.name} value={props.value} onChange={props.onChange} onFocus={onFocus} onBlur={onBlur} isInvalid={props.isInvalid} isRequired={props.isRequired} isReadOnly={props.isReadOnly} isDisabled={props.isDisabled} placeholder={props.placeholder}/>
26
+ {props.rightElement && (<input_1.Input.RightElement>{props.rightElement}</input_1.Input.RightElement>)}
27
+ {props.rightAddon && (<input_1.Input.RightAddon>{props.rightAddon}</input_1.Input.RightAddon>)}
28
+ </input_1.Input>
29
+ <div className="uxf-text-input__helper-text">{props.helperText}</div>
30
+ </div>);
31
+ }
32
+ exports.TextInput = TextInput;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { TextInput } from "@uxf/ui/text-input";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof TextInput;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): JSX.Element;
9
+ export declare function ComponentStructure(): JSX.Element;
@@ -0,0 +1,55 @@
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 text_input_1 = require("@uxf/ui/text-input");
32
+ const component_structure_analyzer_1 = __importDefault(require("@uxf/ui/utils/component-structure-analyzer"));
33
+ exports.default = {
34
+ title: "UI/TextInput",
35
+ component: text_input_1.TextInput,
36
+ };
37
+ function Default() {
38
+ const [value, onChange] = (0, react_1.useState)("");
39
+ const [isInvalid, setInvalid] = (0, react_1.useState)(false);
40
+ return (<div className="space-y-4">
41
+ <input type="checkbox" checked={isInvalid} onChange={(e) => setInvalid(e.target.checked)}/>
42
+ <text_input_1.TextInput label="Label" value={value} onChange={onChange} isInvalid={isInvalid} helperText="Helper text" isRequired/>
43
+ <text_input_1.TextInput label="Label" value={value} onChange={onChange} isInvalid={isInvalid} helperText="Helper text" leftElement="USD"/>
44
+ <text_input_1.TextInput label="Label" value={value} onChange={onChange} isInvalid={isInvalid} helperText="Helper text" leftAddon="https://" rightAddon=".cz" leftElement="🌷" rightElement="🔔"/>
45
+ </div>);
46
+ }
47
+ exports.Default = Default;
48
+ function ComponentStructure() {
49
+ const [value, onChange] = (0, react_1.useState)("");
50
+ const [isInvalid, setInvalid] = (0, react_1.useState)(false);
51
+ return (<component_structure_analyzer_1.default>
52
+ <text_input_1.TextInput label="Label" placeholder="Placeholder" leftElement="🌷" rightElement="🔔" leftAddon="https://" rightAddon=".cz" value={value} onChange={onChange} isInvalid={isInvalid} helperText="Helper text"/>
53
+ </component_structure_analyzer_1.default>);
54
+ }
55
+ exports.ComponentStructure = ComponentStructure;
@@ -1,6 +1,6 @@
1
1
  import { ChangeEvent, FocusEventHandler } from "react";
2
2
  export interface FormControlProps<ValueType, ElementType = HTMLInputElement, RestParams extends unknown[] = []> {
3
- value: ValueType;
3
+ value?: ValueType;
4
4
  onChange?: (value: ValueType, event?: ChangeEvent<ElementType>, ...args: RestParams) => void;
5
5
  onBlur?: FocusEventHandler<ElementType>;
6
6
  onFocus?: FocusEventHandler<ElementType>;
@@ -0,0 +1 @@
1
+ export * from "./form-control-props";
package/types/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./form-control-props"), exports);
File without changes
File without changes
@@ -1,5 +1,5 @@
1
- import { ButtonColors, ButtonSizes, ButtonVariants } from "@uxf/ui/button";
2
1
  import { ReactNode } from "react";
2
+ import { ButtonColors, ButtonSizes, ButtonVariants } from "../button";
3
3
  export declare const defaultConfig: StorybookConfig;
4
4
  export interface StorybookConfig {
5
5
  Button: {
File without changes
@@ -1,9 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { InputGroupSizes, InputGroupVariants } from "@uxf/ui/input/theme";
3
- interface InputGroupProps {
4
- children: ReactNode;
5
- variant?: keyof InputGroupVariants;
6
- size?: keyof InputGroupSizes;
7
- }
8
- declare function InputGroup(props: InputGroupProps): JSX.Element;
9
- export default InputGroup;
@@ -1,63 +0,0 @@
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 InputGroup(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, "Input");
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-group", leftAddon && "uxf-input-group--has-left-addon", leftElement && "uxf-input-group--has-left-element", rightElement && "uxf-input-group--has-right-element", rightAddon && "uxf-input-group--has-right-addon", focused && "uxf-input-group--focused", (mainInput === null || mainInput === void 0 ? void 0 : mainInput.props.isInvalid) && "uxf-input-group--invalid");
43
- const onFocus = (e) => {
44
- setFocused(true);
45
- mainInput === null || mainInput === void 0 ? void 0 : mainInput.props.onFocus(e);
46
- };
47
- const onBlur = (e) => {
48
- setFocused(false);
49
- mainInput === null || mainInput === void 0 ? void 0 : mainInput.props.onBlur(e);
50
- };
51
- return (<div className={inputGroupClasses}>
52
- {leftAddon}
53
- <div className="uxf-input-wrapper" ref={inputWrapperRef} onClick={() => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }}>
54
- {leftElement}
55
- {mainInput
56
- ? react_1.default.cloneElement(mainInput, { ref: inputRef, onFocus, onBlur })
57
- : null}
58
- {rightElement}
59
- </div>
60
- {rightAddon}
61
- </div>);
62
- }
63
- exports.default = InputGroup;
package/postcss.config.js DELETED
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- plugins: {
3
- "postcss-import": {},
4
- "tailwindcss/nesting": {},
5
- tailwindcss: {},
6
- autoprefixer: {},
7
- },
8
- };
@@ -1 +0,0 @@
1
- export * from "./storybook-config";
package/types.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare type Classes<T extends string> = {
2
- [key in T]: string;
3
- };
4
- export declare type FlexboxAlign = "flex-start" | "flex-end" | "center" | "stretch";
5
- export declare type FlexboxJustify = FlexboxAlign | "space-around" | "space-between" | "stretch";
6
- export declare type Gap = "gap-0" | "gap-0.5" | "gap-1" | "gap-1.5" | "gap-2" | "gap-2.5" | "gap-3" | "gap-4" | "gap-5" | "gap-6" | "gap-7" | "gap-8" | "gap-9" | "gap-10" | "gap-11" | "gap-12" | "gap-14" | "gap-16" | "gap-20" | "gap-24" | "gap-28" | "gap-32" | "gap-36" | "gap-40" | "gap-44" | "gap-48" | "gap-52" | "gap-56" | "gap-60" | "gap-64" | "gap-72" | "gap-80" | "gap-96";