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

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 (68) hide show
  1. package/button/button.jsx +17 -0
  2. package/button/button.stories.jsx +59 -0
  3. package/button/index.js +0 -1
  4. package/button/theme.js +0 -1
  5. package/image-gallery/components/close-button.jsx +13 -0
  6. package/image-gallery/components/dot.jsx +12 -0
  7. package/image-gallery/components/gallery.jsx +74 -0
  8. package/image-gallery/components/icon-chevron-left.jsx +12 -0
  9. package/image-gallery/components/icon-chevron-right.jsx +12 -0
  10. package/image-gallery/components/icon-close.jsx +12 -0
  11. package/image-gallery/components/next-button.jsx +13 -0
  12. package/image-gallery/components/previous-button.jsx +13 -0
  13. package/image-gallery/context.jsx +12 -0
  14. package/image-gallery/image-gallery.jsx +58 -0
  15. package/image-gallery/image-gallery.stories.jsx +29 -0
  16. package/image-gallery/image.jsx +12 -0
  17. package/image-gallery/index.js +0 -1
  18. package/image-gallery/types.js +0 -1
  19. package/image-gallery/use-image.js +5 -6
  20. package/input/index.js +0 -1
  21. package/input/input-group.jsx +63 -0
  22. package/input/input-left-addon.jsx +10 -0
  23. package/input/input-left-element.jsx +10 -0
  24. package/input/input-right-addon.jsx +10 -0
  25. package/input/input-right-element.jsx +10 -0
  26. package/input/input.jsx +11 -0
  27. package/input/input.stories.jsx +100 -0
  28. package/input/theme.js +0 -1
  29. package/package.json +4 -38
  30. package/postcss.config.js +8 -0
  31. package/storybook/action.js +4 -34
  32. package/storybook/index.js +0 -1
  33. package/storybook/{storybook-config.js → storybook-config.jsx} +3 -4
  34. package/types/form-control-props.js +0 -1
  35. package/types.d.ts +3 -0
  36. package/types.js +0 -1
  37. package/utils/component-structure-analyzer.jsx +10 -0
  38. package/utils/cx.js +8 -13
  39. package/utils/forwardRef.js +3 -4
  40. package/button/button.js +0 -17
  41. package/button/button.stories.js +0 -33
  42. package/image-gallery/components/close-button.js +0 -13
  43. package/image-gallery/components/dot.js +0 -13
  44. package/image-gallery/components/gallery.js +0 -68
  45. package/image-gallery/components/icon-chevron-left.js +0 -12
  46. package/image-gallery/components/icon-chevron-right.js +0 -12
  47. package/image-gallery/components/icon-close.js +0 -12
  48. package/image-gallery/components/next-button.js +0 -13
  49. package/image-gallery/components/previous-button.js +0 -13
  50. package/image-gallery/context.js +0 -13
  51. package/image-gallery/image-gallery.js +0 -87
  52. package/image-gallery/image-gallery.stories.js +0 -27
  53. package/image-gallery/image.js +0 -13
  54. package/input/input-group.js +0 -78
  55. package/input/input-left-addon.js +0 -11
  56. package/input/input-left-element.js +0 -11
  57. package/input/input-right-addon.js +0 -11
  58. package/input/input-right-element.js +0 -11
  59. package/input/input.js +0 -12
  60. package/input/input.stories.js +0 -105
  61. package/stories/button.stories.tsx +0 -98
  62. package/stories/image-gallery.stories.tsx +0 -33
  63. package/stories/input.stories.tsx +0 -101
  64. package/styles/button.css +0 -75
  65. package/styles/component-structure-analyzer.css +0 -28
  66. package/styles/input-basic.css +0 -18
  67. package/styles/input.css +0 -74
  68. package/utils/component-structure-analyzer.js +0 -11
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const cx_1 = require("@uxf/core/utils/cx");
8
+ function Button(props) {
9
+ var _a, _b, _c;
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}>
12
+ {props.startAdornment}
13
+ {props.children}
14
+ {props.endAdornment}
15
+ </button>);
16
+ }
17
+ exports.default = Button;
@@ -0,0 +1,59 @@
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.Loading = exports.Disabled = exports.Default = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const button_1 = require("@uxf/ui/button");
9
+ const storybook_1 = require("@uxf/ui/storybook");
10
+ const react_2 = require("react");
11
+ exports.default = {
12
+ title: "UI/Button",
13
+ component: button_1.Button,
14
+ };
15
+ function Default() {
16
+ const config = (0, storybook_1.useStorybookConfig)("Button");
17
+ return (<div className="space-y-2">
18
+ {config.variants.map((variant) => (<react_2.Fragment key={variant}>
19
+ {config.colors.map((color) => (<react_2.Fragment key={color}>
20
+ {config.sizes.map((size) => (<div>
21
+ <button_1.Button key={size} variant={variant} color={color} size={size}>
22
+ Button
23
+ </button_1.Button>
24
+ </div>))}
25
+ </react_2.Fragment>))}
26
+ </react_2.Fragment>))}
27
+ </div>);
28
+ }
29
+ exports.Default = Default;
30
+ function Disabled() {
31
+ const config = (0, storybook_1.useStorybookConfig)("Button");
32
+ return (<div className="space-y-2">
33
+ {config.variants.map((variant) => (<react_2.Fragment key={variant}>
34
+ {config.colors.map((color) => (<react_2.Fragment key={color}>
35
+ {config.sizes.map((size) => (<div>
36
+ <button_1.Button key={size} variant={variant} color={color} size={size} disabled>
37
+ Button
38
+ </button_1.Button>
39
+ </div>))}
40
+ </react_2.Fragment>))}
41
+ </react_2.Fragment>))}
42
+ </div>);
43
+ }
44
+ exports.Disabled = Disabled;
45
+ function Loading() {
46
+ const config = (0, storybook_1.useStorybookConfig)("Button");
47
+ return (<div className="space-y-2">
48
+ {config.variants.map((variant) => (<react_2.Fragment key={variant}>
49
+ {config.colors.map((color) => (<react_2.Fragment key={color}>
50
+ {config.sizes.map((size) => (<div>
51
+ <button_1.Button key={size} variant={variant} color={color} size={size} loading>
52
+ Button
53
+ </button_1.Button>
54
+ </div>))}
55
+ </react_2.Fragment>))}
56
+ </react_2.Fragment>))}
57
+ </div>);
58
+ }
59
+ exports.Loading = Loading;
package/button/index.js CHANGED
@@ -21,4 +21,3 @@ exports.Button = void 0;
21
21
  var button_1 = require("@uxf/ui/button/button");
