@uxf/ui 1.0.0-beta.12 → 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.
Files changed (85) 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.css +75 -0
  8. package/button/button.d.ts +1 -0
  9. package/button/button.jsx +1 -1
  10. package/button/button.stories.jsx +4 -4
  11. package/button/button.stories.tsx +98 -0
  12. package/button/button.tsx +36 -0
  13. package/button/index.ts +2 -0
  14. package/button/theme.ts +20 -0
  15. package/image-gallery/components/close-button.tsx +19 -0
  16. package/image-gallery/components/dot.tsx +17 -0
  17. package/image-gallery/components/gallery.tsx +67 -0
  18. package/image-gallery/components/icon-chevron-left.tsx +18 -0
  19. package/image-gallery/components/icon-chevron-right.tsx +18 -0
  20. package/image-gallery/components/icon-close.tsx +22 -0
  21. package/image-gallery/components/next-button.tsx +19 -0
  22. package/image-gallery/components/previous-button.tsx +19 -0
  23. package/image-gallery/context.tsx +17 -0
  24. package/image-gallery/image-gallery.stories.tsx +33 -0
  25. package/image-gallery/image-gallery.tsx +59 -0
  26. package/image-gallery/image.tsx +19 -0
  27. package/image-gallery/index.ts +3 -0
  28. package/image-gallery/types.ts +6 -0
  29. package/image-gallery/use-image.ts +17 -0
  30. package/input/index.d.ts +12 -6
  31. package/input/index.js +14 -13
  32. package/input/index.ts +14 -0
  33. package/input/input-basic.css +18 -0
  34. package/input/input-element.d.ts +8 -0
  35. package/input/input-element.jsx +11 -0
  36. package/input/input-element.tsx +30 -0
  37. package/input/input-left-addon.jsx +1 -1
  38. package/input/input-left-addon.tsx +12 -0
  39. package/input/input-left-element.jsx +1 -1
  40. package/input/input-left-element.tsx +11 -0
  41. package/input/input-right-addon.jsx +1 -1
  42. package/input/input-right-addon.tsx +11 -0
  43. package/input/input-right-element.jsx +1 -1
  44. package/input/input-right-element.tsx +11 -0
  45. package/input/input.css +75 -0
  46. package/input/input.d.ts +8 -7
  47. package/input/input.jsx +61 -7
  48. package/input/input.stories.d.ts +9 -4
  49. package/input/input.stories.jsx +37 -59
  50. package/input/input.stories.tsx +79 -0
  51. package/input/input.tsx +70 -0
  52. package/input/theme.ts +7 -0
  53. package/package.json +8 -4
  54. package/text-input/index.d.ts +1 -0
  55. package/{storybook → text-input}/index.js +1 -1
  56. package/text-input/index.ts +1 -0
  57. package/text-input/text-input.css +29 -0
  58. package/text-input/text-input.d.ts +22 -0
  59. package/text-input/text-input.jsx +32 -0
  60. package/text-input/text-input.stories.d.ts +9 -0
  61. package/text-input/text-input.stories.jsx +55 -0
  62. package/text-input/text-input.stories.tsx +72 -0
  63. package/text-input/text-input.tsx +99 -0
  64. package/tsconfig.json +7 -0
  65. package/tsconfig.tsbuildinfo +1 -0
  66. package/types/form-control-props.d.ts +1 -1
  67. package/types/form-control-props.ts +35 -0
  68. package/types/index.d.ts +1 -0
  69. package/types/index.js +17 -0
  70. package/types/index.ts +1 -0
  71. package/{storybook → utils}/action.d.ts +0 -0
  72. package/{storybook → utils}/action.js +0 -0
  73. package/utils/action.ts +14 -0
  74. package/utils/component-structure-analyzer.css +28 -0
  75. package/utils/component-structure-analyzer.tsx +12 -0
  76. package/utils/cx.ts +56 -0
  77. package/utils/forwardRef.ts +30 -0
  78. package/{storybook → utils}/storybook-config.d.ts +1 -1
  79. package/{storybook → utils}/storybook-config.jsx +0 -0
  80. package/utils/storybook-config.tsx +42 -0
  81. package/input/input-group.d.ts +0 -9
  82. package/input/input-group.jsx +0 -63
  83. package/postcss.config.js +0 -8
  84. package/storybook/index.d.ts +0 -1
  85. package/types.d.ts +0 -6