22
22
  Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(button_1).default; } });
23
23
  __exportStar(require("@uxf/ui/button/theme"), exports);
24
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYnV0dG9uL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsZ0RBQTBEO0FBQWpELGlIQUFBLE9BQU8sT0FBVTtBQUMxQix1REFBcUMifQ==
package/button/theme.js CHANGED
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGhlbWUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYnV0dG9uL3RoZW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
@@ -0,0 +1,13 @@
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 icon_close_1 = __importDefault(require("./icon-close"));
8
+ function CloseButton(props) {
9
+ return (<button className="bg-black bg-opacity-50 p-3" onClick={() => props.onClick()}>
10
+ <icon_close_1.default />
11
+ </button>);
12
+ }
13
+ exports.default = CloseButton;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cx_1 = require("@uxf/core/utils/cx");
7
+ const react_1 = __importDefault(require("react"));
8
+ function Dot(props) {
9
+ const className = (0, cx_1.cx)("h-2 w-2 rounded-full", props.active ? "bg-gray-500" : "bg-white");
10
+ return <div className={className}/>;
11
+ }
12
+ exports.default = Dot;
@@ -0,0 +1,74 @@
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
+ const close_button_1 = __importDefault(require("./close-button"));
30
+ const previous_button_1 = __importDefault(require("./previous-button"));
31
+ const next_button_1 = __importDefault(require("./next-button"));
32
+ const dot_1 = __importDefault(require("./dot"));
33
+ const react_1 = __importStar(require("react"));
34
+ function Gallery(props) {
35
+ (0, react_1.useEffect)(() => {
36
+ const onKeyDown = (event) => {
37
+ switch (event.key) {
38
+ case "ArrowRight":
39
+ props.onNext();
40
+ break;
41
+ case "ArrowLeft":
42
+ props.onPrevious();
43
+ break;
44
+ case "Escape":
45
+ props.onClose();
46
+ break;
47
+ }
48
+ };
49
+ document.body.style.overflow = "hidden";
50
+ window.addEventListener("keydown", onKeyDown);
51
+ return () => {
52
+ document.body.style.overflow = "auto";
53
+ window.removeEventListener("keydown", onKeyDown);
54
+ };
55
+ }, []);
56
+ return (<div className="fixed inset-0 top-0 bottom-0 z-50 flex flex-col bg-black bg-opacity-75 transition-opacity">
57
+ <div className="flex justify-end">
58
+ <close_button_1.default onClick={props.onClose}/>
59
+ </div>
60
+ <div className="container mx-auto flex h-full flex-1 flex-col">
61
+ <div className="relative flex flex-1 items-center justify-center">
62
+ <img className="absolute left-0 right-0 top-0 h-full w-full object-contain" src={props.images[props.imageIndex].src}/>
63
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-between p-2">
64
+ <previous_button_1.default onClick={props.onPrevious}/>
65
+ <next_button_1.default onClick={props.onNext}/>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ <div className="row mx-auto flex space-x-2 p-4">
70
+ {props.images.map((url, index) => (<dot_1.default key={url.src} active={index === props.imageIndex}/>))}
71
+ </div>
72
+ </div>);
73
+ }
74
+ exports.default = Gallery;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ function IconChevronLeft() {
8
+ return (<svg xmlns="http://www.w3.org/2000/svg" className="h-10 w-10 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
9
+ <path strokeLinecap="round" strokeLinejoin="round" d="M15 19l-7-7 7-7"/>
10
+ </svg>);
11
+ }
12
+ exports.default = IconChevronLeft;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ function IconChevronRight() {
8
+ return (<svg xmlns="http://www.w3.org/2000/svg" className="h-10 w-10 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
9
+ <path strokeLinecap="round" strokeLinejoin="round" d="M9 5l7 7-7 7"/>
10
+ </svg>);
11
+ }
12
+ exports.default = IconChevronRight;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ function IconClose() {
8
+ return (<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2} className="h-10 w-10 text-white">
9
+ <path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12"/>
10
+ </svg>);
11
+ }
12
+ exports.default = IconClose;
@@ -0,0 +1,13 @@
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 icon_chevron_right_1 = __importDefault(require("./icon-chevron-right"));
8
+ function NextButton(props) {
9
+ return (<button className="pointer-events-auto rounded-full bg-black bg-opacity-50 p-2" onClick={props.onClick}>
10
+ <icon_chevron_right_1.default />
11
+ </button>);
12
+ }
13
+ exports.default = NextButton;
@@ -0,0 +1,13 @@
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 icon_chevron_left_1 = __importDefault(require("./icon-chevron-left"));
8
+ function PreviousButton(props) {
9
+ return (<button className="pointer-events-auto rounded-full bg-black bg-opacity-50 p-2" onClick={props.onClick}>
10
+ <icon_chevron_left_1.default />
11
+ </button>);
12
+ }
13
+ exports.default = PreviousButton;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useImageGalleryContext = exports.ImageGalleryProvider = void 0;
4
+ const react_1 = require("react");
5
+ const ImageGalleryContext = (0, react_1.createContext)({
6
+ registerImage: () => null,
7
+ unregisterImage: () => null,
8
+ openGallery: () => null,
9
+ });
10
+ exports.ImageGalleryProvider = ImageGalleryContext.Provider;
11
+ const useImageGalleryContext = () => (0, react_1.useContext)(ImageGalleryContext);
12
+ exports.useImageGalleryContext = useImageGalleryContext;
@@ -0,0 +1,58 @@
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
+ const react_1 = __importStar(require("react"));
30
+ const context_1 = require("./context");
31
+ const gallery_1 = __importDefault(require("./components/gallery"));
32
+ function ImageGallery(props) {
33
+ const [images, setImages] = (0, react_1.useState)([]);
34
+ const [imageIndex, setImageIndex] = (0, react_1.useState)(null);
35
+ const registerImage = (image) => setImages((v) => [...v, image]);
36
+ const unregisterImage = (image) => setImages((v) => v.filter((u) => u.src !== image.src));
37
+ const openGallery = (image) => setImageIndex(images.findIndex((i) => i.src === image.src));
38
+ const onPrevious = (0, react_1.useCallback)(() => {
39
+ setImageIndex((v) => (v === null ? null : v - 1));
40
+ }, []);
41
+ const onNext = (0, react_1.useCallback)(() => {
42
+ setImageIndex((v) => (v === null ? null : v + 1));
43
+ }, []);
44
+ // modulo bug https://stackoverflow.com/a/4467559
45
+ const moduloImageIndex = imageIndex === null
46
+ ? null
47
+ : imageIndex < 0
48
+ ? ((imageIndex % images.length) + images.length) % images.length
49
+ : imageIndex % images.length;
50
+ const contextValue = { registerImage, unregisterImage, openGallery };
51
+ return (<>
52
+ <context_1.ImageGalleryProvider value={contextValue}>
53
+ {props.children}
54
+ </context_1.ImageGalleryProvider>
55
+ {typeof moduloImageIndex === "number" && (<gallery_1.default onClose={() => setImageIndex(null)} onNext={onNext} onPrevious={onPrevious} imageIndex={moduloImageIndex} images={images}/>)}
56
+ </>);
57
+ }
58
+ exports.default = ImageGallery;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Default = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const image_gallery_1 = __importDefault(require("./image-gallery"));
9
+ const image_1 = __importDefault(require("./image"));
10
+ exports.default = {
11
+ title: "Lab/ImageGallery",
12
+ component: image_gallery_1.default,
13
+ parameters: { actions: { argTypesRegex: "^on.*" } },
14
+ };
15
+ const images = [
16
+ "https://opentopo.app/hero_image.jpeg",
17
+ "https://opentopo.app/generated/area-18/d/9/d9033d93-ea48-4f66-b0c1-6045c091b326_1024_1024_c.jpg",
18
+ "https://opentopo.app/generated/area-16/f/4/f4a4ca79-ea9e-44d1-a4ec-3c8ccfbcc218_1024_1024_c.jpg",
19
+ "https://opentopo.app/generated/area-1/8/b/8b84e378-1f55-4ce7-b750-b504091cb833_1024_1024_c.jpg",
20
+ "https://opentopo.app/generated/area-2/e/7/e7ec532b-20c2-407e-9305-fa7cfb71f01f_1024_1024_c.jpg",
21
+ ];
22
+ function Default() {
23
+ return (<image_gallery_1.default>
24
+ <div className="flex-direction flex gap-2">
25
+ {images.map((src) => (<image_1.default key={src} src={src} className="h-56 w-56 cursor-pointer object-cover transition-transform hover:scale-105"/>))}
26
+ </div>
27
+ </image_gallery_1.default>);
28
+ }
29
+ exports.Default = Default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const use_image_1 = require("./use-image");
8
+ function Image(props) {
9
+ const openGallery = (0, use_image_1.useImage)(props);
10
+ return (<img src={props.src} alt={props.alt} title={props.title} className={props.className} onClick={() => openGallery(props)}/>);
11
+ }
12
+ exports.default = Image;
@@ -23,4 +23,3 @@ Object.defineProperty(exports, "Image", { enumerable: true, get: function () { r
23
23
  var image_gallery_1 = require("./image-gallery");
24
24
  Object.defineProperty(exports, "ImageGallery", { enumerable: true, get: function () { return __importDefault(image_gallery_1).default; } });
25
25
  __exportStar(require("./use-image"), exports);
26
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW1hZ2UtZ2FsbGVyeS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLGlDQUEyQztBQUFsQywrR0FBQSxPQUFPLE9BQVM7QUFDekIsaURBQTBEO0FBQWpELDhIQUFBLE9BQU8sT0FBZ0I7QUFDaEMsOENBQTRCIn0=
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW1hZ2UtZ2FsbGVyeS90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useImage = void 0;
4
- var react_1 = require("react");
5
- var context_1 = require("./context");
4
+ const react_1 = require("react");
5
+ const context_1 = require("./context");
6
6
  function useImage(props) {
7
- var _a = (0, context_1.useImageGalleryContext)(), registerImage = _a.registerImage, unregisterImage = _a.unregisterImage, openGallery = _a.openGallery;
8
- (0, react_1.useEffect)(function () {
7
+ const { registerImage, unregisterImage, openGallery } = (0, context_1.useImageGalleryContext)();
8
+ (0, react_1.useEffect)(() => {
9
9
  registerImage(props);
10
- return function () {
10
+ return () => {
11
11
  unregisterImage(props);
12
12
  };
13
13
  }, [props]);
14
14
  return openGallery;
15
15
  }
16
16
  exports.useImage = useImage;
17
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlLWltYWdlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ltYWdlLWdhbGxlcnkvdXNlLWltYWdlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLCtCQUFrQztBQUNsQyxxQ0FBbUQ7QUFHbkQsU0FBZ0IsUUFBUSxDQUFDLEtBQTZCO0lBQzlDLElBQUEsS0FDSixJQUFBLGdDQUFzQixHQUFFLEVBRGxCLGFBQWEsbUJBQUEsRUFBRSxlQUFlLHFCQUFBLEVBQUUsV0FBVyxpQkFDekIsQ0FBQztJQUUzQixJQUFBLGlCQUFTLEVBQUM7UUFDUixhQUFhLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDckIsT0FBTztZQUNMLGVBQWUsQ0FBQyxLQUFLLENBQUMsQ0FBQztRQUN6QixDQUFDLENBQUM7SUFDSixDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDO0lBRVosT0FBTyxXQUFXLENBQUM7QUFDckIsQ0FBQztBQVpELDRCQVlDIn0=
package/input/index.js CHANGED
@@ -16,4 +16,3 @@ var input_left_addon_1 = require("./input-left-addon");
16
16
  Object.defineProperty(exports, "InputLeftAddon", { enumerable: true, get: function () { return __importDefault(input_left_addon_1).default; } });
17
17
  var input_right_addon_1 = require("./input-right-addon");
18
18
  Object.defineProperty(exports, "InputRightAddon", { enumerable: true, get: function () { return __importDefault(input_right_addon_1).default; } });
19
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5wdXQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsaUNBQTJDO0FBQWxDLCtHQUFBLE9BQU8sT0FBUztBQUN6Qiw2Q0FBc0Q7QUFBN0MsMEhBQUEsT0FBTyxPQUFjO0FBQzlCLDJEQUFtRTtBQUExRCx1SUFBQSxPQUFPLE9BQW9CO0FBQ3BDLDZEQUFxRTtBQUE1RCx5SUFBQSxPQUFPLE9BQXFCO0FBQ3JDLHVEQUErRDtBQUF0RCxtSUFBQSxPQUFPLE9BQWtCO0FBQ2xDLHlEQUFpRTtBQUF4RCxxSUFBQSxPQUFPLE9BQW1CIn0=
@@ -0,0 +1,63 @@
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;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ function InputLeftAddon(props) {
8
+ return <div className="uxf-input-left-addon">{props.children}</div>;
9
+ }
10
+ exports.default = InputLeftAddon;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ function InputLeftElement(props) {
8
+ return <div className="uxf-input-left-element">{props.children}</div>;
9
+ }
10
+ exports.default = InputLeftElement;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ function InputRightAddon(props) {
8
+ return <div className="uxf-input-right-addon">{props.children}</div>;
9
+ }
10
+ exports.default = InputRightAddon;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ function InputRightElement(props) {
8
+ return <div className="uxf-input-right-element">{props.children}</div>;
9
+ }
10
+ exports.default = InputRightElement;
@@ -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 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}/>);
10
+ }
11
+ exports.default = (0, forwardRef_1.forwardRef)("Input", Input);