@@ -0,0 +1,59 @@
1
+ import React, { ReactNode, useCallback, useState } from "react";
2
+ import { ImageGalleryProvider } from "./context";
3
+ import { ImageGalleryImageProps } from "./types";
4
+ import Gallery from "./components/gallery";
5
+
6
+ interface ImageGalleryProviderProps {
7
+ children: ReactNode;
8
+ }
9
+
10
+ function ImageGallery(props: ImageGalleryProviderProps) {
11
+ const [images, setImages] = useState<ImageGalleryImageProps[]>([]);
12
+ const [imageIndex, setImageIndex] = useState<null | number>(null);
13
+
14
+ const registerImage = (image: ImageGalleryImageProps) =>
15
+ setImages((v) => [...v, image]);
16
+
17
+ const unregisterImage = (image: ImageGalleryImageProps) =>
18
+ setImages((v) => v.filter((u) => u.src !== image.src));
19
+
20
+ const openGallery = (image: ImageGalleryImageProps) =>
21
+ setImageIndex(images.findIndex((i) => i.src === image.src));
22
+
23
+ const onPrevious = useCallback(() => {
24
+ setImageIndex((v) => (v === null ? null : v - 1));
25
+ }, []);
26
+
27
+ const onNext = useCallback(() => {
28
+ setImageIndex((v) => (v === null ? null : v + 1));
29
+ }, []);
30
+
31
+ // modulo bug https://stackoverflow.com/a/4467559
32
+ const moduloImageIndex =
33
+ imageIndex === null
34
+ ? null
35
+ : imageIndex < 0
36
+ ? ((imageIndex % images.length) + images.length) % images.length
37
+ : imageIndex % images.length;
38
+
39
+ const contextValue = { registerImage, unregisterImage, openGallery };
40
+
41
+ return (
42
+ <>
43
+ <ImageGalleryProvider value={contextValue}>
44
+ {props.children}
45
+ </ImageGalleryProvider>
46
+ {typeof moduloImageIndex === "number" && (
47
+ <Gallery
48
+ onClose={() => setImageIndex(null)}
49
+ onNext={onNext}
50
+ onPrevious={onPrevious}
51
+ imageIndex={moduloImageIndex}
52
+ images={images}
53
+ />
54
+ )}
55
+ </>
56
+ );
57
+ }
58
+
59
+ export default ImageGallery;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import { useImage } from "./use-image";
3
+ import { ImageGalleryImageProps } from "@uxf/ui/image-gallery/types";
4
+
5
+ function Image(props: ImageGalleryImageProps) {
6
+ const openGallery = useImage(props);
7
+
8
+ return (
9
+ <img
10
+ src={props.src}
11
+ alt={props.alt}
12
+ title={props.title}
13
+ className={props.className}
14
+ onClick={() => openGallery(props)}
15
+ />
16
+ );
17
+ }
18
+
19
+ export default Image;
@@ -0,0 +1,3 @@
1
+ export { default as Image } from "./image";
2
+ export { default as ImageGallery } from "./image-gallery";
3
+ export * from "./use-image";
@@ -0,0 +1,6 @@
1
+ export interface ImageGalleryImageProps {
2
+ src: string;
3
+ title?: string;
4
+ alt?: string;
5
+ className?: string;
6
+ }
@@ -0,0 +1,17 @@
1
+ import { useEffect } from "react";
2
+ import { useImageGalleryContext } from "./context";
3
+ import { ImageGalleryImageProps } from "./types";
4
+
5
+ export function useImage(props: ImageGalleryImageProps) {
6
+ const { registerImage, unregisterImage, openGallery } =
7
+ useImageGalleryContext();
8
+
9
+ useEffect(() => {
10
+ registerImage(props);
11
+ return () => {
12
+ unregisterImage(props);
13
+ };
14
+ }, [props]);
15
+
16
+ return openGallery;
17
+ }
package/input/index.d.ts CHANGED
@@ -1,6 +1,12 @@
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
+ import RootInput from "./input";
2
+ import LeftElement from "./input-left-element";
3
+ import RightElement from "./input-right-element";
4
+ import LeftAddon from "./input-left-addon";
5
+ import RightAddon from "./input-right-addon";
6
+ export declare const Input: typeof RootInput & {
7
+ Element: import("react").ForwardRefExoticComponent<import("./input-element").InputElementProps & import("react").RefAttributes<HTMLInputElement>>;
8
+ LeftElement: typeof LeftElement;
9
+ RightElement: typeof RightElement;
10
+ LeftAddon: typeof LeftAddon;
11
+ RightAddon: typeof RightAddon;
12
+ };
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
+ });
package/input/index.ts ADDED
@@ -0,0 +1,14 @@
1
+ import RootInput from "./input";
2
+ import Element from "./input-element";
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
+
8
+ export const Input = Object.assign(RootInput, {
9
+ Element,
10
+ LeftElement,
11
+ RightElement,
12
+ LeftAddon,
13
+ RightAddon,
14
+ });
@@ -0,0 +1,18 @@
1
+ .uxf-input {
2
+ @apply flex flex-row;
3
+ }
4
+
5
+ .uxf-input__wrapper {
6
+ @apply flex w-full flex-row;
7
+ }
8
+
9
+ .uxf-input__element {
10
+ @apply w-full px-2;
11
+ }
12
+
13
+ .uxf-input__left-element,
14
+ .uxf-input__right-element,
15
+ .uxf-input__left-addon,
16
+ .uxf-input__right-addon {
17
+ @apply flex flex-row items-center whitespace-nowrap;
18
+ }
@@ -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,30 @@
1
+ import React from "react";
2
+ import { forwardRef } from "@uxf/ui/utils/forwardRef";
3
+ import { FormControlProps } from "@uxf/ui/types/form-control-props";
4
+
5
+ export interface InputElementProps extends FormControlProps<string> {
6
+ id?: string;
7
+ placeholder?: string;
8
+ }
9
+
10
+ type InputTypeRef = HTMLInputElement;
11
+
12
+ function InputElement(
13
+ props: InputElementProps,
14
+ ref: React.ForwardedRef<InputTypeRef>
15
+ ) {
16
+ return (
17
+ <input
18
+ id={props.id}
19
+ ref={ref}
20
+ className="uxf-input__element"
21
+ value={props.value}
22
+ onFocus={props.onFocus}
23
+ onBlur={props.onBlur}
24
+ onChange={(event) => props.onChange?.(event.target.value, event)}
25
+ placeholder={props.placeholder}
26
+ />
27
+ );
28
+ }
29
+
30
+ export default 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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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 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;